vmutils

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2015 License: MIT, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vmutils provides convenience methods for creating Virtual Machine Role configurations.

Example
dnsName := "test-vm-from-go"
storageAccount := "mystorageaccount"
location := "West US"
vmSize := "Small"
vmImage := "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04-LTS-amd64-server-20140724-en-us-30GB"
userName := "testuser"
userPassword := "Test123"

client, err := management.ClientFromPublishSettingsFile("path/to/downloaded.publishsettings", "")
if err != nil {
	panic(err)
}

// create hosted service
if err := hostedservice.NewClient(client).CreateHostedService(hostedservice.CreateHostedServiceParameters{
	ServiceName: dnsName,
	Location:    location,
	Label:       base64.StdEncoding.EncodeToString([]byte(dnsName))}); err != nil {
	panic(err)
}

// create virtual machine
role := NewVMConfiguration(dnsName, vmSize)
ConfigureDeploymentFromPlatformImage(
	&role,
	vmImage,
	fmt.Sprintf("http://%s.blob.core.chinacloudapi.cn/sdktest/%s.vhd", storageAccount, dnsName),
	"")
ConfigureForLinux(&role, dnsName, userName, userPassword)
ConfigureWithPublicSSH(&role)

operationID, err := virtualmachine.NewClient(client).
	CreateDeployment(role, dnsName, virtualmachine.CreateDeploymentOptions{})
if err != nil {
	panic(err)
}
err = client.WaitForOperation(operationID, nil)
if err != nil {
	panic(err)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAzureDockerVMExtensionConfiguration

func AddAzureDockerVMExtensionConfiguration(role *vm.Role, dockerPort int, version string) error

AddAzureDockerVMExtensionConfiguration adds the DockerExtension to the role configuratioon and opens a port "dockerPort" TODO(ahmetalpbalkan) Deprecate this and move to 'docker-machine' codebase.

func AddAzureVMExtensionConfiguration

func AddAzureVMExtensionConfiguration(role *vm.Role, name, publisher, version, referenceName, state string,
	publicConfigurationValue, privateConfigurationValue []byte) error

func ConfigureDeploymentFromExistingOSDisk

func ConfigureDeploymentFromExistingOSDisk(role *vm.Role, osDiskName, label string) error

ConfigureDeploymentFromExistingOSDisk configures VM Role to deploy from an existing disk. 'label' is optional.

func ConfigureDeploymentFromPlatformImage

func ConfigureDeploymentFromPlatformImage(
	role *vm.Role,
	imageName string,
	mediaLink string,
	label string) error

ConfigureDeploymentFromPlatformImage configures VM Role to deploy from a platform image. See osimage package for methods to retrieve a list of the available platform images. "label" is optional.

func ConfigureDeploymentFromRemoteImage

func ConfigureDeploymentFromRemoteImage(
	role *vm.Role,
	remoteImageSourceURL string,
	os string,
	newDiskName string,
	destinationVhdStorageURL string,
	label string) error

ConfigureDeploymentFromRemoteImage configures VM Role to deploy from a remote image source. "remoteImageSourceURL" can be any publically accessible URL to a VHD file, including but not limited to a SAS Azure Storage blob url. "os" needs to be either "Linux" or "Windows". "label" is optional.

func ConfigureDeploymentFromVMImage

func ConfigureDeploymentFromVMImage(
	role *vm.Role,
	vmImageName string,
	mediaLocation string,
	provisionGuestAgent bool) error

ConfigureDeploymentFromVMImage configures VM Role to deploy from a previously captured VM image.

func ConfigureForLinux

func ConfigureForLinux(role *vm.Role, hostname, user, password string, sshPubkeyCertificateThumbprint ...string) error

ConfigureForLinux adds configuration for when deploying a generalized Linux image. If "password" is left empty, SSH password security will be disabled by default. Certificates with SSH public keys should already be uploaded to the cloud service where the VM will be deployed and referenced here only by their thumbprint.

func ConfigureForWindows

func ConfigureForWindows(role *vm.Role, hostname, user, password string, enableAutomaticUpdates bool, timeZone string) error

ConfigureForWindows adds configuration for when deploying a generalized Windows image. timeZone can be left empty. For a complete list of supported time zone entries, you can either refer to the values listed in the registry entry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones" or you can use the tzutil command-line tool to list the valid time.

func ConfigureWindowsToJoinDomain

func ConfigureWindowsToJoinDomain(role *vm.Role, username, password, domainToJoin, machineOU string) error

ConfigureWindowsToJoinDomain adds configuration to join a new Windows vm to a domain. "username" must be in UPN form (user@domain.com), "machineOU" can be left empty

func ConfigureWithExistingDataDisk

func ConfigureWithExistingDataDisk(role *vm.Role, diskName string, cachingType vmdisk.HostCachingType) error

ConfigureWithExistingDataDisk adds configuration for an existing data disk

func ConfigureWithExternalPort

func ConfigureWithExternalPort(role *vm.Role, name string, localport, externalport int, protocol vm.InputEndpointProtocol) error

ConfigureWithExternalPort adds a new InputEndpoint to the Role, exposing a port externally

func ConfigureWithNewDataDisk

func ConfigureWithNewDataDisk(role *vm.Role, label, destinationVhdStorageURL string, sizeInGB int, cachingType vmdisk.HostCachingType) error

ConfigureWithNewDataDisk adds configuration for a new (empty) data disk

func ConfigureWithPublicPowerShell

func ConfigureWithPublicPowerShell(role *vm.Role) error

ConfigureWithPublicPowerShell adds configuration exposing port 5986 externally

func ConfigureWithPublicRDP

func ConfigureWithPublicRDP(role *vm.Role) error

ConfigureWithPublicRDP adds configuration exposing port 3389 externally

func ConfigureWithPublicSSH

func ConfigureWithPublicSSH(role *vm.Role) error

ConfigureWithPublicSSH adds configuration exposing port 22 externally

func ConfigureWithSecurityGroup

func ConfigureWithSecurityGroup(role *vm.Role, networkSecurityGroup string) error

ConfigureWithSecurityGroup associates the Role with a specific network security group

func ConfigureWithSubnet

func ConfigureWithSubnet(role *vm.Role, subnet string) error

ConfigureWithSubnet associates the Role with a specific subnet

func ConfigureWithVhdDataDisk

func ConfigureWithVhdDataDisk(role *vm.Role, sourceVhdStorageURL string, cachingType vmdisk.HostCachingType) error

ConfigureWithVhdDataDisk adds configuration for adding a vhd in a storage account as a data disk

func IsRoleSizeAvailableInLocation

func IsRoleSizeAvailableInLocation(managementclient management.Client, location, roleSizeName string) (bool, error)

IsRoleSizeAvailableInLocation retrieves all available sizes in the specified location and returns whether that the provided roleSizeName is part of that list.

func IsRoleSizeValid

func IsRoleSizeValid(vmclient vm.VirtualMachineClient, roleSizeName string) (bool, error)

IsRoleSizeValid retrieves the available rolesizes using vmclient.GetRoleSizeList() and returns whether that the provided roleSizeName is part of that list

func NewVMConfiguration

func NewVMConfiguration(name string, roleSize string) vm.Role

NewVMConfiguration creates configuration for a new virtual machine Role.

func WaitForDeploymentPowerState

func WaitForDeploymentPowerState(client management.Client, cloudServiceName, deploymentName string, desiredPowerstate vm.PowerState) error

WaitForDeploymentPowerState blocks until all role instances in deployment to reach desired power state.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL