Add exception info about get_explicit_relationship

Currently it's not convienent to debug about the
relationship between two nodetemplates, this patch
add more debug information when exception happends.

Change-Id: I91a6ed0cb6c9675d76f620c742c8546c457b239b
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
This commit is contained in:
shangxdy 2017-07-13 19:31:48 +08:00
parent 5c58a3cd85
commit 8d7519a717
2 changed files with 8 additions and 3 deletions

View File

@ -79,7 +79,9 @@ class NodeTemplate(EntityTemplate):
# TODO(spzala) implement look up once Glance meta data is available
# to find a matching TOSCA node using the TOSCA types
msg = _('Lookup by TOSCA types is not supported. '
'Requirement for "%s" can not be full-filled.') % self.name
'Requirement node "%(node)s" for "%(name)s"'
' can not be full-filled.') \
% {'node': node, 'name': self.name}
if (node in list(self.type_definition.TOSCA_DEF.keys())
or node in self.custom_def):
ExceptionCollector.appendException(NotImplementedError(msg))
@ -87,7 +89,9 @@ class NodeTemplate(EntityTemplate):
if node not in self.templates:
ExceptionCollector.appendException(
KeyError(_('Node template "%s" was not found.') % node))
KeyError(_('Node template "%(node)s" was not found'
' in "%(name)s".')
% {'node': node, 'name': self.name}))
return
related_tpl = NodeTemplate(node, self.templates, self.custom_def)

View File

@ -572,7 +572,8 @@ class ToscaTemplateTest(TestCase):
exception.ExceptionCollector.assertExceptionMessage(
exception.UnknownFieldError, err7_msg)
err8_msg = _('\'Node template "server1" was not found.\'')
err8_msg = _('\'Node template "server1" was not found in '
'"webserver".\'')
exception.ExceptionCollector.assertExceptionMessage(
KeyError, err8_msg)