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