mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region,host): migrate converted servers (#20698)
This commit is contained in:
@@ -149,12 +149,19 @@ func (task *GuestMigrateTask) SaveScheduleResult(ctx context.Context, obj ISched
|
||||
// prepare disk for migration
|
||||
if len(disk.TemplateId) > 0 && isLocalStorage {
|
||||
templates := []string{}
|
||||
guestdisks, _ := guest.GetDisks()
|
||||
for i := range guestdisks {
|
||||
if guestdisks[i].TemplateId != "" {
|
||||
templates = append(templates, guestdisks[i].TemplateId)
|
||||
if sourceGuestId := guest.GetMetadata(ctx, api.SERVER_META_CONVERT_FROM_ESXI, task.UserCred); len(sourceGuestId) > 0 {
|
||||
// skip cache images
|
||||
} else if sourceGuestId := guest.GetMetadata(ctx, api.SERVER_META_CONVERT_FROM_CLOUDPODS, task.UserCred); len(sourceGuestId) > 0 {
|
||||
// skip cache images
|
||||
} else {
|
||||
guestdisks, _ := guest.GetDisks()
|
||||
for i := range guestdisks {
|
||||
if guestdisks[i].TemplateId != "" {
|
||||
templates = append(templates, guestdisks[i].TemplateId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(templates) > 0 {
|
||||
body.Set("cache_templates", jsonutils.NewStringArray(templates))
|
||||
}
|
||||
|
||||
@@ -835,7 +835,7 @@ func (s *SLocalStorage) DestinationPrepareMigrate(
|
||||
return errors.Wrap(err, "CreateFromUrl")
|
||||
}
|
||||
}
|
||||
if rebaseDisks && len(templateId) > 0 && len(baseImagePath) == 0 {
|
||||
if rebaseDisks && len(templateId) > 0 && len(baseImagePath) == 0 && sysDiskHasTemplate {
|
||||
templatePath := path.Join(storageManager.LocalStorageImagecacheManager.GetPath(), templateId)
|
||||
// check if template is encrypted
|
||||
img, err := qemuimg.NewQemuImage(templatePath)
|
||||
|
||||
Reference in New Issue
Block a user