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
This commit is contained in:
EdLeafe 2016-10-05 21:34:42 +00:00 committed by Jay Pipes
parent 5661f879b0
commit 16f4bad6d3
3 changed files with 9 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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