From 58cbedc9f5fab22b201c18cf12baf93b0cc4c4ef Mon Sep 17 00:00:00 2001 From: Drew Thorstensen Date: Thu, 21 Apr 2016 09:50:59 -0400 Subject: [PATCH] Increase scope of stopable states Our CI testing has done some hair pin turns on the VMs from create to destroy. This uncovered an issue where VMs would be in the 'Shutting Down' state. The nova-powervm power off operation would not wait for the shutting down command to finish. This change set fixes that issue. Change-Id: I8a84cf6a9c495ec710aa21ee297b15a08d6f8a21 Closes-Bug: bug/1573042 --- nova_powervm/tests/virt/powervm/test_vm.py | 8 +++++--- nova_powervm/virt/powervm/vm.py | 14 +++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/nova_powervm/tests/virt/powervm/test_vm.py b/nova_powervm/tests/virt/powervm/test_vm.py index c4bff348..166312e2 100644 --- a/nova_powervm/tests/virt/powervm/test_vm.py +++ b/nova_powervm/tests/virt/powervm/test_vm.py @@ -496,9 +496,11 @@ class TestVM(test.TestCase): mock.Mock(state=pvm_bp.LPARState.NOT_ACTIVATED))) self.assertFalse(mock_power_off.called) - stop_states = [pvm_bp.LPARState.RUNNING, pvm_bp.LPARState.STARTING, - pvm_bp.LPARState.OPEN_FIRMWARE, pvm_bp.LPARState.ERROR, - pvm_bp.LPARState.RESUMING] + stop_states = [ + pvm_bp.LPARState.RUNNING, pvm_bp.LPARState.STARTING, + pvm_bp.LPARState.OPEN_FIRMWARE, pvm_bp.LPARState.SHUTTING_DOWN, + pvm_bp.LPARState.ERROR, pvm_bp.LPARState.RESUMING, + pvm_bp.LPARState.SUSPENDING] for stop_state in stop_states: entry = mock.Mock(state=stop_state) mock_power_off.reset_mock() diff --git a/nova_powervm/virt/powervm/vm.py b/nova_powervm/virt/powervm/vm.py index 7cd023ac..9f408140 100644 --- a/nova_powervm/virt/powervm/vm.py +++ b/nova_powervm/virt/powervm/vm.py @@ -94,10 +94,12 @@ RESUMING_EVENTS = [ pvm_bp.LPARState.RESUMING, ] -POWERVM_STARTABLE_STATE = (pvm_bp.LPARState.NOT_ACTIVATED) -POWERVM_STOPABLE_STATE = (pvm_bp.LPARState.RUNNING, pvm_bp.LPARState.STARTING, - pvm_bp.LPARState.OPEN_FIRMWARE, - pvm_bp.LPARState.ERROR, pvm_bp.LPARState.RESUMING) +POWERVM_STARTABLE_STATE = (pvm_bp.LPARState.NOT_ACTIVATED, ) +POWERVM_STOPABLE_STATE = ( + pvm_bp.LPARState.RUNNING, pvm_bp.LPARState.STARTING, + pvm_bp.LPARState.OPEN_FIRMWARE, pvm_bp.LPARState.SHUTTING_DOWN, + pvm_bp.LPARState.ERROR, pvm_bp.LPARState.RESUMING, + pvm_bp.LPARState.SUSPENDING) def translate_event(pvm_state, pwr_state): @@ -650,7 +652,9 @@ def power_off(adapter, instance, host_uuid, entry=None, add_parms=None, # Get the current state and see if we can stop the VM LOG.debug("Powering off request for instance %(inst)s which is in " - "state %(state)s", {'inst': instance.name, 'state': entry.state}) + "state %(state)s. Force Immediate Flag: %(force)s.", + {'inst': instance.name, 'state': entry.state, + 'force': force_immediate}) if entry.state in POWERVM_STOPABLE_STATE: # Now stop the lpar try: