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()