From eacecc2433562aeca1f95366200ca1679c3679a1 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 20 May 2021 12:56:34 +0100 Subject: Move 'hw:pmu', 'hw_pmu' parsing to nova.virt.hardware Virtually all of the code for parsing 'hw:'-prefixed extra specs and 'hw_'-prefix image metadata properties lives in the 'nova.virt.hardware' module. It makes sense for these to be included there. Do that. Change-Id: I1fabdf1827af597f9e5fdb40d5aef244024dd015 Signed-off-by: Stephen Finucane --- nova/compute/api.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'nova/compute/api.py') diff --git a/nova/compute/api.py b/nova/compute/api.py index 28368d910f..90314bb4bc 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -838,17 +838,10 @@ class API: """ image_meta = _get_image_meta_obj(image) - API._validate_flavor_image_mem_encryption(flavor, image_meta) - - # validate PMU extra spec and image metadata - flavor_pmu = flavor.extra_specs.get('hw:pmu') - image_pmu = image_meta.properties.get('hw_pmu') - if (flavor_pmu is not None and image_pmu is not None and - image_pmu != strutils.bool_from_string(flavor_pmu)): - raise exception.ImagePMUConflict() - # Only validate values of flavor/image so the return results of # following 'get' functions are not used. + hardware.get_mem_encryption_constraint(flavor, image_meta) + hardware.get_pmu_constraint(flavor, image_meta) hardware.get_number_of_serial_ports(flavor, image_meta) hardware.get_realtime_cpu_constraint(flavor, image_meta) hardware.get_cpu_topology_constraints(flavor, image_meta) @@ -858,19 +851,6 @@ class API: if validate_pci: pci_request.get_pci_requests_from_flavor(flavor) - @staticmethod - def _validate_flavor_image_mem_encryption(flavor, image): - """Validate that the flavor and image don't make contradictory - requests regarding memory encryption. - - :param flavor: Flavor object - :param image: an ImageMeta object - :raises: nova.exception.FlavorImageConflict - """ - # This library function will raise the exception for us if - # necessary; if not, we can ignore the result returned. - hardware.get_mem_encryption_constraint(flavor, image) - def _get_image_defined_bdms(self, flavor, image_meta, root_device_name): image_properties = image_meta.get('properties', {}) -- cgit v1.2.1