move change ownership logic

This commit is contained in:
Pearl Dsilva 2025-05-12 17:32:43 +05:30
parent 1d46506c04
commit caa8c8183b
1 changed files with 4 additions and 3 deletions

View File

@ -7592,9 +7592,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
removeInstanceFromInstanceGroup(vm.getId());
Long newAccountId = newAccount.getAccountId();
updateVmOwner(newAccount, vm, domainId, newAccountId);
updateVolumesOwner(volumes, oldAccount, newAccount, newAccountId);
AtomicBoolean isNetworkAutoCreated = new AtomicBoolean(false);
try {
updateVmNetwork(cmd, caller, vm, newAccount, template, isNetworkAutoCreated);
@ -7606,6 +7603,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
throw new CloudRuntimeException(String.format("Unable to update networks when assigning VM [%s] due to [%s].", vm, e.getMessage()), e);
}
updateVmOwner(newAccount, vm, domainId, newAccountId);
updateVolumesOwner(volumes, oldAccount, newAccount, newAccountId);
logger.trace(String.format("Incrementing new account [%s] resource count.", newAccount));
if (!isResourceCountRunningVmsOnlyEnabled()) {
resourceCountIncrement(newAccountId, vm.isDisplayVm(), offering, template);