From: EdLeafe Date: Wed, 5 Oct 2016 21:34:42 +0000 (+0000) Subject: Changed the name of the standard resource classes X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=16f4bad6d396c82608bfb094008512f2c3eb37ba;p=osstest%2Fopenstack-nova.git Changed the name of the standard resource classes Originally, the declared names for the resource classes defined in objects/fields.py were an enum, as the original design assumed that any future resource classes would be added as a software upgrade release. As is the convention, this enum was given the name 'ALL'. With the introduction of custom resource classes that can be added by admins, the defined classes are no longer an enum, so the name 'ALL' is misleading. This patch renames it to the more accurate 'STANDARD'. Change-Id: I251a6faa8c284eb91d190b47108664e67d824425 Blueprint: custom-resource-classes --- diff --git a/nova/db/sqlalchemy/resource_class_cache.py b/nova/db/sqlalchemy/resource_class_cache.py index b10efccc70..9188958c8a 100644 --- a/nova/db/sqlalchemy/resource_class_cache.py +++ b/nova/db/sqlalchemy/resource_class_cache.py @@ -83,8 +83,8 @@ class ResourceClassCache(object): return self.id_cache[rc_str] # First check the standard resource classes - if rc_str in fields.ResourceClass.ALL: - return fields.ResourceClass.ALL.index(rc_str) + if rc_str in fields.ResourceClass.STANDARD: + return fields.ResourceClass.STANDARD.index(rc_str) else: # Otherwise, check the database table _refresh_from_db(self.ctx, self) @@ -106,9 +106,9 @@ class ResourceClassCache(object): if rc_id in self.str_cache: return self.str_cache[rc_id] - # First check the fields.ResourceClass.ALL enum + # First check the fields.ResourceClass.STANDARD values try: - return fields.ResourceClass.ALL[rc_id] + return fields.ResourceClass.STANDARD[rc_id] except IndexError: # Otherwise, check the database table _refresh_from_db(self.ctx, self) diff --git a/nova/objects/fields.py b/nova/objects/fields.py index 1ee157f168..73d0e4ce97 100644 --- a/nova/objects/fields.py +++ b/nova/objects/fields.py @@ -271,8 +271,9 @@ class ResourceClass(StringField): # The ordering here is relevant. If you must add a value, only # append. - ALL = (VCPU, MEMORY_MB, DISK_GB, PCI_DEVICE, SRIOV_NET_VF, NUMA_SOCKET, - NUMA_CORE, NUMA_THREAD, NUMA_MEMORY_MB, IPV4_ADDRESS) + STANDARD = (VCPU, MEMORY_MB, DISK_GB, PCI_DEVICE, SRIOV_NET_VF, + NUMA_SOCKET, NUMA_CORE, NUMA_THREAD, NUMA_MEMORY_MB, + IPV4_ADDRESS) # 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/unit/objects/test_resource_provider.py b/nova/tests/unit/objects/test_resource_provider.py index 48cbcbb19b..bd0ba3ccc4 100644 --- a/nova/tests/unit/objects/test_resource_provider.py +++ b/nova/tests/unit/objects/test_resource_provider.py @@ -23,9 +23,9 @@ from nova.tests import uuidsentinel as uuids _RESOURCE_CLASS_NAME = 'DISK_GB' _RESOURCE_CLASS_ID = 2 -IPV4_ADDRESS_ID = objects.fields.ResourceClass.ALL.index( +IPV4_ADDRESS_ID = objects.fields.ResourceClass.STANDARD.index( fields.ResourceClass.IPV4_ADDRESS) -VCPU_ID = objects.fields.ResourceClass.ALL.index( +VCPU_ID = objects.fields.ResourceClass.STANDARD.index( fields.ResourceClass.VCPU) _RESOURCE_PROVIDER_ID = 1