fix(region): batch migrate use enable_tls_migration option

This commit is contained in:
Zexi Li
2022-02-08 15:10:18 +08:00
parent ac268bf260
commit 0418e5f3a5
3 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -565,13 +565,14 @@ type GuestBatchMigrateRequest struct {
// swagger:ignore
PreferHost string `json:"prefer_host" yunion-deprecated-by:"prefer_host_id"`
SkipCpuCheck bool `json:"skip_cpu_check"`
EnableTLS *bool `json:"enable_tls"`
}
type GuestBatchMigrateParams struct {
Id string
LiveMigrate bool
SkipCpuCheck bool
EnableTLS bool
EnableTLS *bool
RescueMode bool
OldStatus string
}
+5
View File
@@ -4488,6 +4488,10 @@ func (manager *SGuestManager) PerformBatchMigrate(ctx context.Context, userCred
}
}
if params.EnableTLS == nil {
params.EnableTLS = &options.Options.EnableTlsMigration
}
guests := make([]SGuest, 0)
q := GuestManager.Query().In("id", params.GuestIds)
err = db.FetchModelObjects(GuestManager, q, &guests)
@@ -4516,6 +4520,7 @@ func (manager *SGuestManager) PerformBatchMigrate(ctx context.Context, userCred
RescueMode: guests[i].Status == api.VM_UNKNOWN,
OldStatus: guests[i].Status,
SkipCpuCheck: params.SkipCpuCheck,
EnableTLS: params.EnableTLS,
}
guests[i].SetStatus(userCred, api.VM_START_MIGRATE, "batch migrate")
if _, ok := hostGuests[guests[i].HostId]; ok {
@@ -49,7 +49,7 @@ func (self *HostGuestsMigrateTask) OnInit(ctx context.Context, objs []db.IStanda
guest := objs[i].(*models.SGuest)
if guests[i].LiveMigrate {
err := guest.StartGuestLiveMigrateTask(
ctx, self.UserCred, guests[i].OldStatus, preferHostId, &guests[i].SkipCpuCheck, &guests[i].EnableTLS, self.Id)
ctx, self.UserCred, guests[i].OldStatus, preferHostId, &guests[i].SkipCpuCheck, guests[i].EnableTLS, self.Id)
if err != nil {
log.Errorln(err)
}