Bugfix for the non managed exception produced when a non defined capability is used in a node template
Change-Id: Ib7303dc38aad1b317af310fb499d243e64aa2772 Related-Bug: 1591934
This commit is contained in:
@@ -180,7 +180,10 @@ class EntityTemplate(object):
|
||||
|
||||
def _validate_capabilities_properties(self, capabilities):
|
||||
for cap, props in capabilities.items():
|
||||
capabilitydef = self.get_capability(cap).definition
|
||||
capability = self.get_capability(cap)
|
||||
if not capability:
|
||||
continue
|
||||
capabilitydef = capability.definition
|
||||
self._common_validate_properties(capabilitydef,
|
||||
props[self.PROPERTIES])
|
||||
|
||||
|
||||
@@ -1500,3 +1500,21 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml
|
||||
self.assertRaises(exception.ValidationError, ToscaTemplate, tpl_path)
|
||||
exception.ExceptionCollector.assertExceptionMessage(
|
||||
ValueError, _('"two" is not an integer.'))
|
||||
|
||||
def test_invalid_capability(self):
|
||||
tpl_snippet = '''
|
||||
node_templates:
|
||||
server:
|
||||
type: tosca.nodes.Compute
|
||||
capabilities:
|
||||
oss:
|
||||
properties:
|
||||
architecture: x86_64
|
||||
'''
|
||||
tpl = (toscaparser.utils.yamlparser.simple_parse(tpl_snippet))
|
||||
err = self.assertRaises(exception.UnknownFieldError,
|
||||
TopologyTemplate, tpl, None)
|
||||
expectedmessage = _('"capabilities" of template "server" contains '
|
||||
'unknown field "oss". Refer to the definition '
|
||||
'to verify valid values.')
|
||||
self.assertEqual(expectedmessage, err.__str__())
|
||||
|
||||
Reference in New Issue
Block a user