Fix substitution mapping assigned value to nodetemplate 09/41709/2
authorshangxdy <shang.xiaodong@zte.com.cn>
Tue, 12 Sep 2017 14:27:15 +0000 (22:27 +0800)
committershangxdy <shang.xiaodong@zte.com.cn>
Tue, 12 Sep 2017 14:32:26 +0000 (22:32 +0800)
Currently the assignment mapped template value to nodetemplate is error,
and additionally debug_mode is not transfered to nested template. So the
patch will fix them.

JIRA: PARSER-155

Change-Id: I8c5801b00ae56b9ba2eb92a6f14357c2f5328718
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
tosca2heat/tosca-parser/toscaparser/shell.py
tosca2heat/tosca-parser/toscaparser/tosca_template.py

index ba9c28f..88c7473 100644 (file)
@@ -91,11 +91,8 @@ class ParserShell(object):
                                   no_required_paras_check=nrpv,
                                   debug_mode=debug_mode)
         except ValidationError as e:
-            msg = _('  ===== main service template ===== ')
-            log.error(msg)
             log.error(e.message)
             if debug_mode:
-                print(msg)
                 print(e.message)
             else:
                 raise e
index c9be9dd..30432af 100644 (file)
@@ -251,13 +251,11 @@ class ToscaTemplate(object):
                         nested_template = ToscaTemplate(
                             path=fname, parsed_params=parsed_params,
                             sub_mapped_node_template=nodetemplate,
-                            no_required_paras_check=nrpv)
+                            no_required_paras_check=nrpv,
+                            debug_mode=self.debug_mode)
                     except ValidationError as e:
-                        msg = _('  ===== nested service template ===== ')
-                        log.error(msg)
                         log.error(e.message)
                         if self.debug_mode:
-                            print(msg)
                             print(e.message)
                         else:
                             raise e
@@ -272,7 +270,7 @@ class ToscaTemplate(object):
                         self.nested_tosca_templates_with_topology.\
                             append(nested_template)
                         # Set the substitution toscatemplate for mapped node
-                        nodetemplate.sub_mapping_tosca_template = \
+                        nodetemplate.substitution_mapped = \
                             nested_template
 
     def _validate_field(self):
@@ -337,8 +335,15 @@ class ToscaTemplate(object):
             if not self.debug_mode:
                 raise exceptions
             else:
+                if self.sub_mapped_node_template:
+                    msg = _('======== nested service template ======== ')
+
+                else:
+                    msg = _('======== main service template ======== ')
+                print(msg)
                 print(exceptions.message)
-            log.error(exceptions.message)
+                log.error(msg)
+                log.error(exceptions.message)
         else:
             if self.input_path:
                 msg = (_('The input "%(path)s" successfully passed '