diff options
author | Stephen Finucane <stephenfin@redhat.com> | 2020-04-08 14:57:04 +0100 |
---|---|---|
committer | Stephen Finucane <stephenfin@redhat.com> | 2020-04-09 10:02:34 +0100 |
commit | 9b15f347d5f2f19701331e68c116ccc5a0a128d3 (patch) | |
tree | 4b3e705503892c6d3a36a6751533d90f737d14c1 /nova/tests | |
parent | 4e30693727d47ea89acd0b21964e3d2ec32ec615 (diff) | |
download | nova-9b15f347d5f2f19701331e68c116ccc5a0a128d3.tar.gz |
api: Allow custom traits
This was missed in change Ib64a1348cce1dca995746214616c4f33d9d664bd. We
also correct the allowed syntax for resource group and values.
Part of blueprint flavor-extra-spec-validators
Change-Id: I6a46556aaa1e7cab03286f92b716841759c63e3d
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'nova/tests')
-rw-r--r-- | nova/tests/unit/api/openstack/compute/test_flavors_extra_specs.py | 17 | ||||
-rw-r--r-- | nova/tests/unit/api/validation/extra_specs/test_validators.py | 4 |
2 files changed, 18 insertions, 3 deletions
diff --git a/nova/tests/unit/api/openstack/compute/test_flavors_extra_specs.py b/nova/tests/unit/api/openstack/compute/test_flavors_extra_specs.py index fdf2147329..f10e3cd363 100644 --- a/nova/tests/unit/api/openstack/compute/test_flavors_extra_specs.py +++ b/nova/tests/unit/api/openstack/compute/test_flavors_extra_specs.py @@ -272,10 +272,17 @@ class FlavorsExtraSpecsTestV21(test.TestCase): 'hw:cpu_policy': 'sharrred', 'hw:cpu_policyyyyyyy': 'shared', 'hw:foo': 'bar', + 'resources:VCPU': 'N', + 'resources_foo:VCPU': 'N', + 'resources:VVCPU': '1', + 'resources_foo:VVCPU': '1', 'trait:STORAGE_DISK_SSD': 'forbiden', 'trait_foo:HW_CPU_X86_AVX2': 'foo', 'trait:bar': 'required', 'trait_foo:bar': 'required', + 'trait:CUSTOM_foo': 'required', + 'trait:CUSTOM_FOO': 'bar', + 'trait_foo:CUSTOM_BAR': 'foo', } for key, value in invalid_specs.items(): body = {'extra_specs': {key: value}} @@ -307,14 +314,22 @@ class FlavorsExtraSpecsTestV21(test.TestCase): 'hide_hypervisor_id': 'true', 'hw:numa_nodes': '1', 'hw:numa_cpus.0': '0-3,8-9,11,10', + 'resources:VCPU': '4', + 'resources_foo:VCPU': '4', + 'resources:CUSTOM_FOO': '1', + 'resources_foo:CUSTOM_BAR': '2', 'trait:STORAGE_DISK_SSD': 'forbidden', 'trait_foo:HW_CPU_X86_AVX2': 'required', + 'trait:CUSTOM_FOO': 'forbidden', + 'trait_foo:CUSTOM_BAR': 'required', } mock_flavor_extra_specs.side_effect = return_create_flavor_extra_specs for key, value in valid_specs.items(): body = {"extra_specs": {key: value}} - req = self._get_request('1/os-extra_specs', use_admin_context=True) + req = self._get_request( + '1/os-extra_specs', use_admin_context=True, version='2.86', + ) res_dict = self.controller.create(req, 1, body=body) self.assertEqual(value, res_dict['extra_specs'][key]) diff --git a/nova/tests/unit/api/validation/extra_specs/test_validators.py b/nova/tests/unit/api/validation/extra_specs/test_validators.py index c45e9e3773..2670c5c5ac 100644 --- a/nova/tests/unit/api/validation/extra_specs/test_validators.py +++ b/nova/tests/unit/api/validation/extra_specs/test_validators.py @@ -29,8 +29,8 @@ class TestValidators(test.NoDBTestCase): namespaces = { 'accel', 'aggregate_instance_extra_specs', 'capabilities', 'hw', 'hw_rng', 'hw_video', 'os', 'pci_passthrough', 'powervm', 'quota', - 'resources(?P<group>(_[a-zA-z0-9_]*|\\d+)?)', - 'trait(?P<group>(_[a-zA-z0-9_]*|\\d+)?)', 'vmware', + 'resources(?P<group>([a-zA-Z0-9_-]{1,64})?)', + 'trait(?P<group>([a-zA-Z0-9_-]{1,64})?)', 'vmware', } self.assertTrue( namespaces.issubset(validators.NAMESPACES), |