Skip to content

Commit

Permalink
Merge pull request apache#1613 from nvazquez/vmnetworkmapissue
Browse files Browse the repository at this point in the history
CLOUDSTACK-9436: vm_network_map table cleanup, release network resources on expunge commandJIRA TICKET: https://issues.apache.org/jira/browse/CLOUDSTACK-9436

This PR replaces apache#1594

Due to error on `test/integration/smoke/test_vpc_redundant.py` it was found out that `vm_network_map` table should be less aggresive on vm stop

* pr/1613:
  CLOUDSTACK-9436: Release network resources on expunge command

Signed-off-by: Will Stevens <williamstevens@gmail.com>
  • Loading branch information
swill committed Jul 25, 2016
2 parents 46a6530 + 148e974 commit 0a0839e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions server/src/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2046,6 +2046,9 @@ public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
return false;
}
try {

releaseNetworkResourcesOnExpunge(vm.getId());

List<VolumeVO> rootVol = _volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
// expunge the vm
_itMgr.advanceExpunge(vm.getUuid());
Expand Down Expand Up @@ -2086,6 +2089,23 @@ public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
}
}

/**
* 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
Expand Down

0 comments on commit 0a0839e

Please sign in to comment.