diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index a878cf000e..19360bdb0c 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -723,8 +723,7 @@ func (self *SGuest) PerformClone(ctx context.Context, userCred mcclient.TokenCre } func (self *SGuest) PerformSetPassword(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.ServerSetPasswordInput) (jsonutils.JSONObject, error) { - switch self.Status { - case api.VM_RUNNING: + if self.Hypervisor == api.HYPERVISOR_KVM && self.Status == api.VM_RUNNING { inputQga := &api.ServerQgaSetPasswordInput{ Username: input.Username, Password: input.Password, @@ -740,15 +739,13 @@ func (self *SGuest) PerformSetPassword(ctx context.Context, userCred mcclient.To inputQga.Password = seclib2.RandomPassword2(12) } return self.PerformQgaSetPassword(ctx, userCred, query, inputQga) - case api.VM_READY: + } else { inputDeploy := api.ServerDeployInput{ Password: input.Password, ResetPassword: input.ResetPassword, AutoStart: input.AutoStart, } return self.PerformDeploy(ctx, userCred, query, inputDeploy) - default: - return nil, httperrors.NewServerStatusError("Cannot deploy in status %s", self.Status) } } diff --git a/pkg/compute/tasks/guest_qga_reset_password_task.go b/pkg/compute/tasks/guest_qga_reset_password_task.go index 579cf5fbe6..ec580ac6a8 100644 --- a/pkg/compute/tasks/guest_qga_reset_password_task.go +++ b/pkg/compute/tasks/guest_qga_reset_password_task.go @@ -98,7 +98,7 @@ func (self *GuestQgaSetPasswordTask) OnQgaSetUserPassword(ctx context.Context, g guest.SetAllMetadata(ctx, info, self.UserCred) } - logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_SET_USER_PASSWORD, "", self.UserCred, true) + logclient.AddActionLogWithContext(ctx, guest, logclient.ACT_SET_USER_PASSWORD, "qga set password success", self.UserCred, true) self.SetStageComplete(ctx, nil) }