From 5694ff0635ec165bec2d34504ae6060219bc0d9c Mon Sep 17 00:00:00 2001 From: Huan Xie Date: Wed, 11 Oct 2017 09:32:26 +0100 Subject: [PATCH] VGPU: Define vgpu resource class This patch is to add definition of resource class for VGPU and VGPU_DISPLAY_HEAD, and there will be a series of patches to implement the whole vgpu feature. Partially Implements: blueprint add-support-for-vgpu Change-Id: Ie363453eb9856b39e4ededc5e76807b3d165a1c5 --- nova/objects/fields.py | 4 +++- .../api/openstack/placement/gabbits/resource-classes.yaml | 8 ++++---- nova/tests/unit/objects/test_fields.py | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/nova/objects/fields.py b/nova/objects/fields.py index b7d3791ee073..c2bab3c4b1ad 100644 --- a/nova/objects/fields.py +++ b/nova/objects/fields.py @@ -475,12 +475,14 @@ class ResourceClass(StringField): NUMA_THREAD = 'NUMA_THREAD' NUMA_MEMORY_MB = 'NUMA_MEMORY_MB' IPV4_ADDRESS = 'IPV4_ADDRESS' + VGPU = 'VGPU' + VGPU_DISPLAY_HEAD = 'VGPU_DISPLAY_HEAD' # The ordering here is relevant. If you must add a value, only # append. STANDARD = (VCPU, MEMORY_MB, DISK_GB, PCI_DEVICE, SRIOV_NET_VF, NUMA_SOCKET, NUMA_CORE, NUMA_THREAD, NUMA_MEMORY_MB, - IPV4_ADDRESS) + IPV4_ADDRESS, VGPU, VGPU_DISPLAY_HEAD) # This is the set of standard resource classes that existed before # we opened up for custom resource classes in version 1.1 of various diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml index 8fd204515984..1a4cdd699409 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml @@ -40,7 +40,7 @@ tests: GET: /resource_classes response_json_paths: response_json_paths: - $.resource_classes.`len`: 10 # Number of standard resource classes + $.resource_classes.`len`: 12 # Number of standard resource classes $.resource_classes[0].name: VCPU - name: non admin forbidden @@ -117,9 +117,9 @@ tests: - name: list resource classes after addition of custom res class GET: /resource_classes response_json_paths: - $.resource_classes.`len`: 11 # 10 standard plus 1 custom - $.resource_classes[10].name: $ENVIRON['CUSTOM_RES_CLASS'] - $.resource_classes[10].links[?rel = "self"].href: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS'] + $.resource_classes.`len`: 13 # 12 standard plus 1 custom + $.resource_classes[12].name: $ENVIRON['CUSTOM_RES_CLASS'] + $.resource_classes[12].links[?rel = "self"].href: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS'] - name: update standard resource class PUT: /resource_classes/VCPU diff --git a/nova/tests/unit/objects/test_fields.py b/nova/tests/unit/objects/test_fields.py index 3d0d786fa10b..6db85d0a568f 100644 --- a/nova/tests/unit/objects/test_fields.py +++ b/nova/tests/unit/objects/test_fields.py @@ -346,6 +346,8 @@ class TestResourceClass(TestString): ('NUMA_THREAD', 'NUMA_THREAD'), ('NUMA_MEMORY_MB', 'NUMA_MEMORY_MB'), ('IPV4_ADDRESS', 'IPV4_ADDRESS'), + ('VGPU', 'VGPU'), + ('VGPU_DISPLAY_HEAD', 'VGPU_DISPLAY_HEAD'), ] self.coerce_bad_values = [object(), dict()] self.to_primitive_values = self.coerce_good_values[0:1]