From bf71e62224bdd4a2a7d9aa2c24b2687e26aad091 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Thu, 6 Sep 2018 11:20:59 +0800 Subject: [PATCH] regionv2 support vnc connect baremetal --- pkg/compute/models/hosts.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 00f653b80a..089886833b 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -1575,6 +1575,21 @@ func (self *SHost) GetExtraDetails(ctx context.Context, userCred mcclient.TokenC return self.getMoreDetails(extra) } +func (self *SHost) AllowGetDetailsVnc(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool { + return userCred.IsSystemAdmin() +} + +func (self *SHost) GetDetailsVnc(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (jsonutils.JSONObject, error) { + if utils.IsInStringArray(self.Status, []string{BAREMETAL_READY, BAREMETAL_RUNNING}) { + retval := jsonutils.NewDict() + retval.Set("host_id", jsonutils.NewString(self.Id)) + zone := self.GetZone() + retval.Set("zone", jsonutils.NewString(zone.GetName())) + return retval, nil + } + return jsonutils.NewDict(), nil +} + func (manager *SHostManager) GetHostsByManagerAndRegion(managerId string, regionId string) []SHost { hosts := HostManager.Query().SubQuery() zones := ZoneManager.Query().SubQuery()