objects: Fix issue in exception type
We were attempting to pass a 'target_version' variable into an exception message. 'target_version' is a tuple which means it's expanded out resulting in the following error: TypeError: not all arguments converted during string formatting Fix this. Change-Id: I6063b2108ae38776d034fd7a4c3aa88dc66a084f Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Closes-Bug: #1898554
This commit is contained in:
parent
261de76104
commit
12cc805d36
|
@ -48,8 +48,9 @@ class InstanceNUMACell(base.NovaEphemeralObject,
|
|||
if primitive['cpu_policy'] == obj_fields.CPUAllocationPolicy.MIXED:
|
||||
raise exception.ObjectActionError(
|
||||
action='obj_make_compatible',
|
||||
reason=_('mixed instance is not supported in version %s') %
|
||||
target_version)
|
||||
reason=_(
|
||||
'%s policy is not supported in version %s'
|
||||
) % (primitive['cpu_policy'], target_version))
|
||||
|
||||
# NOTE(huaqiang): Since version 1.5, 'cpuset' is modified to track the
|
||||
# unpinned CPUs only, with pinned CPUs tracked via 'pcpuset' instead.
|
||||
|
|
|
@ -179,10 +179,23 @@ class _TestInstanceNUMACell(object):
|
|||
topo_obj = objects.InstanceNUMACell(
|
||||
cpuset=set(), pcpuset=set([0, 1]),
|
||||
cpuset_reserved=set([1, 2]),
|
||||
cpu_policy=fields.CPUAllocationPolicy.DEDICATED)
|
||||
cpu_policy=fields.CPUAllocationPolicy.MIXED,
|
||||
)
|
||||
versions = ovo_base.obj_tree_get_versions('InstanceNUMACell')
|
||||
data = lambda x: x['nova_object.data']
|
||||
|
||||
primitive = data(topo_obj.obj_to_primitive(
|
||||
target_version='1.6', version_manifest=versions))
|
||||
self.assertEqual(
|
||||
fields.CPUAllocationPolicy.MIXED, primitive['cpu_policy'])
|
||||
|
||||
self.assertRaises(
|
||||
exception.ObjectActionError,
|
||||
topo_obj.obj_to_primitive,
|
||||
target_version='1.5', version_manifest=versions)
|
||||
|
||||
# set this to something compatible with < 1.6 so we can keep testing
|
||||
topo_obj.cpu_policy = fields.CPUAllocationPolicy.DEDICATED
|
||||
primitive = data(topo_obj.obj_to_primitive(
|
||||
target_version='1.5', version_manifest=versions))
|
||||
self.assertIn('pcpuset', primitive)
|
||||
|
|
Loading…
Reference in New Issue