mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-9436: Release network resources on expunge command
This commit is contained in:
parent
46a6530e70
commit
148e974482
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue