summaryrefslogtreecommitdiffstats
path: root/tosca2heat
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2016-08-04 03:05:47 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2016-08-08 17:46:34 +0800
commiteb5eb37bbbe0e97ddc8a0f2943943e1cabaa0cd1 (patch)
tree29f3a1d47da8e5ac4f71f1387b19424ccea38760 /tosca2heat
parent12d7916e7d1e8047f4109c66616665b9f5011921 (diff)
Service template with substitution mapping definition can deployed
standalone According to specification of http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/TOSCA-Simple-Profile-YAML-v1.0.html,the two main use cases: 1. No matter whether or not the service template has substitution mapping definition,it can be deployed standalone; 2. Also can be imported and used as nested service template substituted a node template with substitution mapping definition; 3. substitution mapping will expose node_type,may expose capabilities and requirements. JIRA:PARSER-78 Change-Id: I81ac940545f946925f6aa96a1b2ca0ccc9bbb076 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/substitution_mappings.py12
-rw-r--r--tosca2heat/tosca-parser/toscaparser/topology_template.py2
2 files changed, 9 insertions, 5 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py b/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py
index 20ec947..7fdce24 100644
--- a/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py
+++ b/tosca2heat/tosca-parser/toscaparser/substitution_mappings.py
@@ -106,7 +106,8 @@ class Substitution_mappings(object):
# The inputs in service template which defines substutition mappings
# must be in properties of node template wchich be mapped.
inputs_names = list(self.sub_mapped_node_template
- .get_properties().keys())
+ .get_properties().keys()
+ if self.sub_mapped_node_template else [])
for name in inputs_names:
if name not in [input.name for input in self.inputs]:
ExceptionCollector.appendException(
@@ -118,7 +119,8 @@ class Substitution_mappings(object):
# The capabilites must be in node template wchich be mapped.
tpls_capabilities = self.sub_mapping_def.get(self.CAPABILITIES)
- node_capabiliteys = self.sub_mapped_node_template.get_capabilities()
+ node_capabiliteys = self.sub_mapped_node_template.get_capabilities() \
+ if self.sub_mapped_node_template else None
for cap in node_capabiliteys.keys() if node_capabiliteys else []:
if (tpls_capabilities and
cap not in list(tpls_capabilities.keys())):
@@ -132,7 +134,8 @@ class Substitution_mappings(object):
# The requirements must be in node template wchich be mapped.
tpls_requirements = self.sub_mapping_def.get(self.REQUIREMENTS)
- node_requirements = self.sub_mapped_node_template.requirements
+ node_requirements = self.sub_mapped_node_template.requirements \
+ if self.sub_mapped_node_template else None
for req in node_requirements if node_requirements else []:
if (tpls_requirements and
req not in list(tpls_requirements.keys())):
@@ -146,7 +149,8 @@ class Substitution_mappings(object):
pass
# The outputs in service template which defines substutition mappings
# must be in atrributes of node template wchich be mapped.
- # outputs_names = self.sub_mapped_node_template.get_properties().keys()
+ # outputs_names = self.sub_mapped_node_template.get_properties().
+ # keys() if self.sub_mapped_node_template else None
# for name in outputs_names:
# if name not in [output.name for input in self.outputs]:
# ExceptionCollector.appendException(
diff --git a/tosca2heat/tosca-parser/toscaparser/topology_template.py b/tosca2heat/tosca-parser/toscaparser/topology_template.py
index 4039257..0407653 100644
--- a/tosca2heat/tosca-parser/toscaparser/topology_template.py
+++ b/tosca2heat/tosca-parser/toscaparser/topology_template.py
@@ -110,7 +110,7 @@ class TopologyTemplate(object):
def _substitution_mappings(self):
tpl_substitution_mapping = self._tpl_substitution_mappings()
- if tpl_substitution_mapping and self.sub_mapped_node_template:
+ if tpl_substitution_mapping:
return Substitution_mappings(tpl_substitution_mapping,
self.nodetemplates,
self.inputs,