Merge "Validate PCI aliases early in resize"
This commit is contained in:
commit
6304bcf781
|
@ -561,7 +561,28 @@ class API(base.Base):
|
|||
|
||||
@staticmethod
|
||||
def _validate_flavor_image_nostatus(context, image, instance_type,
|
||||
root_bdm, validate_numa=True):
|
||||
root_bdm, validate_numa=True,
|
||||
validate_pci=False):
|
||||
"""Validate the flavor and image.
|
||||
|
||||
This is called from the API service to ensure that the flavor
|
||||
extra-specs and image properties are self-consistent and compatible
|
||||
with each other.
|
||||
|
||||
:param context: A context.RequestContext
|
||||
:param image: a dict representation of the image including properties,
|
||||
enforces the image status is active.
|
||||
:param instance_type: Flavor object
|
||||
:param root_bdm: BlockDeviceMapping for root disk. Will be None for
|
||||
the resize case.
|
||||
:param validate_numa: Flag to indicate whether or not to validate
|
||||
the NUMA-related metadata.
|
||||
:param validate_pci: Flag to indicate whether or not to validate
|
||||
the PCI-related metadata.
|
||||
:raises: Many different possible exceptions. See
|
||||
api.openstack.compute.servers.INVALID_FLAVOR_IMAGE_EXCEPTIONS
|
||||
for the full list.
|
||||
"""
|
||||
if not image:
|
||||
return
|
||||
|
||||
|
@ -653,6 +674,8 @@ class API(base.Base):
|
|||
hardware.get_cpu_topology_constraints(instance_type, image_meta)
|
||||
if validate_numa:
|
||||
hardware.numa_get_constraints(instance_type, image_meta)
|
||||
if validate_pci:
|
||||
pci_request.get_pci_requests_from_flavor(instance_type)
|
||||
|
||||
def _get_image_defined_bdms(self, instance_type, image_meta,
|
||||
root_device_name):
|
||||
|
@ -3595,7 +3618,8 @@ class API(base.Base):
|
|||
instance.system_metadata)
|
||||
# Can skip root_bdm check since it will not change during resize.
|
||||
self._validate_flavor_image_nostatus(
|
||||
context, image, new_instance_type, root_bdm=None)
|
||||
context, image, new_instance_type, root_bdm=None,
|
||||
validate_pci=True)
|
||||
|
||||
filter_properties = {'ignore_hosts': []}
|
||||
|
||||
|
|
|
@ -2094,7 +2094,8 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
fake_inst.system_metadata)
|
||||
if not same_flavor:
|
||||
mock_validate.assert_called_once_with(
|
||||
self.context, image_meta, new_flavor, root_bdm=None)
|
||||
self.context, image_meta, new_flavor, root_bdm=None,
|
||||
validate_pci=True)
|
||||
# mock.ANY might be 'instances', 'cores', or 'ram'
|
||||
# depending on how the deltas dict is iterated in check_deltas
|
||||
mock_count.assert_called_once_with(
|
||||
|
@ -6429,6 +6430,18 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
self.assertEqual(['context-for-%s' % c for c in compute_api.CELLS],
|
||||
cells)
|
||||
|
||||
@mock.patch('nova.pci.request.get_pci_requests_from_flavor')
|
||||
def test_pci_validated(self, mock_request):
|
||||
"""Tests that calling _validate_flavor_image_nostatus() with
|
||||
validate_pci=True results in get_pci_requests_from_flavor() being
|
||||
called.
|
||||
"""
|
||||
image = dict(id=uuids.image_id, status='foo')
|
||||
flavor = self._create_flavor()
|
||||
self.compute_api._validate_flavor_image_nostatus(self.context,
|
||||
image, flavor, root_bdm=None, validate_pci=True)
|
||||
mock_request.assert_called_once_with(flavor)
|
||||
|
||||
def test_validate_and_build_base_options_translate_neutron_secgroup(self):
|
||||
"""Tests that _check_requested_secgroups will return a uuid for a
|
||||
requested Neutron security group and that will be returned from
|
||||
|
|
Loading…
Reference in New Issue