diff --git a/lower-constraints.txt b/lower-constraints.txt index 27a8514780c0..2bd57f8a01f9 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -62,7 +62,7 @@ os-brick==3.1.0 os-client-config==1.29.0 os-resource-classes==0.4.0 os-service-types==1.7.0 -os-traits==2.4.0 +os-traits==2.5.0 os-vif==1.14.0 os-win==4.2.0 os-xenapi==0.3.4 diff --git a/nova/scheduler/utils.py b/nova/scheduler/utils.py index fa376c5d12fb..46fe72072277 100644 --- a/nova/scheduler/utils.py +++ b/nova/scheduler/utils.py @@ -188,6 +188,8 @@ class ResourceRequest(object): res_req._translate_vtpm_request(request_spec.flavor, image) + res_req._translate_pci_numa_affinity_policy(request_spec.flavor, image) + res_req.strip_zeros() return res_req @@ -351,6 +353,16 @@ class ResourceRequest(object): 'value': trait}) self._add_trait(os_traits.HW_CPU_HYPERTHREADING, trait) + def _translate_pci_numa_affinity_policy(self, flavor, image): + policy = hardware.get_pci_numa_policy_constraint(flavor, image) + # only the socket policy supports a trait + if policy == objects.fields.PCINUMAAffinityPolicy.SOCKET: + trait = os_traits.COMPUTE_SOCKET_PCI_NUMA_AFFINITY + self._add_trait(trait, 'required') + LOG.debug( + "Requiring 'socket' PCI NUMA affinity support via trait %s.", + trait) + @property def group_policy(self): return self._group_policy diff --git a/nova/tests/unit/scheduler/test_utils.py b/nova/tests/unit/scheduler/test_utils.py index 29d59f47b3bd..74871c9b80bc 100644 --- a/nova/tests/unit/scheduler/test_utils.py +++ b/nova/tests/unit/scheduler/test_utils.py @@ -1224,6 +1224,25 @@ class TestUtils(TestUtilsBase): rr = utils.ResourceRequest.from_request_spec(rs) self.assertResourceRequestsEqual(expected, rr) + def test_resource_request_from_request_spec_with_pci_numa_policy(self): + flavor = objects.Flavor( + vcpus=1, memory_mb=1024, root_gb=10, ephemeral_gb=5, swap=0, + extra_specs={'hw:pci_numa_affinity_policy': 'socket'}, + ) + expected = FakeResourceRequest() + expected._rg_by_id[None] = objects.RequestGroup( + use_same_provider=False, + required_traits={'COMPUTE_SOCKET_PCI_NUMA_AFFINITY'}, + resources={ + 'VCPU': 1, + 'MEMORY_MB': 1024, + 'DISK_GB': 15, + }, + ) + rs = objects.RequestSpec(flavor=flavor, is_bfv=False) + rr = utils.ResourceRequest.from_request_spec(rs) + self.assertResourceRequestsEqual(expected, rr) + def test_resource_request_from_request_spec_with_vtpm_1_2(self): flavor = objects.Flavor( vcpus=1, memory_mb=1024, root_gb=10, ephemeral_gb=5, swap=0, diff --git a/requirements.txt b/requirements.txt index 25ee05c282b2..1b9db60e7aa2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -53,7 +53,7 @@ psutil>=3.2.2 # BSD oslo.versionedobjects>=1.35.0 # Apache-2.0 os-brick>=3.1.0 # Apache-2.0 os-resource-classes>=0.4.0 # Apache-2.0 -os-traits>=2.4.0 # Apache-2.0 +os-traits>=2.5.0 # Apache-2.0 os-vif>=1.14.0 # Apache-2.0 os-win>=4.2.0 # Apache-2.0 castellan>=0.16.0 # Apache-2.0