mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: 创建公有云虚拟机保留镜像原密码功能失效
This commit is contained in:
@@ -34,7 +34,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
)
|
||||
|
||||
type SManagedVirtualizedGuestDriver struct {
|
||||
@@ -226,11 +225,6 @@ func (self *SManagedVirtualizedGuestDriver) GetLinuxDefaultAccount(desc cloudpro
|
||||
}
|
||||
|
||||
func (self *SManagedVirtualizedGuestDriver) RemoteDeployGuestForCreate(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest, host *models.SHost, desc cloudprovider.SManagedVMCreateConfig) (jsonutils.JSONObject, error) {
|
||||
if len(desc.Password) == 0 {
|
||||
//Azure创建必须要设置密码
|
||||
desc.Password = seclib2.RandomPassword2(12)
|
||||
}
|
||||
|
||||
ihost, _ := host.GetIHost()
|
||||
|
||||
iVM, err := func() (cloudprovider.ICloudVM, error) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/util/ansible"
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
)
|
||||
|
||||
type SHost struct {
|
||||
@@ -96,6 +97,12 @@ func (self *SHost) CreateVM(desc *cloudprovider.SManagedVMCreateConfig) (cloudpr
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if len(desc.Password) == 0 {
|
||||
//Azure创建必须要设置密码
|
||||
desc.Password = seclib2.RandomPassword2(12)
|
||||
}
|
||||
|
||||
vmId, err := self._createVM(desc.Name, desc.ExternalImageId, desc.SysDisk, desc.Cpu, desc.MemoryMB, desc.InstanceType, nic.ID, desc.IpAddr, desc.Description, desc.Password, desc.DataDisks, desc.PublicKey, desc.UserData)
|
||||
if err != nil {
|
||||
self.zone.region.DeleteNetworkInterface(nic.ID)
|
||||
|
||||
Reference in New Issue
Block a user