本文整理汇总了Golang中github.com/Azure/azure-sdk-for-go/management/virtualmachine.Role.ConfigurationSets方法的典型用法代码示例。如果您正苦于以下问题:Golang Role.ConfigurationSets方法的具体用法?Golang Role.ConfigurationSets怎么用?Golang Role.ConfigurationSets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Azure/azure-sdk-for-go/management/virtualmachine.Role
的用法示例。
在下文中一共展示了Role.ConfigurationSets方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例5: 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
}
示例6: 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
}