mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #9360 from ioito/bugfix/qx-server-sync
fix(region): sync servers
This commit is contained in:
@@ -95,15 +95,11 @@ func (self *BaremetalSyncAllGuestsStatusTask) OnInit(ctx context.Context, obj db
|
||||
}
|
||||
|
||||
func (self *BaremetalSyncAllGuestsStatusTask) OnGuestSyncStatusComplete(ctx context.Context, baremetal *models.SHost, body jsonutils.JSONObject) {
|
||||
var guests = make([]models.SGuest, 0)
|
||||
for _, guest := range baremetal.GetGuests() {
|
||||
if guest.Status == api.VM_UNKNOWN && guest.Hypervisor != api.HYPERVISOR_BAREMETAL {
|
||||
guest.SetStatus(self.UserCred, models.SYNC_STATUS, "")
|
||||
guests = append(guests, guest)
|
||||
}
|
||||
}
|
||||
guests, _ := baremetal.GetGuests()
|
||||
for _, guest := range guests {
|
||||
guest.StartSyncstatus(ctx, self.UserCred, "")
|
||||
if guest.Status == api.VM_UNKNOWN && guest.Hypervisor != api.HYPERVISOR_BAREMETAL {
|
||||
guest.StartSyncstatus(ctx, self.GetUserCred(), "")
|
||||
}
|
||||
}
|
||||
log.Infof("All unknown guests syncstatus complete")
|
||||
self.SetStageComplete(ctx, nil)
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -38,9 +39,14 @@ func init() {
|
||||
func (self *BaremetalUnconvertHypervisorTask) OnInit(ctx context.Context, obj db.IStandaloneModel, body jsonutils.JSONObject) {
|
||||
baremetal := obj.(*models.SHost)
|
||||
baremetal.SetStatus(self.UserCred, api.BAREMETAL_CONVERTING, "")
|
||||
guests := baremetal.GetGuests()
|
||||
guests, err := baremetal.GetGuests()
|
||||
if err != nil {
|
||||
self.SetStageFailed(ctx, jsonutils.NewString(errors.Wrapf(err, "baremetal.GetGuests").Error()))
|
||||
return
|
||||
}
|
||||
if len(guests) > 1 {
|
||||
self.SetStageFailed(ctx, jsonutils.NewString("Host guest conut > 1"))
|
||||
return
|
||||
}
|
||||
if len(guests) == 1 {
|
||||
guest := guests[0]
|
||||
|
||||
Reference in New Issue
Block a user