From 042a5728183a853791f03c34f231de4f0986dfc4 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 12 Apr 2021 17:33:42 +0800 Subject: [PATCH] region: guests: sshable: only check sshable state when in running state --- pkg/compute/models/guest_sshable.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/compute/models/guest_sshable.go b/pkg/compute/models/guest_sshable.go index c6f37c71a1..662a94a3a2 100644 --- a/pkg/compute/models/guest_sshable.go +++ b/pkg/compute/models/guest_sshable.go @@ -72,6 +72,10 @@ func (guest *SGuest) GetDetailsSshable( userCred mcclient.TokenCredential, query jsonutils.JSONObject, ) (jsonutils.JSONObject, error) { + if guest.Status != compute_api.VM_RUNNING { + return nil, httperrors.NewBadRequestError("server sshable state can only be checked when in running state") + } + tryData := &GuestSshableTryData{ User: "cloudroot", }