Assume node traits in instance trait validation
In Rocky, we can assume that node.traits is set, since the earliest version we may be pinned to is Queens, which supports node traits. Change-Id: Ib011122a72f31e73e7e2031cb7582057e1f33ef4 Related-Bug: #1755146 Related-Bug: #1722194
This commit is contained in:
parent
f8a00617fa
commit
f5605d13e6
@ -774,10 +774,7 @@ def validate_instance_info_traits(node):
|
||||
if not all(isinstance(t, six.string_types) for t in instance_traits):
|
||||
invalid()
|
||||
|
||||
# TODO(mgoddard): Remove the obj_attr_is_set() call in Rocky
|
||||
# when all node objects will have a traits field.
|
||||
node_traits = (node.traits.get_trait_names()
|
||||
if node.obj_attr_is_set('traits') else [])
|
||||
node_traits = node.traits.get_trait_names()
|
||||
missing = set(instance_traits) - set(node_traits)
|
||||
if missing:
|
||||
err = (_("Cannot specify instance traits that are not also set on the "
|
||||
|
@ -1814,11 +1814,3 @@ class ValidateInstanceInfoTraitsTestCase(tests_base.TestCase):
|
||||
'Cannot specify instance traits that are not',
|
||||
conductor_utils.validate_instance_info_traits,
|
||||
self.node)
|
||||
|
||||
def test_validate_instance_info_traits_no_node_traits(self):
|
||||
self.node.instance_info['traits'] = ['trait1', 'trait2']
|
||||
delattr(self.node, 'traits')
|
||||
self.assertRaisesRegex(exception.InvalidParameterValue,
|
||||
'Cannot specify instance traits that are not',
|
||||
conductor_utils.validate_instance_info_traits,
|
||||
self.node)
|
||||
|
Loading…
Reference in New Issue
Block a user