diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2016-07-21 20:02:51 +0800 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2016-07-29 22:03:30 +0800 |
commit | ed2f6006158e120159f4422bc626cc0d5fe5cecf (patch) | |
tree | 8b298fcc1fe52b6e993c600c5967f6ce072bed19 /tosca2heat/tosca-parser/toscaparser/topology_template.py | |
parent | 47821301accde5ecc0dc90be2048f479e5857672 (diff) |
tosca-parser support the semantic of substitution mapping
As a template designer,
I want to using node template substitution for model composition or
chaining subsystems.
So firstly tosca-paser should support the substitution mappings
analysis.
Change-Id: I44371795504415ba8cf5a15f7e1d046e3ff00ade
JIRA: PARSER-43
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/topology_template.py')
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/topology_template.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/topology_template.py b/tosca2heat/tosca-parser/toscaparser/topology_template.py index 6cf4f31..70bc7d6 100644 --- a/tosca2heat/tosca-parser/toscaparser/topology_template.py +++ b/tosca2heat/tosca-parser/toscaparser/topology_template.py @@ -22,6 +22,7 @@ from toscaparser.parameters import Input from toscaparser.parameters import Output from toscaparser.policy import Policy from toscaparser.relationship_template import RelationshipTemplate +from toscaparser.substitution_mappings import Substitution_mappings from toscaparser.tpl_relationship_graph import ToscaGraph from toscaparser.utils.gettextutils import _ @@ -41,8 +42,10 @@ class TopologyTemplate(object): '''Load the template data.''' def __init__(self, template, custom_defs, - rel_types=None, parsed_params=None): + rel_types=None, parsed_params=None, + submaped_node_template=None): self.tpl = template + self.submaped_node_template = submaped_node_template if self.tpl: self.custom_defs = custom_defs self.rel_types = rel_types @@ -106,7 +109,14 @@ class TopologyTemplate(object): return outputs def _substitution_mappings(self): - pass + tpl_substitution_mapping = self._tpl_substitution_mappings() + if tpl_substitution_mapping and self.submaped_node_template: + return Substitution_mappings(tpl_substitution_mapping, + self.nodetemplates, + self.inputs, + self.outputs, + self.submaped_node_template, + self.custom_defs) def _policies(self): policies = [] @@ -178,13 +188,16 @@ class TopologyTemplate(object): # topology template can act like node template # it is exposed by substitution_mappings. def nodetype(self): - pass + return (self.substitution_mappings.node_type + if self.substitution_mappings else None) def capabilities(self): - pass + return (self.substitution_mappings.capabilities + if self.substitution_mappings else None) def requirements(self): - pass + return (self.substitution_mappings.requirements + if self.substitution_mappings else None) def _tpl_description(self): description = self.tpl.get(DESCRIPTION) @@ -279,3 +292,9 @@ class TopologyTemplate(object): func = functions.get_function(self, self.outputs, output.value) if isinstance(func, functions.GetAttribute): output.attrs[output.VALUE] = func + + @classmethod + def get_submaped_node_type(cls, topo_tpl): + if topo_tpl and isinstance(topo_tpl, dict): + submap_tpl = topo_tpl.get(SUBSTITUION_MAPPINGS) + return Substitution_mappings.get_node_type(submap_tpl) |