Add missing compat routine for Usage object
We added a v1.1 to Usage without a compat routine to go with it. It's not really a big deal as we're not sending this over RPC anywhere yet that I know of, but we should have this for the sake of completeness. Change-Id: Ia50448741b29e1c33e4988a9476418b6ba835983
This commit is contained in:
@@ -937,6 +937,13 @@ class Usage(base.NovaObject):
|
|||||||
'usage': fields.NonNegativeIntegerField(),
|
'usage': fields.NonNegativeIntegerField(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def obj_make_compatible(self, primitive, target_version):
|
||||||
|
super(Usage, self).obj_make_compatible(primitive, target_version)
|
||||||
|
target_version = versionutils.convert_version_to_tuple(target_version)
|
||||||
|
if target_version < (1, 1) and 'resource_class' in primitive:
|
||||||
|
rc = primitive['resource_class']
|
||||||
|
rc_cache.raise_if_custom_resource_class_pre_v1_1(rc)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _from_db_object(context, target, source):
|
def _from_db_object(context, target, source):
|
||||||
for field in target.fields:
|
for field in target.fields:
|
||||||
|
@@ -541,3 +541,13 @@ class TestAllocationListNoDB(test_objects._LocalTest,
|
|||||||
class TestRemoteAllocationListNoDB(test_objects._RemoteTest,
|
class TestRemoteAllocationListNoDB(test_objects._RemoteTest,
|
||||||
_TestAllocationListNoDB):
|
_TestAllocationListNoDB):
|
||||||
USES_DB = False
|
USES_DB = False
|
||||||
|
|
||||||
|
|
||||||
|
class TestUsageNoDB(test_objects._LocalTest):
|
||||||
|
USES_DB = False
|
||||||
|
|
||||||
|
def test_v1_1_resource_class(self):
|
||||||
|
usage = objects.Usage(resource_class='foo')
|
||||||
|
self.assertRaises(ValueError,
|
||||||
|
usage.obj_to_primitive,
|
||||||
|
target_version='1.0')
|
||||||
|
Reference in New Issue
Block a user