CLOUDSTACK-9407: Release network resources on expunge command

This commit is contained in:
nvazquez 2016-06-06 11:47:45 -03:00 committed by nvazquez
parent 22c6b47473
commit d3f3fb0590
2 changed files with 18 additions and 2 deletions

View File

@ -1577,8 +1577,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
try {
_networkMgr.release(profile, cleanUpEvenIfUnableToStop);
s_logger.debug("Successfully released network resources for the vm " + vm);
s_logger.debug("Not releasing network resources until expunge command is sent");
//_networkMgr.release(profile, cleanUpEvenIfUnableToStop);
//s_logger.debug("Successfully released network resources for the vm " + vm);
} catch (final Exception e) {
s_logger.warn("Unable to release some network resources.", e);
}

View File

@ -2046,6 +2046,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
return false;
}
try {
releaseNetworkResourcesOnExpunge(vm.getId());
List<VolumeVO> rootVol = _volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
// expunge the vm
_itMgr.advanceExpunge(vm.getUuid());
@ -2086,6 +2089,18 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
}
/**
* Release network resources, it was done on vm stop previously.
* @param id vm id
* @throws ConcurrentOperationException
* @throws ResourceUnavailableException
*/
private void releaseNetworkResourcesOnExpunge(long id) throws ConcurrentOperationException, ResourceUnavailableException {
final VMInstanceVO vmInstance = _vmDao.findById(id);
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vmInstance);
_networkMgr.release(profile, false);
}
private boolean cleanupVmResources(long vmId) {
boolean success = true;
// Remove vm from security groups