From 53f306e8e20023eace74c3644a20be4066ca7ca9 Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Tue, 4 Mar 2014 15:09:07 -0800 Subject: [PATCH] Send StopCommand(Cleanup) if out-of-band power-off VM is detected. --- .../src/com/cloud/vm/VirtualMachineManagerImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index 2cbde359d82..0ca0d309fea 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -4221,6 +4221,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac case Stopped: case Migrating: s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-off report while there is no pending jobs on it"); + VirtualMachineGuru vmGuru = getVmGuru(vm); + VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); + sendStop(vmGuru, profile, true); + try { stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOffReport, null); } catch (NoTransitionException e) { @@ -4233,9 +4237,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Stopped state according to power-off report from hypervisor"); - VirtualMachineGuru vmGuru = getVmGuru(vm); - VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); - sendStop(vmGuru, profile, true); break; case Destroyed: