Merge pull request #2123 from ioito/hotfix/qx-managed-keypair

fix: get keypair info fail after rebuild-root
This commit is contained in:
yunion-ci-robot
2019-08-07 18:03:43 +08:00
committed by GitHub
2 changed files with 13 additions and 2 deletions
+12 -1
View File
@@ -22,6 +22,7 @@ import (
"github.com/pkg/errors"
"yunion.io/x/onecloud/pkg/util/cloudinit"
"yunion.io/x/onecloud/pkg/util/seclib2"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
@@ -450,7 +451,17 @@ func (self *SManagedVirtualizedGuestDriver) RemoteDeployGuestForDeploy(ctx conte
desc.Password = ""
}
return iVM.DeployVM(ctx, desc.Name, desc.Password, desc.PublicKey, deleteKeypair, desc.Description)
e := iVM.DeployVM(ctx, desc.Name, desc.Password, desc.PublicKey, deleteKeypair, desc.Description)
if e != nil {
return e
}
//解绑秘钥后需要重置密码
if deleteKeypair {
desc.Password = seclib2.RandomPassword2(12)
return iVM.DeployVM(ctx, desc.Name, desc.Password, desc.PublicKey, false, desc.Description)
}
return nil
}()
if err != nil {
return nil, err
+1 -1
View File
@@ -51,7 +51,7 @@ func fetchIVMinfo(desc cloudprovider.SManagedVMCreateConfig, iVM cloudprovider.I
//避免在rebuild_root时绑定秘钥,没有account信息
data.Add(jsonutils.NewString(account), "account")
if len(passwd) > 0 {
if len(passwd) > 0 || len(publicKey) > 0 {
var encpasswd string
var err error
if len(publicKey) > 0 {