Merge "VMWare: Move constant power state strings to the constant.py"
This commit is contained in:
commit
e6e33dd6f7
@ -1438,7 +1438,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(driver.VMwareVCDriver, 'reboot')
|
||||
@mock.patch.object(vm_util, 'get_vm_state',
|
||||
return_value='poweredOff')
|
||||
return_value=power_state.SHUTDOWN)
|
||||
def test_resume_state_on_host_boot(self, mock_get_vm_state,
|
||||
mock_reboot):
|
||||
self._create_instance()
|
||||
@ -1451,7 +1451,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||
|
||||
def test_resume_state_on_host_boot_no_reboot(self):
|
||||
self._create_instance()
|
||||
for state in ['poweredOn', 'suspended']:
|
||||
for state in [power_state.RUNNING, power_state.SUSPENDED]:
|
||||
with test.nested(
|
||||
mock.patch.object(driver.VMwareVCDriver, 'reboot'),
|
||||
mock.patch.object(vm_util, 'get_vm_state',
|
||||
|
@ -16,6 +16,7 @@
|
||||
Shared constants across the VMware driver
|
||||
"""
|
||||
|
||||
from nova.compute import power_state
|
||||
from nova.network import model as network_model
|
||||
|
||||
MIN_VC_VERSION = '5.1.0'
|
||||
@ -225,3 +226,7 @@ VALID_OS_TYPES = set([
|
||||
'winXPPro64Guest',
|
||||
'winXPProGuest',
|
||||
])
|
||||
|
||||
POWER_STATES = {'poweredOff': power_state.SHUTDOWN,
|
||||
'poweredOn': power_state.RUNNING,
|
||||
'suspended': power_state.SUSPENDED}
|
||||
|
@ -30,6 +30,7 @@ from oslo_vmware import pbm
|
||||
from oslo_vmware import vim
|
||||
from oslo_vmware import vim_util
|
||||
|
||||
from nova.compute import power_state
|
||||
from nova.compute import task_states
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
@ -201,8 +202,8 @@ class VMwareVCDriver(driver.ComputeDriver):
|
||||
# Check if the instance is running already and avoid doing
|
||||
# anything if it is.
|
||||
state = vm_util.get_vm_state(self._session, instance)
|
||||
ignored_states = ['poweredon', 'suspended']
|
||||
if state.lower() in ignored_states:
|
||||
ignored_states = [power_state.RUNNING, power_state.SUSPENDED]
|
||||
if state in ignored_states:
|
||||
return
|
||||
# Instance is not up and could be in an unknown state.
|
||||
# Be as absolute as possible about getting it back into
|
||||
|
@ -1153,7 +1153,7 @@ def get_vm_state(session, instance):
|
||||
vm_ref = get_vm_ref(session, instance)
|
||||
vm_state = session._call_method(vutil, "get_object_property",
|
||||
vm_ref, "runtime.powerState")
|
||||
return vm_state
|
||||
return constants.POWER_STATES[vm_state]
|
||||
|
||||
|
||||
def get_stats_from_cluster(session, cluster):
|
||||
|
@ -66,10 +66,6 @@ CONF = nova.conf.CONF
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
VMWARE_POWER_STATES = {'poweredOff': power_state.SHUTDOWN,
|
||||
'poweredOn': power_state.RUNNING,
|
||||
'suspended': power_state.SUSPENDED}
|
||||
|
||||
RESIZE_TOTAL_STEPS = 6
|
||||
|
||||
|
||||
@ -1517,7 +1513,7 @@ class VMwareVMOps(object):
|
||||
max_mem = int(vm_props.get('summary.config.memorySizeMB', 0)) * 1024
|
||||
num_cpu = int(vm_props.get('summary.config.numCpu', 0))
|
||||
return hardware.InstanceInfo(
|
||||
state=VMWARE_POWER_STATES[vm_props['runtime.powerState']],
|
||||
state=constants.POWER_STATES[vm_props['runtime.powerState']],
|
||||
max_mem_kb=max_mem,
|
||||
mem_kb=max_mem,
|
||||
num_cpu=num_cpu)
|
||||
@ -1550,7 +1546,7 @@ class VMwareVMOps(object):
|
||||
data = self._get_diagnostics(instance)
|
||||
state = data.get('powerState')
|
||||
if state:
|
||||
state = power_state.STATE_MAP[VMWARE_POWER_STATES[state]]
|
||||
state = power_state.STATE_MAP[constants.POWER_STATES[state]]
|
||||
uptime = data.get('uptimeSeconds', 0)
|
||||
config_drive = configdrive.required_by(instance)
|
||||
diags = diagnostics.Diagnostics(state=state,
|
||||
|
Loading…
Reference in New Issue
Block a user