fix(region): make project of instance snapshot be consistent with the instance

This commit is contained in:
rainzm
2020-11-25 18:23:14 +08:00
parent b4011db917
commit e6c908da2e
2 changed files with 13 additions and 2 deletions
+11
View File
@@ -4335,6 +4335,17 @@ func (guest *SGuest) PerformChangeOwner(ctx context.Context, userCred mcclient.T
return nil, err
}
}
// change owner for instance snapshot
isps, err := guest.GetInstanceSnapshots()
if err != nil {
return nil, errors.Wrap(err, "unable to GetInstanceSnapshots")
}
for i := range isps {
_, err := isps[i].PerformChangeOwner(ctx, userCred, query, input)
if err != nil {
return nil, errors.Wrapf(err, "unable to change owner for instance snapshot %s", isps[i].GetId())
}
}
return guest.SVirtualResourceBase.PerformChangeOwner(ctx, userCred, query, input)
}
+2 -2
View File
@@ -281,8 +281,8 @@ func (self *SInstanceSnapshot) StartCreateInstanceSnapshotTask(
func (manager *SInstanceSnapshotManager) fillInstanceSnapshot(userCred mcclient.TokenCredential, guest *SGuest, instanceSnapshot *SInstanceSnapshot) {
instanceSnapshot.SetModelManager(manager, instanceSnapshot)
instanceSnapshot.ProjectId = userCred.GetProjectId()
instanceSnapshot.DomainId = userCred.GetProjectDomainId()
instanceSnapshot.ProjectId = guest.ProjectId
instanceSnapshot.DomainId = guest.DomainId
instanceSnapshot.GuestId = guest.Id
guestSchedInput := guest.ToSchedDesc()