From eb3953f41a167060d62d6fb35abf49b08e75b816 Mon Sep 17 00:00:00 2001 From: dahn Date: Tue, 4 Sep 2018 10:08:26 +0200 Subject: [PATCH] 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. --- .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index 6f2ae852e12..682bfb9936e 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -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());