bug 9044: don't cleanup vm resources if the vm is already expunged

status 9044: resolved fixed
This commit is contained in:
alena 2011-03-18 16:30:08 -07:00
parent 8da874ca0b
commit 2027aa9a8a
1 changed files with 15 additions and 10 deletions

View File

@ -1127,17 +1127,22 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
return false;
}
//Cleanup vm resources - all the PF/LB/StaticNat rules associated with vm
s_logger.debug("Starting cleaning up vm " + vm + " resources...");
if (cleanupVmResources(vm.getId())) {
s_logger.debug("Successfully cleaned up vm " + vm + " resources as a part of expunge process");
} else {
s_logger.warn("Failed to cleanup resources as a part of vm " + vm + " expunge");
return false;
//Only if vm is not expunged already, cleanup it's resources
if (vm != null && vm.getRemoved() == null) {
//Cleanup vm resources - all the PF/LB/StaticNat rules associated with vm
s_logger.debug("Starting cleaning up vm " + vm + " resources...");
if (cleanupVmResources(vm.getId())) {
s_logger.debug("Successfully cleaned up vm " + vm + " resources as a part of expunge process");
} else {
s_logger.warn("Failed to cleanup resources as a part of vm " + vm + " expunge");
return false;
}
_itMgr.remove(vm, _accountMgr.getSystemUser(), caller);
}
_itMgr.remove(vm, _accountMgr.getSystemUser(), caller);
return true;
return true;
} catch (ResourceUnavailableException e) {
s_logger.warn("Unable to expunge " + vm, e);
return false;