From 4a36afc4c5045285d02f131575295bd0c38a8d3f Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Wed, 9 Nov 2022 00:08:21 +0800 Subject: [PATCH] fix(region): add power states check in some cases (#15323) --- pkg/compute/models/guest_actions.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 574c25e790..ec2c089783 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -70,7 +70,8 @@ import ( func (self *SGuest) GetDetailsVnc(ctx context.Context, userCred mcclient.TokenCredential, input *cloudprovider.ServerVncInput) (*cloudprovider.ServerVncOutput, error) { ret := &cloudprovider.ServerVncOutput{} - if utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_BLOCK_STREAM, api.VM_MIGRATING}) { + if self.PowerStates == api.VM_POWER_STATES_ON || + utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_BLOCK_STREAM, api.VM_MIGRATING}) { host, err := self.GetHost() if err != nil { return nil, httperrors.NewInternalServerError(errors.Wrapf(err, "GetHost").Error()) @@ -116,7 +117,8 @@ func (self *SGuest) PerformMonitor( query jsonutils.JSONObject, input *api.ServerMonitorInput, ) (jsonutils.JSONObject, error) { - if utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_BLOCK_STREAM, api.VM_MIGRATING}) { + if self.PowerStates == api.VM_POWER_STATES_ON || + utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_BLOCK_STREAM, api.VM_MIGRATING}) { if input.COMMAND == "" { return nil, httperrors.NewMissingParameterError("command") }