當前位置: 首頁>>代碼示例>>Golang>>正文


Golang virtualmachine.Role類代碼示例

本文整理匯總了Golang中github.com/Azure/azure-sdk-for-go/management/virtualmachine.Role的典型用法代碼示例。如果您正苦於以下問題:Golang Role類的具體用法?Golang Role怎麽用?Golang Role使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Role類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: configureForLinux

//
// configureForLinux sets up the VM role for Linux specific configuration
//
// Paramters:
//   role: role that needs to be updated with Linux configuration
//   dnsName: name of the machine that we are trying to create
//
// Returns:
//   error: errors from reading certs, getting thumbprint and adding
//   certificate to hostedservice
//
func (d *Driver) configureForLinux(role *virtualmachine.Role, dnsName string) error {

	// Get the Azure client
	client, err := d.getClient()
	if err != nil {
		return err
	}

	mediaLink := fmt.Sprintf("http://%s.blob.core.windows.net/vhds/%s.vhd",
		d.StorageAccount, dnsName)

	// Setup the image configuration
	vmutils.ConfigureDeploymentFromPlatformImage(
		role,
		d.Image,
		mediaLink,
		"")

	// Read the certificate
	data, err := ioutil.ReadFile(d.azureCertPath())
	if err != nil {
		return err
	}

	// Add the certificate to the hostedservice
	if _, err := hostedservice.NewClient(client).AddCertificate(dnsName, data, "pfx", ""); err != nil {
		return err
	}

	thumbPrint, err := getServiceCertFingerprint(d.azureCertPath())
	if err != nil {
		return err
	}

	vmutils.ConfigureForLinux(role, dnsName, d.SSHUser, d.UserPassword, thumbPrint)
	vmutils.ConfigureWithPublicSSH(role)

	role.UseCertAuth = true
	role.CertPath = d.azureCertPath()

	// Attach VM to a specific subnet
	if d.Subnet != "" {
		err = vmutils.ConfigureWithSubnet(role, d.Subnet)
		if err != nil {
			log.Error("failed to configure subnet:", d.Subnet, ", err:", err)
			return err
		}
		log.Debug("subnet is:", d.Subnet)
	}

	return nil
}
開發者ID:containerx,項目名稱:machine,代碼行數:63,代碼來源:azure.go

示例2: ConfigureDeploymentFromPublishedVMImage

// ConfigureDeploymentFromPublishedVMImage configures VM Role to deploy from
// a published (public) VM image.
func ConfigureDeploymentFromPublishedVMImage(
	role *vm.Role,
	vmImageName string,
	mediaLocation string,
	provisionGuestAgent bool) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.VMImageName = vmImageName
	role.MediaLocation = mediaLocation
	role.ProvisionGuestAgent = provisionGuestAgent
	return nil
}
開發者ID:Zordrak,項目名稱:terraform,代碼行數:16,代碼來源:deployment.go

示例3: ConfigureDeploymentFromExistingOSDisk

// ConfigureDeploymentFromExistingOSDisk configures VM Role to deploy from an
// existing disk. 'label' is optional.
func ConfigureDeploymentFromExistingOSDisk(role *vm.Role, osDiskName, label string) error {
	role.OSVirtualHardDisk = &vm.OSVirtualHardDisk{
		DiskName:  osDiskName,
		DiskLabel: label,
	}
	return nil
}
開發者ID:Zordrak,項目名稱:terraform,代碼行數:9,代碼來源:deployment.go

示例4: ConfigureForLinux

// 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 ConfigureForLinux(role *vm.Role, hostname, user, password string, sshPubkeyCertificateThumbprint ...string) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.ConfigurationSets = updateOrAddConfig(role.ConfigurationSets, vm.ConfigurationSetTypeLinuxProvisioning,
		func(config *vm.ConfigurationSet) {
			config.HostName = hostname
			config.UserName = user
			config.UserPassword = password
			if password != "" {
				config.DisableSSHPasswordAuthentication = "false"
			}
			if len(sshPubkeyCertificateThumbprint) != 0 {
				config.SSH = &vm.SSH{}
				for _, k := range sshPubkeyCertificateThumbprint {
					config.SSH.PublicKeys = append(config.SSH.PublicKeys,
						vm.PublicKey{
							Fingerprint: k,
							Path:        "/home/" + user + "/.ssh/authorized_keys",
						},
					)
				}
			}
		},
	)

	return nil
}
開發者ID:qingfuwang,項目名稱:azure-sdk-for-go,代碼行數:34,代碼來源:vmutils.go

示例5: ConfigureDeploymentFromUserVMImage

// ConfigureDeploymentFromUserVMImage configures VM Role to deploy from a previously
// captured (user generated) VM image.
func ConfigureDeploymentFromUserVMImage(
	role *vm.Role,
	vmImageName string) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.VMImageName = vmImageName
	return nil
}
開發者ID:Zordrak,項目名稱:terraform,代碼行數:12,代碼來源:deployment.go

示例6: configureWithCustomData

func configureWithCustomData(role *vm.Role, customData string, typ vm.ConfigurationSetType) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.ConfigurationSets = updateOrAddConfig(role.ConfigurationSets, typ,
		func(config *vm.ConfigurationSet) {
			config.CustomData = customData
		})

	return nil
}
開發者ID:Originate,項目名稱:terraform,代碼行數:12,代碼來源:vmutils.go

示例7: ConfigureWithSubnet

// ConfigureWithSubnet associates the Role with a specific subnet
func ConfigureWithSubnet(role *vm.Role, subnet string) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.ConfigurationSets = updateOrAddConfig(role.ConfigurationSets, vm.ConfigurationSetTypeNetwork,
		func(config *vm.ConfigurationSet) {
			config.SubnetNames = append(config.SubnetNames, subnet)
		})

	return nil
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:13,代碼來源:network.go

示例8: ConfigureWithSecurityGroup

// ConfigureWithSecurityGroup associates the Role with a specific network security group
func ConfigureWithSecurityGroup(role *vm.Role, networkSecurityGroup string) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.ConfigurationSets = updateOrAddConfig(role.ConfigurationSets, vm.ConfigurationSetTypeNetwork,
		func(config *vm.ConfigurationSet) {
			config.NetworkSecurityGroup = networkSecurityGroup
		})

	return nil
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:13,代碼來源:network.go

示例9: AddAzureVMExtensionConfiguration

func AddAzureVMExtensionConfiguration(role *vm.Role, name, publisher, version, referenceName, state string,
	publicConfigurationValue, privateConfigurationValue []byte) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	extension := vm.ResourceExtensionReference{
		Name:          name,
		Publisher:     publisher,
		Version:       version,
		ReferenceName: referenceName,
		State:         state,
	}

	if len(privateConfigurationValue) != 0 {
		extension.ParameterValues = append(extension.ParameterValues, vm.ResourceExtensionParameter{
			Key:   "ignored",
			Value: base64.StdEncoding.EncodeToString(privateConfigurationValue),
			Type:  "Private",
		})
	}

	if len(publicConfigurationValue) != 0 {
		extension.ParameterValues = append(extension.ParameterValues, vm.ResourceExtensionParameter{
			Key:   "ignored",
			Value: base64.StdEncoding.EncodeToString(publicConfigurationValue),
			Type:  "Public",
		})
	}

	if role.ResourceExtensionReferences == nil {
		role.ResourceExtensionReferences = &[]vm.ResourceExtensionReference{}
	}
	extensionList := append(*role.ResourceExtensionReferences, extension)
	role.ResourceExtensionReferences = &extensionList
	return nil
}
開發者ID:Zordrak,項目名稱:terraform,代碼行數:37,代碼來源:extensions.go

示例10: ConfigureDeploymentFromPlatformImage

// 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 ConfigureDeploymentFromPlatformImage(
	role *vm.Role,
	imageName string,
	mediaLink string,
	label string) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.OSVirtualHardDisk = &vm.OSVirtualHardDisk{
		SourceImageName: imageName,
		MediaLink:       mediaLink,
	}
	return nil
}
開發者ID:Zordrak,項目名稱:terraform,代碼行數:18,代碼來源:deployment.go

示例11: ConfigureForWindows

// 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 ConfigureForWindows(role *vm.Role, hostname, user, password string, enableAutomaticUpdates bool, timeZone string) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.ConfigurationSets = updateOrAddConfig(role.ConfigurationSets, vm.ConfigurationSetTypeWindowsProvisioning,
		func(config *vm.ConfigurationSet) {
			config.ComputerName = hostname
			config.AdminUsername = user
			config.AdminPassword = password
			config.EnableAutomaticUpdates = enableAutomaticUpdates
			config.TimeZone = timeZone
		},
	)

	return nil
}
開發者ID:qingfuwang,項目名稱:azure-sdk-for-go,代碼行數:22,代碼來源:vmutils.go

示例12: ConfigureWithExternalPort

// ConfigureWithExternalPort adds a new InputEndpoint to the Role, exposing a
// port externally
func ConfigureWithExternalPort(role *vm.Role, name string, localport, externalport int, protocol vm.InputEndpointProtocol) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.ConfigurationSets = updateOrAddConfig(role.ConfigurationSets, vm.ConfigurationSetTypeNetwork,
		func(config *vm.ConfigurationSet) {
			config.InputEndpoints = append(config.InputEndpoints, vm.InputEndpoint{
				LocalPort: localport,
				Name:      name,
				Port:      externalport,
				Protocol:  protocol,
			})
		})

	return nil
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:19,代碼來源:network.go

示例13: ConfigureDeploymentFromRemoteImage

// 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 ConfigureDeploymentFromRemoteImage(
	role *vm.Role,
	remoteImageSourceURL string,
	os string,
	newDiskName string,
	destinationVhdStorageURL string,
	label string) error {
	if role == nil {
		return fmt.Errorf(errParamNotSpecified, "role")
	}

	role.OSVirtualHardDisk = &vm.OSVirtualHardDisk{
		RemoteSourceImageLink: remoteImageSourceURL,
		MediaLink:             destinationVhdStorageURL,
		DiskName:              newDiskName,
		OS:                    os,
		DiskLabel:             label,
	}
	return nil
}
開發者ID:Zordrak,項目名稱:terraform,代碼行數:24,代碼來源:deployment.go

示例14: appendDataDisk

func appendDataDisk(role *vm.Role, disk vm.DataVirtualHardDisk) {
	disk.Lun = len(role.DataVirtualHardDisks)
	role.DataVirtualHardDisks = append(role.DataVirtualHardDisks, disk)
}
開發者ID:RezaDKhan,項目名稱:terraform,代碼行數:4,代碼來源:datadisks.go


注:本文中的github.com/Azure/azure-sdk-for-go/management/virtualmachine.Role類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。