diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 7c0f3f7327..a2942078a9 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -1012,6 +1012,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) } @@ -1078,6 +1084,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) } @@ -1315,6 +1328,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) }