diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 7b67646547..8946d7ff73 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -1018,6 +1018,12 @@ func (self *SGuest) GetCustomizeColumns(ctx context.Context, userCred mcclient.T extra.Add(jsonutils.NewString(timeutils.FullIsoTime(pendingDeletedAt)), "auto_delete_at") } + isGpu := jsonutils.JSONFalse + if self.isGpu() { + isGpu = jsonutils.JSONTrue + } + extra.Add(isGpu, "is_gpu") + return self.moreExtraInfo(extra) } @@ -1087,6 +1093,13 @@ func (self *SGuest) GetExtraDetails(ctx context.Context, userCred mcclient.Token extra.Add(jsonutils.NewString(eip.IpAddr), "eip") extra.Add(jsonutils.NewString(eip.Mode), "eip_mode") } + + isGpu := jsonutils.JSONFalse + if self.isGpu() { + isGpu = jsonutils.JSONTrue + } + extra.Add(isGpu, "is_gpu") + return self.moreExtraInfo(extra) } @@ -1324,6 +1337,10 @@ func (self *SGuest) getAdminSecurityRules() string { } } +func (self *SGuest) isGpu() bool { + return len(self.GetIsolatedDevices()) != 0 +} + func (self *SGuest) GetIsolatedDevices() []SIsolatedDevice { return IsolatedDeviceManager.findAttachedDevicesOfGuest(self) }