server: expunge if flag is set (#2825)

In integration work for CCS I found that the service call UserVmService.destroyVm(long uuid, boolean expunge) does not honour the expunge flag. I traced it down to the implementation VirtualMachineManagerImpl.destroy(String vmUuid, boolean expunge).
Testing: manual testing so far, testing will pose some crosscutting challanges as the behaviour and implementation are seperated by about five layers of abstraction.
This commit is contained in:
dahn 2018-09-04 10:08:26 +02:00 committed by Rohit Yadav
parent 263559c19e
commit eb3953f41a
1 changed files with 7 additions and 0 deletions

View File

@ -1890,6 +1890,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (!stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm);
throw new CloudRuntimeException("Unable to destroy " + vm);
} else {
if (expunge) {
if (!stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, vm.getHostId())) {
s_logger.debug("Unable to expunge the vm because it is not in the correct state: " + vm);
throw new CloudRuntimeException("Unable to expunge " + vm);
}
}
}
} catch (final NoTransitionException e) {
s_logger.debug(e.getMessage());