mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
fix host get guests (#7682)
This commit is contained in:
@@ -1429,6 +1429,17 @@ func (self *SHost) GetGuests() []SGuest {
|
||||
return guests
|
||||
}
|
||||
|
||||
func (self *SHost) GetKvmGuests() []SGuest {
|
||||
q := GuestManager.Query().Equals("host_id", self.Id).Equals("hypervisor", api.HYPERVISOR_KVM)
|
||||
guests := make([]SGuest, 0)
|
||||
err := db.FetchModelObjects(GuestManager, q, &guests)
|
||||
if err != nil {
|
||||
log.Errorf("GetGuests %s", err)
|
||||
return nil
|
||||
}
|
||||
return guests
|
||||
}
|
||||
|
||||
func (self *SHost) GetGuestsMasterOnThisHost() []SGuest {
|
||||
q := self.GetGuestsQuery().IsNotEmpty("backup_host_id")
|
||||
guests := make([]SGuest, 0)
|
||||
@@ -4911,7 +4922,7 @@ func (host *SHost) PerformHostMaintenance(ctx context.Context, userCred mcclient
|
||||
preferHostId = host.Id
|
||||
}
|
||||
|
||||
guests := host.GetGuests()
|
||||
guests := host.GetKvmGuests()
|
||||
for i := 0; i < len(guests); i++ {
|
||||
lockman.LockObject(ctx, &guests[i])
|
||||
defer lockman.ReleaseObject(ctx, &guests[i])
|
||||
|
||||
Reference in New Issue
Block a user