CLOUDSTACK-9436: Release network resources on expunge command

This commit is contained in:
nvazquez 2016-06-06 11:47:45 -03:00
parent 46a6530e70
commit 148e974482
1 changed files with 20 additions and 0 deletions

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,23 @@ 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);
if (vmInstance != null){
final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vmInstance);
_networkMgr.release(profile, false);
}
else {
s_logger.error("Couldn't find vm with id = " + id + ", unable to release network resources");
}
}
private boolean cleanupVmResources(long vmId) {
boolean success = true;
// Remove vm from security groups