summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/topology_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/topology_template.py')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/topology_template.py29
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)