Merge "objects: Move 'vm_mode' to 'fields.VMMode'"
This commit is contained in:
commit
2b78a0d7b8
|
@ -1,87 +0,0 @@
|
||||||
# Copyright 2012 Red Hat, Inc.
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
"""Possible vm modes for instances.
|
|
||||||
|
|
||||||
Compute instance vm modes represent the host/guest ABI used for the
|
|
||||||
virtual machine / container. Individual hypervisors may support
|
|
||||||
multiple different vm modes per host. Available vm modes for a hypervisor
|
|
||||||
driver may also vary according to the architecture it is running on.
|
|
||||||
|
|
||||||
The 'vm_mode' parameter can be set against an instance to
|
|
||||||
choose what sort of VM to boot.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from nova import exception
|
|
||||||
|
|
||||||
HVM = "hvm" # Native ABI (aka fully virtualized)
|
|
||||||
XEN = "xen" # Xen 3.0 paravirtualized
|
|
||||||
UML = "uml" # User Mode Linux paravirtualized
|
|
||||||
EXE = "exe" # Executables in containers
|
|
||||||
|
|
||||||
ALL = [HVM, XEN, UML, EXE]
|
|
||||||
|
|
||||||
|
|
||||||
def get_from_instance(instance):
|
|
||||||
"""Get the vm mode for an instance
|
|
||||||
|
|
||||||
:param instance: instance object to query
|
|
||||||
|
|
||||||
:returns: canonicalized vm mode for the instance
|
|
||||||
"""
|
|
||||||
|
|
||||||
mode = instance.vm_mode
|
|
||||||
return canonicalize(mode)
|
|
||||||
|
|
||||||
|
|
||||||
def is_valid(name):
|
|
||||||
"""Check if a string is a valid vm mode
|
|
||||||
|
|
||||||
:param name: vm mode name to validate
|
|
||||||
|
|
||||||
:returns: True if @name is valid
|
|
||||||
"""
|
|
||||||
|
|
||||||
return name in ALL
|
|
||||||
|
|
||||||
|
|
||||||
def canonicalize(mode):
|
|
||||||
"""Canonicalize the vm mode
|
|
||||||
|
|
||||||
:param name: vm mode name to canonicalize
|
|
||||||
|
|
||||||
:returns: a canonical vm mode name
|
|
||||||
"""
|
|
||||||
|
|
||||||
if mode is None:
|
|
||||||
return None
|
|
||||||
|
|
||||||
mode = mode.lower()
|
|
||||||
|
|
||||||
# For compatibility with pre-Folsom deployments
|
|
||||||
if mode == "pv":
|
|
||||||
mode = XEN
|
|
||||||
|
|
||||||
if mode == "hv":
|
|
||||||
mode = HVM
|
|
||||||
|
|
||||||
if mode == "baremetal":
|
|
||||||
mode = HVM
|
|
||||||
|
|
||||||
if not is_valid(mode):
|
|
||||||
raise exception.InvalidVirtualMachineMode(vmmode=mode)
|
|
||||||
|
|
||||||
return mode
|
|
|
@ -18,8 +18,6 @@ import re
|
||||||
from oslo_versionedobjects import fields
|
from oslo_versionedobjects import fields
|
||||||
import six
|
import six
|
||||||
|
|
||||||
# TODO(berrange) Temporary import for VMMode class
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.i18n import _
|
from nova.i18n import _
|
||||||
from nova.network import model as network_model
|
from nova.network import model as network_model
|
||||||
|
@ -541,18 +539,80 @@ class VIFModel(BaseNovaEnum):
|
||||||
|
|
||||||
|
|
||||||
class VMMode(BaseNovaEnum):
|
class VMMode(BaseNovaEnum):
|
||||||
# TODO(berrange): move all constants out of 'nova.compute.vm_mode'
|
"""Represents possible vm modes for instances.
|
||||||
# into fields on this class
|
|
||||||
ALL = vm_mode.ALL
|
Compute instance VM modes represent the host/guest ABI used for the
|
||||||
|
virtual machine or container. Individual hypervisors may support
|
||||||
|
multiple different vm modes per host. Available VM modes for a
|
||||||
|
hypervisor driver may also vary according to the architecture it is
|
||||||
|
running on.
|
||||||
|
"""
|
||||||
|
HVM = 'hvm' # Native ABI (aka fully virtualized)
|
||||||
|
XEN = 'xen' # Xen 3.0 paravirtualized
|
||||||
|
UML = 'uml' # User Mode Linux paravirtualized
|
||||||
|
EXE = 'exe' # Executables in containers
|
||||||
|
|
||||||
|
ALL = (HVM, XEN, UML, EXE)
|
||||||
|
|
||||||
def coerce(self, obj, attr, value):
|
def coerce(self, obj, attr, value):
|
||||||
try:
|
try:
|
||||||
value = vm_mode.canonicalize(value)
|
value = self.canonicalize(value)
|
||||||
except exception.InvalidVirtualMachineMode:
|
except exception.InvalidVirtualMachineMode:
|
||||||
msg = _("Virtual machine mode '%s' is not valid") % value
|
msg = _("Virtual machine mode '%s' is not valid") % value
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
return super(VMMode, self).coerce(obj, attr, value)
|
return super(VMMode, self).coerce(obj, attr, value)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_from_instance(cls, instance):
|
||||||
|
"""Get the vm mode for an instance
|
||||||
|
|
||||||
|
:param instance: instance object to query
|
||||||
|
|
||||||
|
:returns: canonicalized vm mode for the instance
|
||||||
|
"""
|
||||||
|
mode = instance.vm_mode
|
||||||
|
|
||||||
|
return cls.canonicalize(mode)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_valid(cls, name):
|
||||||
|
"""Check if a string is a valid vm mode
|
||||||
|
|
||||||
|
:param name: vm mode name to validate
|
||||||
|
|
||||||
|
:returns: True if @name is valid
|
||||||
|
"""
|
||||||
|
return name in cls.ALL
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def canonicalize(cls, mode):
|
||||||
|
"""Canonicalize the vm mode
|
||||||
|
|
||||||
|
:param name: vm mode name to canonicalize
|
||||||
|
|
||||||
|
:returns: a canonical vm mode name
|
||||||
|
"""
|
||||||
|
if mode is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
mode = mode.lower()
|
||||||
|
|
||||||
|
# For compatibility with pre-Folsom deployments
|
||||||
|
if mode == 'pv':
|
||||||
|
mode = cls.XEN
|
||||||
|
|
||||||
|
if mode == 'hv':
|
||||||
|
mode = cls.HVM
|
||||||
|
|
||||||
|
if mode == 'baremetal':
|
||||||
|
mode = cls.HVM
|
||||||
|
|
||||||
|
if not cls.is_valid(mode):
|
||||||
|
raise exception.InvalidVirtualMachineMode(vmmode=mode)
|
||||||
|
|
||||||
|
return mode
|
||||||
|
|
||||||
|
|
||||||
class WatchdogAction(BaseNovaEnum):
|
class WatchdogAction(BaseNovaEnum):
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ from distutils import versionpredicate
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova.objects import fields
|
from nova.objects import fields
|
||||||
from nova.scheduler import filters
|
from nova.scheduler import filters
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ class ImagePropertiesFilter(filters.BaseHostFilter):
|
||||||
checked_img_props = (
|
checked_img_props = (
|
||||||
fields.Architecture.canonicalize(img_arch),
|
fields.Architecture.canonicalize(img_arch),
|
||||||
fields.HVType.canonicalize(img_h_type),
|
fields.HVType.canonicalize(img_h_type),
|
||||||
vm_mode.canonicalize(img_vm_mode)
|
fields.VMMode.canonicalize(img_vm_mode)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Supported if no compute-related instance properties are specified
|
# Supported if no compute-related instance properties are specified
|
||||||
|
|
|
@ -31,7 +31,6 @@ from nova.compute import instance_actions
|
||||||
from nova.compute import rpcapi as compute_rpcapi
|
from nova.compute import rpcapi as compute_rpcapi
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import utils as compute_utils
|
from nova.compute import utils as compute_utils
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
from nova import conductor
|
from nova import conductor
|
||||||
from nova import context
|
from nova import context
|
||||||
|
@ -3079,7 +3078,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
system_metadata=orig_system_metadata,
|
system_metadata=orig_system_metadata,
|
||||||
expected_attrs=['system_metadata'],
|
expected_attrs=['system_metadata'],
|
||||||
image_ref=orig_image_href,
|
image_ref=orig_image_href,
|
||||||
vm_mode=vm_mode.HVM)
|
vm_mode=fields_obj.VMMode.HVM)
|
||||||
flavor = instance.get_flavor()
|
flavor = instance.get_flavor()
|
||||||
|
|
||||||
def get_image(context, image_href):
|
def get_image(context, image_href):
|
||||||
|
@ -3109,7 +3108,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
_check_auto_disk_config.assert_called_once_with(image=new_image)
|
_check_auto_disk_config.assert_called_once_with(image=new_image)
|
||||||
_checks_for_create_and_rebuild.assert_called_once_with(self.context,
|
_checks_for_create_and_rebuild.assert_called_once_with(self.context,
|
||||||
None, new_image, flavor, {}, [], None)
|
None, new_image, flavor, {}, [], None)
|
||||||
self.assertEqual(vm_mode.XEN, instance.vm_mode)
|
self.assertEqual(fields_obj.VMMode.XEN, instance.vm_mode)
|
||||||
|
|
||||||
def _test_check_injected_file_quota_onset_file_limit_exceeded(self,
|
def _test_check_injected_file_quota_onset_file_limit_exceeded(self,
|
||||||
side_effect):
|
side_effect):
|
||||||
|
|
|
@ -23,7 +23,6 @@ from nova.compute.monitors import base as monitor_base
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import resource_tracker
|
from nova.compute import resource_tracker
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import exception as exc
|
from nova import exception as exc
|
||||||
|
@ -80,7 +79,7 @@ _COMPUTE_NODE_FIXTURES = [
|
||||||
objects.HVSpec.from_list([
|
objects.HVSpec.from_list([
|
||||||
obj_fields.Architecture.I686,
|
obj_fields.Architecture.I686,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM])
|
obj_fields.VMMode.HVM])
|
||||||
],
|
],
|
||||||
metrics=None,
|
metrics=None,
|
||||||
pci_device_pools=None,
|
pci_device_pools=None,
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
# Copyright (C) 2012 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova import exception
|
|
||||||
from nova import test
|
|
||||||
from nova.tests.unit import fake_instance
|
|
||||||
|
|
||||||
|
|
||||||
class ComputeVMModeTest(test.NoDBTestCase):
|
|
||||||
|
|
||||||
def _fake_object(self, updates):
|
|
||||||
return fake_instance.fake_instance_obj(None, **updates)
|
|
||||||
|
|
||||||
def test_case(self):
|
|
||||||
inst = self._fake_object(dict(vm_mode="HVM"))
|
|
||||||
mode = vm_mode.get_from_instance(inst)
|
|
||||||
self.assertEqual(mode, "hvm")
|
|
||||||
|
|
||||||
def test_legacy_pv(self):
|
|
||||||
inst = self._fake_object(dict(vm_mode="pv"))
|
|
||||||
mode = vm_mode.get_from_instance(inst)
|
|
||||||
self.assertEqual(mode, "xen")
|
|
||||||
|
|
||||||
def test_legacy_hv(self):
|
|
||||||
inst = self._fake_object(dict(vm_mode="hv"))
|
|
||||||
mode = vm_mode.get_from_instance(inst)
|
|
||||||
self.assertEqual(mode, "hvm")
|
|
||||||
|
|
||||||
def test_bogus(self):
|
|
||||||
inst = self._fake_object(dict(vm_mode="wibble"))
|
|
||||||
self.assertRaises(exception.Invalid,
|
|
||||||
vm_mode.get_from_instance,
|
|
||||||
inst)
|
|
||||||
|
|
||||||
def test_good(self):
|
|
||||||
inst = self._fake_object(dict(vm_mode="hvm"))
|
|
||||||
mode = vm_mode.get_from_instance(inst)
|
|
||||||
self.assertEqual(mode, "hvm")
|
|
||||||
|
|
||||||
def test_name_pv_compat(self):
|
|
||||||
mode = vm_mode.canonicalize('pv')
|
|
||||||
self.assertEqual(vm_mode.XEN, mode)
|
|
||||||
|
|
||||||
def test_name_hv_compat(self):
|
|
||||||
mode = vm_mode.canonicalize('hv')
|
|
||||||
self.assertEqual(vm_mode.HVM, mode)
|
|
||||||
|
|
||||||
def test_name_baremetal_compat(self):
|
|
||||||
mode = vm_mode.canonicalize('baremetal')
|
|
||||||
self.assertEqual(vm_mode.HVM, mode)
|
|
||||||
|
|
||||||
def test_name_hvm(self):
|
|
||||||
mode = vm_mode.canonicalize('hvm')
|
|
||||||
self.assertEqual(vm_mode.HVM, mode)
|
|
||||||
|
|
||||||
def test_name_none(self):
|
|
||||||
mode = vm_mode.canonicalize(None)
|
|
||||||
self.assertIsNone(mode)
|
|
||||||
|
|
||||||
def test_name_invalid(self):
|
|
||||||
self.assertRaises(exception.InvalidVirtualMachineMode,
|
|
||||||
vm_mode.canonicalize, 'invalid')
|
|
|
@ -25,6 +25,7 @@ from nova.network import model as network_model
|
||||||
from nova.objects import fields
|
from nova.objects import fields
|
||||||
from nova import signature_utils
|
from nova import signature_utils
|
||||||
from nova import test
|
from nova import test
|
||||||
|
from nova.tests.unit import fake_instance
|
||||||
from nova import utils
|
from nova import utils
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,6 +268,62 @@ class TestHVType(TestField):
|
||||||
'wibble')
|
'wibble')
|
||||||
|
|
||||||
|
|
||||||
|
class TestVMMode(TestField):
|
||||||
|
def _fake_object(self, updates):
|
||||||
|
return fake_instance.fake_instance_obj(None, **updates)
|
||||||
|
|
||||||
|
def test_case(self):
|
||||||
|
inst = self._fake_object(dict(vm_mode='HVM'))
|
||||||
|
mode = fields.VMMode.get_from_instance(inst)
|
||||||
|
self.assertEqual(mode, 'hvm')
|
||||||
|
|
||||||
|
def test_legacy_pv(self):
|
||||||
|
inst = self._fake_object(dict(vm_mode='pv'))
|
||||||
|
mode = fields.VMMode.get_from_instance(inst)
|
||||||
|
self.assertEqual(mode, 'xen')
|
||||||
|
|
||||||
|
def test_legacy_hv(self):
|
||||||
|
inst = self._fake_object(dict(vm_mode='hv'))
|
||||||
|
mode = fields.VMMode.get_from_instance(inst)
|
||||||
|
self.assertEqual(mode, 'hvm')
|
||||||
|
|
||||||
|
def test_bogus(self):
|
||||||
|
inst = self._fake_object(dict(vm_mode='wibble'))
|
||||||
|
self.assertRaises(exception.Invalid,
|
||||||
|
fields.VMMode.get_from_instance,
|
||||||
|
inst)
|
||||||
|
|
||||||
|
def test_good(self):
|
||||||
|
inst = self._fake_object(dict(vm_mode='hvm'))
|
||||||
|
mode = fields.VMMode.get_from_instance(inst)
|
||||||
|
self.assertEqual(mode, 'hvm')
|
||||||
|
|
||||||
|
def test_canonicalize_pv_compat(self):
|
||||||
|
mode = fields.VMMode.canonicalize('pv')
|
||||||
|
self.assertEqual(fields.VMMode.XEN, mode)
|
||||||
|
|
||||||
|
def test_canonicalize_hv_compat(self):
|
||||||
|
mode = fields.VMMode.canonicalize('hv')
|
||||||
|
self.assertEqual(fields.VMMode.HVM, mode)
|
||||||
|
|
||||||
|
def test_canonicalize_baremetal_compat(self):
|
||||||
|
mode = fields.VMMode.canonicalize('baremetal')
|
||||||
|
self.assertEqual(fields.VMMode.HVM, mode)
|
||||||
|
|
||||||
|
def test_canonicalize_hvm(self):
|
||||||
|
mode = fields.VMMode.canonicalize('hvm')
|
||||||
|
self.assertEqual(fields.VMMode.HVM, mode)
|
||||||
|
|
||||||
|
def test_canonicalize_none(self):
|
||||||
|
mode = fields.VMMode.canonicalize(None)
|
||||||
|
self.assertIsNone(mode)
|
||||||
|
|
||||||
|
def test_canonicalize_invalid(self):
|
||||||
|
self.assertRaises(exception.InvalidVirtualMachineMode,
|
||||||
|
fields.VMMode.canonicalize,
|
||||||
|
'invalid')
|
||||||
|
|
||||||
|
|
||||||
class TestImageSignatureTypes(TestField):
|
class TestImageSignatureTypes(TestField):
|
||||||
# Ensure that the object definition is updated
|
# Ensure that the object definition is updated
|
||||||
# in step with the signature_utils module
|
# in step with the signature_utils module
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova.objects import fields as obj_fields
|
from nova.objects import fields as obj_fields
|
||||||
from nova.tests.unit.objects import test_objects
|
from nova.tests.unit.objects import test_objects
|
||||||
|
@ -22,25 +21,25 @@ from nova.tests.unit.objects import test_objects
|
||||||
spec_dict = {
|
spec_dict = {
|
||||||
'arch': obj_fields.Architecture.I686,
|
'arch': obj_fields.Architecture.I686,
|
||||||
'hv_type': obj_fields.HVType.KVM,
|
'hv_type': obj_fields.HVType.KVM,
|
||||||
'vm_mode': vm_mode.HVM
|
'vm_mode': obj_fields.VMMode.HVM
|
||||||
}
|
}
|
||||||
|
|
||||||
spec_list = [
|
spec_list = [
|
||||||
obj_fields.Architecture.I686,
|
obj_fields.Architecture.I686,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM
|
obj_fields.VMMode.HVM
|
||||||
]
|
]
|
||||||
|
|
||||||
spec_dict_vz = {
|
spec_dict_vz = {
|
||||||
'arch': obj_fields.Architecture.I686,
|
'arch': obj_fields.Architecture.I686,
|
||||||
'hv_type': obj_fields.HVType.VIRTUOZZO,
|
'hv_type': obj_fields.HVType.VIRTUOZZO,
|
||||||
'vm_mode': vm_mode.HVM
|
'vm_mode': obj_fields.VMMode.HVM
|
||||||
}
|
}
|
||||||
|
|
||||||
spec_dict_parallels = {
|
spec_dict_parallels = {
|
||||||
'arch': obj_fields.Architecture.I686,
|
'arch': obj_fields.Architecture.I686,
|
||||||
'hv_type': obj_fields.HVType.PARALLELS,
|
'hv_type': obj_fields.HVType.PARALLELS,
|
||||||
'vm_mode': vm_mode.HVM
|
'vm_mode': obj_fields.VMMode.HVM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ class _TestHVSpecObject(object):
|
||||||
spec_obj = objects.HVSpec()
|
spec_obj = objects.HVSpec()
|
||||||
spec_obj.arch = obj_fields.Architecture.I686
|
spec_obj.arch = obj_fields.Architecture.I686
|
||||||
spec_obj.hv_type = obj_fields.HVType.KVM
|
spec_obj.hv_type = obj_fields.HVType.KVM
|
||||||
spec_obj.vm_mode = vm_mode.HVM
|
spec_obj.vm_mode = obj_fields.VMMode.HVM
|
||||||
spec = spec_obj.to_list()
|
spec = spec_obj.to_list()
|
||||||
self.assertEqual(spec_list, spec)
|
self.assertEqual(spec_list, spec)
|
||||||
|
|
||||||
|
|
|
@ -1129,10 +1129,10 @@ object_data = {
|
||||||
'FloatingIPList': '1.11-7f2ba670714e1b7bab462ab3290f7159',
|
'FloatingIPList': '1.11-7f2ba670714e1b7bab462ab3290f7159',
|
||||||
'HostMapping': '1.0-1a3390a696792a552ab7bd31a77ba9ac',
|
'HostMapping': '1.0-1a3390a696792a552ab7bd31a77ba9ac',
|
||||||
'HyperVLiveMigrateData': '1.1-9987a3cec31a81abac6fba7cc722e43f',
|
'HyperVLiveMigrateData': '1.1-9987a3cec31a81abac6fba7cc722e43f',
|
||||||
'HVSpec': '1.2-e1ef66eb58ac1be510300c5d9f8ad931',
|
'HVSpec': '1.2-e6cf4455367f301baa926e3972978d55',
|
||||||
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
|
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
|
||||||
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
|
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
|
||||||
'ImageMetaProps': '1.15-28e104f642cbf04c7899d349e7e4d05d',
|
'ImageMetaProps': '1.15-070af88560aebda534a5d57e0d26e795',
|
||||||
'Instance': '2.3-4f98ab23f4b0a25fabb1040c8f5edecc',
|
'Instance': '2.3-4f98ab23f4b0a25fabb1040c8f5edecc',
|
||||||
'InstanceAction': '1.1-f9f293e526b66fca0d05c3b3a2d13914',
|
'InstanceAction': '1.1-f9f293e526b66fca0d05c3b3a2d13914',
|
||||||
'InstanceActionEvent': '1.1-e56a64fa4710e43ef7af2ad9d6028b33',
|
'InstanceActionEvent': '1.1-e56a64fa4710e43ef7af2ad9d6028b33',
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova.objects import fields as obj_fields
|
from nova.objects import fields as obj_fields
|
||||||
from nova.scheduler.filters import image_props_filter
|
from nova.scheduler.filters import image_props_filter
|
||||||
|
@ -31,7 +30,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.X86_64,
|
hw_architecture=obj_fields.Architecture.X86_64,
|
||||||
img_hv_type=obj_fields.HVType.KVM,
|
img_hv_type=obj_fields.HVType.KVM,
|
||||||
hw_vm_mode=vm_mode.HVM,
|
hw_vm_mode=obj_fields.VMMode.HVM,
|
||||||
img_hv_requested_version='>=6.0,<6.2'))
|
img_hv_requested_version='>=6.0,<6.2'))
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
||||||
|
@ -39,7 +38,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -49,14 +48,14 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.ARMV7,
|
hw_architecture=obj_fields.Architecture.ARMV7,
|
||||||
img_hv_type=obj_fields.HVType.QEMU,
|
img_hv_type=obj_fields.HVType.QEMU,
|
||||||
hw_vm_mode=vm_mode.HVM))
|
hw_vm_mode=obj_fields.VMMode.HVM))
|
||||||
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
capabilities = {
|
capabilities = {
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -66,7 +65,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.X86_64,
|
hw_architecture=obj_fields.Architecture.X86_64,
|
||||||
img_hv_type=obj_fields.HVType.KVM,
|
img_hv_type=obj_fields.HVType.KVM,
|
||||||
hw_vm_mode=vm_mode.HVM,
|
hw_vm_mode=obj_fields.VMMode.HVM,
|
||||||
img_hv_requested_version='>=6.2'))
|
img_hv_requested_version='>=6.2'))
|
||||||
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
|
@ -75,7 +74,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -84,14 +83,14 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
img_props = objects.ImageMeta(
|
img_props = objects.ImageMeta(
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.X86_64,
|
hw_architecture=obj_fields.Architecture.X86_64,
|
||||||
hw_vm_mode=vm_mode.HVM))
|
hw_vm_mode=obj_fields.VMMode.HVM))
|
||||||
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
capabilities = {
|
capabilities = {
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -100,14 +99,14 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
img_props = objects.ImageMeta(
|
img_props = objects.ImageMeta(
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.X86_64,
|
hw_architecture=obj_fields.Architecture.X86_64,
|
||||||
hw_vm_mode=vm_mode.HVM))
|
hw_vm_mode=obj_fields.VMMode.HVM))
|
||||||
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
capabilities = {
|
capabilities = {
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.XEN,
|
obj_fields.HVType.XEN,
|
||||||
vm_mode.XEN)],
|
obj_fields.VMMode.XEN)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -119,7 +118,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -129,7 +128,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.X86_64,
|
hw_architecture=obj_fields.Architecture.X86_64,
|
||||||
img_hv_type=obj_fields.HVType.KVM,
|
img_hv_type=obj_fields.HVType.KVM,
|
||||||
hw_vm_mode=vm_mode.HVM))
|
hw_vm_mode=obj_fields.VMMode.HVM))
|
||||||
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
hypervisor_version = versionutils.convert_version_to_int('6.0.0')
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
capabilities = {
|
capabilities = {
|
||||||
|
@ -143,7 +142,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.X86_64,
|
hw_architecture=obj_fields.Architecture.X86_64,
|
||||||
img_hv_type=obj_fields.HVType.KVM,
|
img_hv_type=obj_fields.HVType.KVM,
|
||||||
hw_vm_mode=vm_mode.HVM,
|
hw_vm_mode=obj_fields.VMMode.HVM,
|
||||||
img_hv_requested_version='>=6.0'))
|
img_hv_requested_version='>=6.0'))
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
capabilities = {
|
capabilities = {
|
||||||
|
@ -151,7 +150,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)]}
|
obj_fields.VMMode.HVM)]}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
|
||||||
|
@ -160,7 +159,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
properties=objects.ImageMetaProps(
|
properties=objects.ImageMetaProps(
|
||||||
hw_architecture=obj_fields.Architecture.X86_64,
|
hw_architecture=obj_fields.Architecture.X86_64,
|
||||||
img_hv_type=obj_fields.HVType.KVM,
|
img_hv_type=obj_fields.HVType.KVM,
|
||||||
hw_vm_mode=vm_mode.HVM,
|
hw_vm_mode=obj_fields.VMMode.HVM,
|
||||||
img_hv_requested_version='>=6.0'))
|
img_hv_requested_version='>=6.0'))
|
||||||
spec_obj = objects.RequestSpec(image=img_props)
|
spec_obj = objects.RequestSpec(image=img_props)
|
||||||
capabilities = {
|
capabilities = {
|
||||||
|
@ -168,7 +167,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': 5000}
|
'hypervisor_version': 5000}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -184,7 +183,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.XEN,
|
obj_fields.HVType.XEN,
|
||||||
vm_mode.XEN)],
|
obj_fields.VMMode.XEN)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -200,7 +199,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -216,7 +215,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.I686,
|
obj_fields.Architecture.I686,
|
||||||
obj_fields.HVType.KVM,
|
obj_fields.HVType.KVM,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -232,7 +231,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.I686,
|
obj_fields.Architecture.I686,
|
||||||
obj_fields.HVType.XEN,
|
obj_fields.HVType.XEN,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
@ -249,7 +248,7 @@ class TestImagePropsFilter(test.NoDBTestCase):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.I686,
|
obj_fields.Architecture.I686,
|
||||||
obj_fields.HVType.BAREMETAL,
|
obj_fields.HVType.BAREMETAL,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'hypervisor_version': hypervisor_version}
|
'hypervisor_version': hypervisor_version}
|
||||||
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
host = fakes.FakeHostState('host1', 'node1', capabilities)
|
||||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||||
|
|
|
@ -60,7 +60,6 @@ from nova.api.metadata import base as instance_metadata
|
||||||
from nova.compute import manager
|
from nova.compute import manager
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova import context
|
from nova import context
|
||||||
|
@ -1862,7 +1861,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
vconfig.LibvirtConfigGuestFeatureAPIC)
|
vconfig.LibvirtConfigGuestFeatureAPIC)
|
||||||
self.assertEqual(cfg.memory, 6 * units.Ki)
|
self.assertEqual(cfg.memory, 6 * units.Ki)
|
||||||
self.assertEqual(cfg.vcpus, 28)
|
self.assertEqual(cfg.vcpus, 28)
|
||||||
self.assertEqual(cfg.os_type, vm_mode.HVM)
|
self.assertEqual(cfg.os_type, fields.VMMode.HVM)
|
||||||
self.assertEqual(cfg.os_boot_dev, ["hd"])
|
self.assertEqual(cfg.os_boot_dev, ["hd"])
|
||||||
self.assertIsNone(cfg.os_root)
|
self.assertIsNone(cfg.os_root)
|
||||||
self.assertEqual(len(cfg.devices), 10)
|
self.assertEqual(len(cfg.devices), 10)
|
||||||
|
@ -1937,7 +1936,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
||||||
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
||||||
self.assertEqual(instance_ref.flavor.vcpus, cfg.vcpus)
|
self.assertEqual(instance_ref.flavor.vcpus, cfg.vcpus)
|
||||||
self.assertEqual(vm_mode.EXE, cfg.os_type)
|
self.assertEqual(fields.VMMode.EXE, cfg.os_type)
|
||||||
self.assertEqual("/sbin/init", cfg.os_init_path)
|
self.assertEqual("/sbin/init", cfg.os_init_path)
|
||||||
self.assertEqual("console=tty0 console=ttyS0", cfg.os_cmdline)
|
self.assertEqual("console=tty0 console=ttyS0", cfg.os_cmdline)
|
||||||
self.assertIsNone(cfg.os_root)
|
self.assertIsNone(cfg.os_root)
|
||||||
|
@ -1962,7 +1961,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
||||||
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
||||||
self.assertEqual(instance_ref.vcpus, cfg.vcpus)
|
self.assertEqual(instance_ref.vcpus, cfg.vcpus)
|
||||||
self.assertEqual(vm_mode.EXE, cfg.os_type)
|
self.assertEqual(fields.VMMode.EXE, cfg.os_type)
|
||||||
self.assertEqual("/sbin/init", cfg.os_init_path)
|
self.assertEqual("/sbin/init", cfg.os_init_path)
|
||||||
self.assertEqual("console=tty0 console=ttyS0", cfg.os_cmdline)
|
self.assertEqual("console=tty0 console=ttyS0", cfg.os_cmdline)
|
||||||
self.assertIsNone(cfg.os_root)
|
self.assertIsNone(cfg.os_root)
|
||||||
|
@ -3159,7 +3158,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
vconfig.LibvirtConfigGuestFeatureAPIC)
|
vconfig.LibvirtConfigGuestFeatureAPIC)
|
||||||
self.assertEqual(cfg.memory, instance_ref.flavor.memory_mb * units.Ki)
|
self.assertEqual(cfg.memory, instance_ref.flavor.memory_mb * units.Ki)
|
||||||
self.assertEqual(cfg.vcpus, instance_ref.flavor.vcpus)
|
self.assertEqual(cfg.vcpus, instance_ref.flavor.vcpus)
|
||||||
self.assertEqual(cfg.os_type, vm_mode.HVM)
|
self.assertEqual(cfg.os_type, fields.VMMode.HVM)
|
||||||
self.assertEqual(cfg.os_boot_dev, ["hd"])
|
self.assertEqual(cfg.os_boot_dev, ["hd"])
|
||||||
self.assertIsNone(cfg.os_root)
|
self.assertIsNone(cfg.os_root)
|
||||||
self.assertEqual(len(cfg.devices), 10)
|
self.assertEqual(len(cfg.devices), 10)
|
||||||
|
@ -4085,7 +4084,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
|
|
||||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||||
instance_ref = objects.Instance(**self.test_instance)
|
instance_ref = objects.Instance(**self.test_instance)
|
||||||
instance_ref['vm_mode'] = vm_mode.HVM
|
instance_ref['vm_mode'] = fields.VMMode.HVM
|
||||||
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
||||||
|
|
||||||
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
|
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
|
||||||
|
@ -4095,7 +4094,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
cfg = drvr._get_guest_config(instance_ref, [],
|
cfg = drvr._get_guest_config(instance_ref, [],
|
||||||
image_meta, disk_info)
|
image_meta, disk_info)
|
||||||
|
|
||||||
self.assertEqual(cfg.os_type, vm_mode.HVM)
|
self.assertEqual(cfg.os_type, fields.VMMode.HVM)
|
||||||
self.assertEqual(cfg.os_loader, CONF.libvirt.xen_hvmloader_path)
|
self.assertEqual(cfg.os_loader, CONF.libvirt.xen_hvmloader_path)
|
||||||
self.assertEqual(3, len(cfg.features))
|
self.assertEqual(3, len(cfg.features))
|
||||||
self.assertIsInstance(cfg.features[0],
|
self.assertIsInstance(cfg.features[0],
|
||||||
|
@ -4124,7 +4123,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
cfg = drvr._get_guest_config(instance_ref, [],
|
cfg = drvr._get_guest_config(instance_ref, [],
|
||||||
image_meta, disk_info)
|
image_meta, disk_info)
|
||||||
|
|
||||||
self.assertEqual(cfg.os_type, vm_mode.XEN)
|
self.assertEqual(cfg.os_type, fields.VMMode.XEN)
|
||||||
self.assertEqual(1, len(cfg.features))
|
self.assertEqual(1, len(cfg.features))
|
||||||
self.assertIsInstance(cfg.features[0],
|
self.assertIsInstance(cfg.features[0],
|
||||||
vconfig.LibvirtConfigGuestFeaturePAE)
|
vconfig.LibvirtConfigGuestFeaturePAE)
|
||||||
|
@ -4222,29 +4221,35 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
def test_use_ps2_mouse(self):
|
def test_use_ps2_mouse(self):
|
||||||
self.flags(pointer_model='ps2mouse')
|
self.flags(pointer_model='ps2mouse')
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
|
True, True, fields.VMMode.HVM)
|
||||||
self.assertIsNone(tablet)
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
def test_get_guest_usb_tablet_wipe(self):
|
def test_get_guest_usb_tablet_wipe(self):
|
||||||
self.flags(use_usb_tablet=True, group='libvirt')
|
self.flags(use_usb_tablet=True, group='libvirt')
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
|
True, True, fields.VMMode.HVM)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(True, False, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
|
True, False, fields.VMMode.HVM)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(False, True, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
|
False, True, fields.VMMode.HVM)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(False, False, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
self.assertIsNone(tablet)
|
False, False, fields.VMMode.HVM)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(True, True, "foo")
|
|
||||||
self.assertIsNone(tablet)
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
False, True, vm_mode.HVM, True)
|
True, True, "foo")
|
||||||
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
|
False, True, fields.VMMode.HVM, True)
|
||||||
self.assertIsNone(tablet)
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
def test_get_guest_usb_tablet_image_meta(self):
|
def test_get_guest_usb_tablet_image_meta(self):
|
||||||
|
@ -4252,19 +4257,19 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
image_meta = {"properties": {"hw_pointer_model": "usbtablet"}}
|
image_meta = {"properties": {"hw_pointer_model": "usbtablet"}}
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
True, True, vm_mode.HVM, image_meta=image_meta)
|
True, True, fields.VMMode.HVM, image_meta=image_meta)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
True, False, vm_mode.HVM, image_meta=image_meta)
|
True, False, fields.VMMode.HVM, image_meta=image_meta)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
False, True, vm_mode.HVM, image_meta=image_meta)
|
False, True, fields.VMMode.HVM, image_meta=image_meta)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
False, False, vm_mode.HVM, image_meta=image_meta)
|
False, False, fields.VMMode.HVM, image_meta=image_meta)
|
||||||
self.assertIsNone(tablet)
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
|
@ -4272,7 +4277,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertIsNone(tablet)
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
False, True, vm_mode.HVM, True, image_meta=image_meta)
|
False, True, fields.VMMode.HVM, True, image_meta=image_meta)
|
||||||
self.assertIsNone(tablet)
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
def test_get_guest_usb_tablet_image_meta_no_vnc(self):
|
def test_get_guest_usb_tablet_image_meta_no_vnc(self):
|
||||||
|
@ -4283,32 +4288,32 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exception.UnsupportedPointerModelRequested,
|
exception.UnsupportedPointerModelRequested,
|
||||||
self._test_get_guest_usb_tablet,
|
self._test_get_guest_usb_tablet,
|
||||||
False, False, vm_mode.HVM, True, image_meta=image_meta)
|
False, False, fields.VMMode.HVM, True, image_meta=image_meta)
|
||||||
|
|
||||||
def test_get_guest_no_pointer_model_usb_tablet_set(self):
|
def test_get_guest_no_pointer_model_usb_tablet_set(self):
|
||||||
self.flags(use_usb_tablet=True, group='libvirt')
|
self.flags(use_usb_tablet=True, group='libvirt')
|
||||||
self.flags(pointer_model=None)
|
self.flags(pointer_model=None)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(True, True, fields.VMMode.HVM)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
def test_get_guest_no_pointer_model_usb_tablet_not_set(self):
|
def test_get_guest_no_pointer_model_usb_tablet_not_set(self):
|
||||||
self.flags(use_usb_tablet=False, group='libvirt')
|
self.flags(use_usb_tablet=False, group='libvirt')
|
||||||
self.flags(pointer_model=None)
|
self.flags(pointer_model=None)
|
||||||
|
|
||||||
tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(True, True, fields.VMMode.HVM)
|
||||||
self.assertIsNone(tablet)
|
self.assertIsNone(tablet)
|
||||||
|
|
||||||
def test_get_guest_pointer_model_usb_tablet(self):
|
def test_get_guest_pointer_model_usb_tablet(self):
|
||||||
self.flags(use_usb_tablet=False, group='libvirt')
|
self.flags(use_usb_tablet=False, group='libvirt')
|
||||||
self.flags(pointer_model='usbtablet')
|
self.flags(pointer_model='usbtablet')
|
||||||
tablet = self._test_get_guest_usb_tablet(True, True, vm_mode.HVM)
|
tablet = self._test_get_guest_usb_tablet(True, True, fields.VMMode.HVM)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
def test_get_guest_pointer_model_usb_tablet_image(self):
|
def test_get_guest_pointer_model_usb_tablet_image(self):
|
||||||
image_meta = {"properties": {"hw_pointer_model": "usbtablet"}}
|
image_meta = {"properties": {"hw_pointer_model": "usbtablet"}}
|
||||||
tablet = self._test_get_guest_usb_tablet(
|
tablet = self._test_get_guest_usb_tablet(
|
||||||
True, True, vm_mode.HVM, image_meta=image_meta)
|
True, True, fields.VMMode.HVM, image_meta=image_meta)
|
||||||
self.assertIsNotNone(tablet)
|
self.assertIsNotNone(tablet)
|
||||||
|
|
||||||
def test_get_guest_pointer_model_usb_tablet_image_no_HVM(self):
|
def test_get_guest_pointer_model_usb_tablet_image_no_HVM(self):
|
||||||
|
@ -4318,7 +4323,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exception.UnsupportedPointerModelRequested,
|
exception.UnsupportedPointerModelRequested,
|
||||||
self._test_get_guest_usb_tablet,
|
self._test_get_guest_usb_tablet,
|
||||||
True, True, vm_mode.XEN, image_meta=image_meta)
|
True, True, fields.VMMode.XEN, image_meta=image_meta)
|
||||||
|
|
||||||
def test_get_guest_config_with_watchdog_action_flavor(self):
|
def test_get_guest_config_with_watchdog_action_flavor(self):
|
||||||
self.flags(virt_type='kvm', group='libvirt')
|
self.flags(virt_type='kvm', group='libvirt')
|
||||||
|
@ -5774,13 +5779,13 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
|
|
||||||
def test_xml_and_uri_no_ramdisk_no_kernel_xen_hvm(self):
|
def test_xml_and_uri_no_ramdisk_no_kernel_xen_hvm(self):
|
||||||
instance_data = dict(self.test_instance)
|
instance_data = dict(self.test_instance)
|
||||||
instance_data.update({'vm_mode': vm_mode.HVM})
|
instance_data.update({'vm_mode': fields.VMMode.HVM})
|
||||||
self._check_xml_and_uri(instance_data, expect_kernel=False,
|
self._check_xml_and_uri(instance_data, expect_kernel=False,
|
||||||
expect_ramdisk=False, expect_xen_hvm=True)
|
expect_ramdisk=False, expect_xen_hvm=True)
|
||||||
|
|
||||||
def test_xml_and_uri_no_ramdisk_no_kernel_xen_pv(self):
|
def test_xml_and_uri_no_ramdisk_no_kernel_xen_pv(self):
|
||||||
instance_data = dict(self.test_instance)
|
instance_data = dict(self.test_instance)
|
||||||
instance_data.update({'vm_mode': vm_mode.XEN})
|
instance_data.update({'vm_mode': fields.VMMode.XEN})
|
||||||
self._check_xml_and_uri(instance_data, expect_kernel=False,
|
self._check_xml_and_uri(instance_data, expect_kernel=False,
|
||||||
expect_ramdisk=False, expect_xen_hvm=False,
|
expect_ramdisk=False, expect_xen_hvm=False,
|
||||||
xen_only=True)
|
xen_only=True)
|
||||||
|
@ -6549,24 +6554,24 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
instance_ref = objects.Instance(**instance)
|
instance_ref = objects.Instance(**instance)
|
||||||
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
||||||
|
|
||||||
xen_vm_mode = vm_mode.XEN
|
xen_vm_mode = fields.VMMode.XEN
|
||||||
if expect_xen_hvm:
|
if expect_xen_hvm:
|
||||||
xen_vm_mode = vm_mode.HVM
|
xen_vm_mode = fields.VMMode.HVM
|
||||||
|
|
||||||
type_uri_map = {'qemu': ('qemu:///system',
|
type_uri_map = {'qemu': ('qemu:///system',
|
||||||
[(lambda t: t.find('.').get('type'), 'qemu'),
|
[(lambda t: t.find('.').get('type'), 'qemu'),
|
||||||
(lambda t: t.find('./os/type').text,
|
(lambda t: t.find('./os/type').text,
|
||||||
vm_mode.HVM),
|
fields.VMMode.HVM),
|
||||||
(lambda t: t.find('./devices/emulator'), None)]),
|
(lambda t: t.find('./devices/emulator'), None)]),
|
||||||
'kvm': ('qemu:///system',
|
'kvm': ('qemu:///system',
|
||||||
[(lambda t: t.find('.').get('type'), 'kvm'),
|
[(lambda t: t.find('.').get('type'), 'kvm'),
|
||||||
(lambda t: t.find('./os/type').text,
|
(lambda t: t.find('./os/type').text,
|
||||||
vm_mode.HVM),
|
fields.VMMode.HVM),
|
||||||
(lambda t: t.find('./devices/emulator'), None)]),
|
(lambda t: t.find('./devices/emulator'), None)]),
|
||||||
'uml': ('uml:///system',
|
'uml': ('uml:///system',
|
||||||
[(lambda t: t.find('.').get('type'), 'uml'),
|
[(lambda t: t.find('.').get('type'), 'uml'),
|
||||||
(lambda t: t.find('./os/type').text,
|
(lambda t: t.find('./os/type').text,
|
||||||
vm_mode.UML)]),
|
fields.VMMode.UML)]),
|
||||||
'xen': ('xen:///',
|
'xen': ('xen:///',
|
||||||
[(lambda t: t.find('.').get('type'), 'xen'),
|
[(lambda t: t.find('.').get('type'), 'xen'),
|
||||||
(lambda t: t.find('./os/type').text,
|
(lambda t: t.find('./os/type').text,
|
||||||
|
@ -12302,13 +12307,13 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
caps.host.cpu = cpu
|
caps.host.cpu = cpu
|
||||||
|
|
||||||
guest = vconfig.LibvirtConfigGuest()
|
guest = vconfig.LibvirtConfigGuest()
|
||||||
guest.ostype = vm_mode.HVM
|
guest.ostype = fields.VMMode.HVM
|
||||||
guest.arch = fields.Architecture.X86_64
|
guest.arch = fields.Architecture.X86_64
|
||||||
guest.domtype = ["kvm"]
|
guest.domtype = ["kvm"]
|
||||||
caps.guests.append(guest)
|
caps.guests.append(guest)
|
||||||
|
|
||||||
guest = vconfig.LibvirtConfigGuest()
|
guest = vconfig.LibvirtConfigGuest()
|
||||||
guest.ostype = vm_mode.HVM
|
guest.ostype = fields.VMMode.HVM
|
||||||
guest.arch = fields.Architecture.I686
|
guest.arch = fields.Architecture.I686
|
||||||
guest.domtype = ["kvm"]
|
guest.domtype = ["kvm"]
|
||||||
caps.guests.append(guest)
|
caps.guests.append(guest)
|
||||||
|
@ -14818,7 +14823,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
||||||
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
||||||
self.assertEqual(instance_ref.flavor.vcpus, cfg.vcpus)
|
self.assertEqual(instance_ref.flavor.vcpus, cfg.vcpus)
|
||||||
self.assertEqual(vm_mode.HVM, cfg.os_type)
|
self.assertEqual(fields.VMMode.HVM, cfg.os_type)
|
||||||
self.assertIsNone(cfg.os_root)
|
self.assertIsNone(cfg.os_root)
|
||||||
self.assertEqual(6, len(cfg.devices))
|
self.assertEqual(6, len(cfg.devices))
|
||||||
self.assertIsInstance(cfg.devices[0],
|
self.assertIsInstance(cfg.devices[0],
|
||||||
|
@ -14845,7 +14850,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.flags(virt_type='parallels', group='libvirt')
|
self.flags(virt_type='parallels', group='libvirt')
|
||||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
|
||||||
ct_instance = self.test_instance.copy()
|
ct_instance = self.test_instance.copy()
|
||||||
ct_instance["vm_mode"] = vm_mode.EXE
|
ct_instance["vm_mode"] = fields.VMMode.EXE
|
||||||
instance_ref = objects.Instance(**ct_instance)
|
instance_ref = objects.Instance(**ct_instance)
|
||||||
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
|
||||||
|
|
||||||
|
@ -14862,7 +14867,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
self.assertEqual(instance_ref["uuid"], cfg.uuid)
|
||||||
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
self.assertEqual(instance_ref.flavor.memory_mb * units.Ki, cfg.memory)
|
||||||
self.assertEqual(instance_ref.flavor.vcpus, cfg.vcpus)
|
self.assertEqual(instance_ref.flavor.vcpus, cfg.vcpus)
|
||||||
self.assertEqual(vm_mode.EXE, cfg.os_type)
|
self.assertEqual(fields.VMMode.EXE, cfg.os_type)
|
||||||
self.assertEqual("/sbin/init", cfg.os_init_path)
|
self.assertEqual("/sbin/init", cfg.os_init_path)
|
||||||
self.assertIsNone(cfg.os_root)
|
self.assertIsNone(cfg.os_root)
|
||||||
if rescue:
|
if rescue:
|
||||||
|
@ -14947,8 +14952,8 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
self.assertTrue(disk_found)
|
self.assertTrue(disk_found)
|
||||||
|
|
||||||
def test_get_guest_config_parallels_volume(self):
|
def test_get_guest_config_parallels_volume(self):
|
||||||
self._test_get_guest_config_parallels_volume(vm_mode.EXE, 4)
|
self._test_get_guest_config_parallels_volume(fields.VMMode.EXE, 4)
|
||||||
self._test_get_guest_config_parallels_volume(vm_mode.HVM, 6)
|
self._test_get_guest_config_parallels_volume(fields.VMMode.HVM, 6)
|
||||||
|
|
||||||
def test_get_guest_disk_config_rbd_older_config_drive_fall_back(self):
|
def test_get_guest_disk_config_rbd_older_config_drive_fall_back(self):
|
||||||
# New config drives are stored in rbd but existing instances have
|
# New config drives are stored in rbd but existing instances have
|
||||||
|
@ -15040,7 +15045,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||||
|
|
||||||
self.flags(virt_type='parallels', group='libvirt')
|
self.flags(virt_type='parallels', group='libvirt')
|
||||||
instance = objects.Instance(**self.test_instance)
|
instance = objects.Instance(**self.test_instance)
|
||||||
instance.vm_mode = vm_mode.EXE
|
instance.vm_mode = fields.VMMode.EXE
|
||||||
fake_dom = FakeVirtDomain(fake_xml=dummyxml)
|
fake_dom = FakeVirtDomain(fake_xml=dummyxml)
|
||||||
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
|
||||||
mock_get_domain.return_value = fake_dom
|
mock_get_domain.return_value = fake_dom
|
||||||
|
|
|
@ -30,11 +30,11 @@ import six
|
||||||
|
|
||||||
from nova.compute import flavors
|
from nova.compute import flavors
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import vm_mode
|
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova import objects
|
from nova import objects
|
||||||
|
from nova.objects import fields as obj_fields
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.tests.unit import fake_flavor
|
from nova.tests.unit import fake_flavor
|
||||||
from nova.tests.unit import fake_instance
|
from nova.tests.unit import fake_instance
|
||||||
|
@ -1613,37 +1613,37 @@ class DetermineVmModeTestCase(VMUtilsTestBase):
|
||||||
|
|
||||||
def test_determine_vm_mode_returns_xen_mode(self):
|
def test_determine_vm_mode_returns_xen_mode(self):
|
||||||
instance = self._fake_object({"vm_mode": "xen"})
|
instance = self._fake_object({"vm_mode": "xen"})
|
||||||
self.assertEqual(vm_mode.XEN,
|
self.assertEqual(obj_fields.VMMode.XEN,
|
||||||
vm_utils.determine_vm_mode(instance, None))
|
vm_utils.determine_vm_mode(instance, None))
|
||||||
|
|
||||||
def test_determine_vm_mode_returns_hvm_mode(self):
|
def test_determine_vm_mode_returns_hvm_mode(self):
|
||||||
instance = self._fake_object({"vm_mode": "hvm"})
|
instance = self._fake_object({"vm_mode": "hvm"})
|
||||||
self.assertEqual(vm_mode.HVM,
|
self.assertEqual(obj_fields.VMMode.HVM,
|
||||||
vm_utils.determine_vm_mode(instance, None))
|
vm_utils.determine_vm_mode(instance, None))
|
||||||
|
|
||||||
def test_determine_vm_mode_returns_xen_for_linux(self):
|
def test_determine_vm_mode_returns_xen_for_linux(self):
|
||||||
instance = self._fake_object({"vm_mode": None, "os_type": "linux"})
|
instance = self._fake_object({"vm_mode": None, "os_type": "linux"})
|
||||||
self.assertEqual(vm_mode.XEN,
|
self.assertEqual(obj_fields.VMMode.XEN,
|
||||||
vm_utils.determine_vm_mode(instance, None))
|
vm_utils.determine_vm_mode(instance, None))
|
||||||
|
|
||||||
def test_determine_vm_mode_returns_hvm_for_windows(self):
|
def test_determine_vm_mode_returns_hvm_for_windows(self):
|
||||||
instance = self._fake_object({"vm_mode": None, "os_type": "windows"})
|
instance = self._fake_object({"vm_mode": None, "os_type": "windows"})
|
||||||
self.assertEqual(vm_mode.HVM,
|
self.assertEqual(obj_fields.VMMode.HVM,
|
||||||
vm_utils.determine_vm_mode(instance, None))
|
vm_utils.determine_vm_mode(instance, None))
|
||||||
|
|
||||||
def test_determine_vm_mode_returns_hvm_by_default(self):
|
def test_determine_vm_mode_returns_hvm_by_default(self):
|
||||||
instance = self._fake_object({"vm_mode": None, "os_type": None})
|
instance = self._fake_object({"vm_mode": None, "os_type": None})
|
||||||
self.assertEqual(vm_mode.HVM,
|
self.assertEqual(obj_fields.VMMode.HVM,
|
||||||
vm_utils.determine_vm_mode(instance, None))
|
vm_utils.determine_vm_mode(instance, None))
|
||||||
|
|
||||||
def test_determine_vm_mode_returns_xen_for_VHD(self):
|
def test_determine_vm_mode_returns_xen_for_VHD(self):
|
||||||
instance = self._fake_object({"vm_mode": None, "os_type": None})
|
instance = self._fake_object({"vm_mode": None, "os_type": None})
|
||||||
self.assertEqual(vm_mode.XEN,
|
self.assertEqual(obj_fields.VMMode.XEN,
|
||||||
vm_utils.determine_vm_mode(instance, vm_utils.ImageType.DISK_VHD))
|
vm_utils.determine_vm_mode(instance, vm_utils.ImageType.DISK_VHD))
|
||||||
|
|
||||||
def test_determine_vm_mode_returns_xen_for_DISK(self):
|
def test_determine_vm_mode_returns_xen_for_DISK(self):
|
||||||
instance = self._fake_object({"vm_mode": None, "os_type": None})
|
instance = self._fake_object({"vm_mode": None, "os_type": None})
|
||||||
self.assertEqual(vm_mode.XEN,
|
self.assertEqual(obj_fields.VMMode.XEN,
|
||||||
vm_utils.determine_vm_mode(instance, vm_utils.ImageType.DISK))
|
vm_utils.determine_vm_mode(instance, vm_utils.ImageType.DISK))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ from oslo_utils import versionutils
|
||||||
|
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_mode
|
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova.console import type as ctype
|
from nova.console import type as ctype
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
@ -149,7 +148,7 @@ class FakeDriver(driver.ComputeDriver):
|
||||||
'supported_instances': [(
|
'supported_instances': [(
|
||||||
obj_fields.Architecture.X86_64,
|
obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.FAKE,
|
obj_fields.HVType.FAKE,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'numa_topology': None,
|
'numa_topology': None,
|
||||||
}
|
}
|
||||||
self._mounts = {}
|
self._mounts = {}
|
||||||
|
|
|
@ -26,7 +26,6 @@ from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova.i18n import _
|
from nova.i18n import _
|
||||||
from nova.objects import fields as obj_fields
|
from nova.objects import fields as obj_fields
|
||||||
|
@ -159,10 +158,10 @@ class HostOps(object):
|
||||||
'supported_instances': [
|
'supported_instances': [
|
||||||
(obj_fields.Architecture.I686,
|
(obj_fields.Architecture.I686,
|
||||||
obj_fields.HVType.HYPERV,
|
obj_fields.HVType.HYPERV,
|
||||||
vm_mode.HVM),
|
obj_fields.VMMode.HVM),
|
||||||
(obj_fields.Architecture.X86_64,
|
(obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.HYPERV,
|
obj_fields.HVType.HYPERV,
|
||||||
vm_mode.HVM)],
|
obj_fields.VMMode.HVM)],
|
||||||
'numa_topology': None,
|
'numa_topology': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ import six.moves.urllib.parse as urlparse
|
||||||
from nova.api.metadata import base as instance_metadata
|
from nova.api.metadata import base as instance_metadata
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova.console import type as console_type
|
from nova.console import type as console_type
|
||||||
|
@ -98,7 +97,7 @@ def _get_nodes_supported_instances(cpu_arch=None):
|
||||||
return []
|
return []
|
||||||
return [(cpu_arch,
|
return [(cpu_arch,
|
||||||
obj_fields.HVType.BAREMETAL,
|
obj_fields.HVType.BAREMETAL,
|
||||||
vm_mode.HVM)]
|
obj_fields.VMMode.HVM)]
|
||||||
|
|
||||||
|
|
||||||
def _log_ironic_polling(what, node, instance):
|
def _log_ironic_polling(what, node, instance):
|
||||||
|
|
|
@ -76,7 +76,6 @@ from oslo_config import cfg
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from nova import block_device
|
from nova import block_device
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.i18n import _
|
from nova.i18n import _
|
||||||
from nova.objects import base as obj_base
|
from nova.objects import base as obj_base
|
||||||
|
@ -248,8 +247,8 @@ def get_disk_bus_for_device_type(instance,
|
||||||
elif virt_type == "lxc":
|
elif virt_type == "lxc":
|
||||||
return "lxc"
|
return "lxc"
|
||||||
elif virt_type == "xen":
|
elif virt_type == "xen":
|
||||||
guest_vm_mode = vm_mode.get_from_instance(instance)
|
guest_vm_mode = obj_fields.VMMode.get_from_instance(instance)
|
||||||
if guest_vm_mode == vm_mode.HVM:
|
if guest_vm_mode == obj_fields.VMMode.HVM:
|
||||||
return "ide"
|
return "ide"
|
||||||
else:
|
else:
|
||||||
return "xen"
|
return "xen"
|
||||||
|
|
|
@ -64,7 +64,6 @@ from nova import block_device
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import utils as compute_utils
|
from nova.compute import utils as compute_utils
|
||||||
from nova.compute import vm_mode
|
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova.console import serial as serial_console
|
from nova.console import serial as serial_console
|
||||||
from nova.console import type as ctype
|
from nova.console import type as ctype
|
||||||
|
@ -3508,7 +3507,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
fs.source_dir = os.path.join(
|
fs.source_dir = os.path.join(
|
||||||
libvirt_utils.get_instance_path(instance), 'rootfs')
|
libvirt_utils.get_instance_path(instance), 'rootfs')
|
||||||
devices.append(fs)
|
devices.append(fs)
|
||||||
elif os_type == vm_mode.EXE and CONF.libvirt.virt_type == "parallels":
|
elif (os_type == fields.VMMode.EXE and
|
||||||
|
CONF.libvirt.virt_type == "parallels"):
|
||||||
if rescue:
|
if rescue:
|
||||||
fsrescue = self._get_guest_fs_config(instance, "disk.rescue")
|
fsrescue = self._get_guest_fs_config(instance, "disk.rescue")
|
||||||
devices.append(fsrescue)
|
devices.append(fsrescue)
|
||||||
|
@ -4012,13 +4012,13 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
def _get_guest_os_type(self, virt_type):
|
def _get_guest_os_type(self, virt_type):
|
||||||
"""Returns the guest OS type based on virt type."""
|
"""Returns the guest OS type based on virt type."""
|
||||||
if virt_type == "lxc":
|
if virt_type == "lxc":
|
||||||
ret = vm_mode.EXE
|
ret = fields.VMMode.EXE
|
||||||
elif virt_type == "uml":
|
elif virt_type == "uml":
|
||||||
ret = vm_mode.UML
|
ret = fields.VMMode.UML
|
||||||
elif virt_type == "xen":
|
elif virt_type == "xen":
|
||||||
ret = vm_mode.XEN
|
ret = fields.VMMode.XEN
|
||||||
else:
|
else:
|
||||||
ret = vm_mode.HVM
|
ret = fields.VMMode.HVM
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def _set_guest_for_rescue(self, rescue, guest, inst_path, virt_type,
|
def _set_guest_for_rescue(self, rescue, guest, inst_path, virt_type,
|
||||||
|
@ -4112,7 +4112,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
guest.features.append(vconfig.LibvirtConfigGuestFeaturePAE())
|
guest.features.append(vconfig.LibvirtConfigGuestFeaturePAE())
|
||||||
|
|
||||||
if (virt_type not in ("lxc", "uml", "parallels", "xen") or
|
if (virt_type not in ("lxc", "uml", "parallels", "xen") or
|
||||||
(virt_type == "xen" and guest.os_type == vm_mode.HVM)):
|
(virt_type == "xen" and guest.os_type == fields.VMMode.HVM)):
|
||||||
guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
|
guest.features.append(vconfig.LibvirtConfigGuestFeatureACPI())
|
||||||
guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
|
guest.features.append(vconfig.LibvirtConfigGuestFeatureAPIC())
|
||||||
|
|
||||||
|
@ -4145,7 +4145,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
# be overridden by the user with image_meta.properties, which
|
# be overridden by the user with image_meta.properties, which
|
||||||
# is carried out in the next if statement below this one.
|
# is carried out in the next if statement below this one.
|
||||||
guestarch = libvirt_utils.get_arch(image_meta)
|
guestarch = libvirt_utils.get_arch(image_meta)
|
||||||
if guest.os_type == vm_mode.XEN:
|
if guest.os_type == fields.VMMode.XEN:
|
||||||
video.type = 'xen'
|
video.type = 'xen'
|
||||||
elif CONF.libvirt.virt_type == 'parallels':
|
elif CONF.libvirt.virt_type == 'parallels':
|
||||||
video.type = 'vga'
|
video.type = 'vga'
|
||||||
|
@ -4312,7 +4312,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
def _configure_guest_by_virt_type(self, guest, virt_type, caps, instance,
|
def _configure_guest_by_virt_type(self, guest, virt_type, caps, instance,
|
||||||
image_meta, flavor, root_device_name):
|
image_meta, flavor, root_device_name):
|
||||||
if virt_type == "xen":
|
if virt_type == "xen":
|
||||||
if guest.os_type == vm_mode.HVM:
|
if guest.os_type == fields.VMMode.HVM:
|
||||||
guest.os_loader = CONF.libvirt.xen_hvmloader_path
|
guest.os_loader = CONF.libvirt.xen_hvmloader_path
|
||||||
elif virt_type in ("kvm", "qemu"):
|
elif virt_type in ("kvm", "qemu"):
|
||||||
if caps.host.cpu.arch in (fields.Architecture.I686,
|
if caps.host.cpu.arch in (fields.Architecture.I686,
|
||||||
|
@ -4347,7 +4347,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
guest.os_kernel = "/usr/bin/linux"
|
guest.os_kernel = "/usr/bin/linux"
|
||||||
guest.os_root = root_device_name
|
guest.os_root = root_device_name
|
||||||
elif virt_type == "parallels":
|
elif virt_type == "parallels":
|
||||||
if guest.os_type == vm_mode.EXE:
|
if guest.os_type == fields.VMMode.EXE:
|
||||||
guest.os_init_path = "/sbin/init"
|
guest.os_init_path = "/sbin/init"
|
||||||
|
|
||||||
def _conf_non_lxc_uml(self, virt_type, guest, root_device_name, rescue,
|
def _conf_non_lxc_uml(self, virt_type, guest, root_device_name, rescue,
|
||||||
|
@ -4559,7 +4559,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
# for nova.api.ec2.cloud.CloudController.get_metadata()
|
# for nova.api.ec2.cloud.CloudController.get_metadata()
|
||||||
instance.root_device_name = root_device_name
|
instance.root_device_name = root_device_name
|
||||||
|
|
||||||
guest.os_type = (vm_mode.get_from_instance(instance) or
|
guest.os_type = (fields.VMMode.get_from_instance(instance) or
|
||||||
self._get_guest_os_type(virt_type))
|
self._get_guest_os_type(virt_type))
|
||||||
caps = self._host.get_capabilities()
|
caps = self._host.get_capabilities()
|
||||||
|
|
||||||
|
@ -4707,7 +4707,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
|
|
||||||
def _get_guest_usb_tablet(self, os_type):
|
def _get_guest_usb_tablet(self, os_type):
|
||||||
tablet = None
|
tablet = None
|
||||||
if os_type == vm_mode.HVM:
|
if os_type == fields.VMMode.HVM:
|
||||||
tablet = vconfig.LibvirtConfigGuestInput()
|
tablet = vconfig.LibvirtConfigGuestInput()
|
||||||
tablet.type = "tablet"
|
tablet.type = "tablet"
|
||||||
tablet.bus = "usb"
|
tablet.bus = "usb"
|
||||||
|
@ -5072,7 +5072,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
instance_cap = (
|
instance_cap = (
|
||||||
fields.Architecture.canonicalize(g.arch),
|
fields.Architecture.canonicalize(g.arch),
|
||||||
fields.HVType.canonicalize(dt),
|
fields.HVType.canonicalize(dt),
|
||||||
vm_mode.canonicalize(g.ostype))
|
fields.VMMode.canonicalize(g.ostype))
|
||||||
instance_caps.append(instance_cap)
|
instance_caps.append(instance_cap)
|
||||||
|
|
||||||
return instance_caps
|
return instance_caps
|
||||||
|
@ -6862,7 +6862,7 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||||
doc.findall('.//devices/%s/target' % device_type))
|
doc.findall('.//devices/%s/target' % device_type))
|
||||||
|
|
||||||
if (CONF.libvirt.virt_type == 'parallels' and
|
if (CONF.libvirt.virt_type == 'parallels' and
|
||||||
doc.find('os/type').text == vm_mode.EXE):
|
doc.find('os/type').text == fields.VMMode.EXE):
|
||||||
node_type = 'filesystem'
|
node_type = 'filesystem'
|
||||||
else:
|
else:
|
||||||
node_type = 'disk'
|
node_type = 'disk'
|
||||||
|
|
|
@ -26,7 +26,6 @@ from lxml import etree
|
||||||
from oslo_concurrency import processutils
|
from oslo_concurrency import processutils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova.i18n import _
|
from nova.i18n import _
|
||||||
from nova.i18n import _LI
|
from nova.i18n import _LI
|
||||||
|
@ -360,7 +359,8 @@ def find_disk(virt_dom):
|
||||||
disk_path = source.get('dir')
|
disk_path = source.get('dir')
|
||||||
disk_path = disk_path[0:disk_path.rfind('rootfs')]
|
disk_path = disk_path[0:disk_path.rfind('rootfs')]
|
||||||
disk_path = os.path.join(disk_path, 'disk')
|
disk_path = os.path.join(disk_path, 'disk')
|
||||||
elif CONF.libvirt.virt_type == 'parallels' and os_type == vm_mode.EXE:
|
elif (CONF.libvirt.virt_type == 'parallels' and
|
||||||
|
os_type == obj_fields.VMMode.EXE):
|
||||||
filesystem = domain.find('devices/filesystem')
|
filesystem = domain.find('devices/filesystem')
|
||||||
driver = filesystem.find('driver')
|
driver = filesystem.find('driver')
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ from oslo_utils import units
|
||||||
from oslo_utils import versionutils
|
from oslo_utils import versionutils
|
||||||
from oslo_vmware import exceptions as vexc
|
from oslo_vmware import exceptions as vexc
|
||||||
|
|
||||||
from nova.compute import vm_mode
|
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
@ -99,10 +98,10 @@ class VCState(object):
|
||||||
data["supported_instances"] = [
|
data["supported_instances"] = [
|
||||||
(obj_fields.Architecture.I686,
|
(obj_fields.Architecture.I686,
|
||||||
obj_fields.HVType.VMWARE,
|
obj_fields.HVType.VMWARE,
|
||||||
vm_mode.HVM),
|
obj_fields.VMMode.HVM),
|
||||||
(obj_fields.Architecture.X86_64,
|
(obj_fields.Architecture.X86_64,
|
||||||
obj_fields.HVType.VMWARE,
|
obj_fields.HVType.VMWARE,
|
||||||
vm_mode.HVM)]
|
obj_fields.VMMode.HVM)]
|
||||||
|
|
||||||
self._stats = data
|
self._stats = data
|
||||||
if self._auto_service_disabled:
|
if self._auto_service_disabled:
|
||||||
|
|
|
@ -25,7 +25,6 @@ from oslo_serialization import jsonutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
@ -285,7 +284,7 @@ def to_supported_instances(host_capabilities):
|
||||||
ostype, _version, guestarch = capability.split("-")
|
ostype, _version, guestarch = capability.split("-")
|
||||||
|
|
||||||
guestarch = obj_fields.Architecture.canonicalize(guestarch)
|
guestarch = obj_fields.Architecture.canonicalize(guestarch)
|
||||||
ostype = vm_mode.canonicalize(ostype)
|
ostype = obj_fields.VMMode.canonicalize(ostype)
|
||||||
|
|
||||||
result.append((guestarch, obj_fields.HVType.XEN, ostype))
|
result.append((guestarch, obj_fields.HVType.XEN, ostype))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
@ -43,11 +43,11 @@ import six.moves.urllib.parse as urlparse
|
||||||
from nova.api.metadata import base as instance_metadata
|
from nova.api.metadata import base as instance_metadata
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_mode
|
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.i18n import _, _LE, _LI, _LW
|
from nova.i18n import _, _LE, _LI, _LW
|
||||||
from nova.network import model as network_model
|
from nova.network import model as network_model
|
||||||
|
from nova.objects import fields as obj_fields
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.virt import configdrive
|
from nova.virt import configdrive
|
||||||
from nova.virt import diagnostics
|
from nova.virt import diagnostics
|
||||||
|
@ -1608,23 +1608,24 @@ def determine_disk_image_type(image_meta):
|
||||||
|
|
||||||
|
|
||||||
def determine_vm_mode(instance, disk_image_type):
|
def determine_vm_mode(instance, disk_image_type):
|
||||||
current_mode = vm_mode.get_from_instance(instance)
|
current_mode = obj_fields.VMMode.get_from_instance(instance)
|
||||||
if current_mode == vm_mode.XEN or current_mode == vm_mode.HVM:
|
if (current_mode == obj_fields.VMMode.XEN or
|
||||||
|
current_mode == obj_fields.VMMode.HVM):
|
||||||
return current_mode
|
return current_mode
|
||||||
|
|
||||||
os_type = instance['os_type']
|
os_type = instance['os_type']
|
||||||
if os_type == "linux":
|
if os_type == "linux":
|
||||||
return vm_mode.XEN
|
return obj_fields.VMMode.XEN
|
||||||
if os_type == "windows":
|
if os_type == "windows":
|
||||||
return vm_mode.HVM
|
return obj_fields.VMMode.HVM
|
||||||
|
|
||||||
# disk_image_type specific default for backwards compatibility
|
# disk_image_type specific default for backwards compatibility
|
||||||
if disk_image_type == ImageType.DISK_VHD or \
|
if disk_image_type == ImageType.DISK_VHD or \
|
||||||
disk_image_type == ImageType.DISK:
|
disk_image_type == ImageType.DISK:
|
||||||
return vm_mode.XEN
|
return obj_fields.VMMode.XEN
|
||||||
|
|
||||||
# most images run OK as HVM
|
# most images run OK as HVM
|
||||||
return vm_mode.HVM
|
return obj_fields.VMMode.HVM
|
||||||
|
|
||||||
|
|
||||||
def set_vm_name_label(session, vm_ref, name_label):
|
def set_vm_name_label(session, vm_ref, name_label):
|
||||||
|
|
|
@ -39,7 +39,6 @@ from nova import block_device
|
||||||
from nova import compute
|
from nova import compute
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
from nova.compute import task_states
|
from nova.compute import task_states
|
||||||
from nova.compute import vm_mode
|
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
import nova.conf
|
import nova.conf
|
||||||
from nova.console import type as ctype
|
from nova.console import type as ctype
|
||||||
|
@ -47,6 +46,7 @@ from nova import context as nova_context
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.i18n import _, _LE, _LI, _LW
|
from nova.i18n import _, _LE, _LI, _LW
|
||||||
from nova import objects
|
from nova import objects
|
||||||
|
from nova.objects import fields as obj_fields
|
||||||
from nova.pci import manager as pci_manager
|
from nova.pci import manager as pci_manager
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova.virt import configdrive
|
from nova.virt import configdrive
|
||||||
|
@ -703,7 +703,7 @@ class VMOps(object):
|
||||||
LOG.debug("vm_mode not found in rescue image properties."
|
LOG.debug("vm_mode not found in rescue image properties."
|
||||||
"Setting vm_mode to %s", mode, instance=instance)
|
"Setting vm_mode to %s", mode, instance=instance)
|
||||||
else:
|
else:
|
||||||
mode = vm_mode.canonicalize(rescue_vm_mode)
|
mode = obj_fields.VMMode.canonicalize(rescue_vm_mode)
|
||||||
|
|
||||||
if instance.vm_mode != mode:
|
if instance.vm_mode != mode:
|
||||||
# Update database with normalized (or determined) value
|
# Update database with normalized (or determined) value
|
||||||
|
@ -711,7 +711,7 @@ class VMOps(object):
|
||||||
instance.save()
|
instance.save()
|
||||||
|
|
||||||
device_id = vm_utils.get_vm_device_id(self._session, image_meta)
|
device_id = vm_utils.get_vm_device_id(self._session, image_meta)
|
||||||
use_pv_kernel = (mode == vm_mode.XEN)
|
use_pv_kernel = (mode == obj_fields.VMMode.XEN)
|
||||||
LOG.debug("Using PV kernel: %s", use_pv_kernel, instance=instance)
|
LOG.debug("Using PV kernel: %s", use_pv_kernel, instance=instance)
|
||||||
vm_ref = vm_utils.create_vm(self._session, instance, name_label,
|
vm_ref = vm_utils.create_vm(self._session, instance, name_label,
|
||||||
kernel_file, ramdisk_file,
|
kernel_file, ramdisk_file,
|
||||||
|
|
Loading…
Reference in New Issue