From c7491340551cdd9d757d63b4bbe79132506e386a Mon Sep 17 00:00:00 2001 From: shangxdy Date: Mon, 17 Jul 2017 17:40:59 +0800 Subject: Synchronize upstream version of 0.9 Synchronize heat-translator wiht upstream versionn of 0.9 JIRA: PARSER-128 Change-Id: I4d2c62a0e81119d5c0305e3ac052415a6d5acee3 Signed-off-by: shangxdy --- .../translator/hot/translate_node_templates.py | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'tosca2heat/heat-translator/translator/hot/translate_node_templates.py') diff --git a/tosca2heat/heat-translator/translator/hot/translate_node_templates.py b/tosca2heat/heat-translator/translator/hot/translate_node_templates.py index 1a1a4d7..78ab1c4 100644 --- a/tosca2heat/heat-translator/translator/hot/translate_node_templates.py +++ b/tosca2heat/heat-translator/translator/hot/translate_node_templates.py @@ -228,11 +228,11 @@ class TranslateNodeTemplates(object): # BlockStorage Attachment is a special case, # which doesn't match to Heat Resources 1 to 1. if base_type == "tosca.nodes.Compute": - volume_name = None requirements = node.requirements if requirements: # Find the name of associated BlockStorage node for requires in requirements: + volume_name = None for value in requires.values(): if isinstance(value, dict): for node_name in value.values(): @@ -250,11 +250,12 @@ class TranslateNodeTemplates(object): volume_name = node_name break - suffix = suffix + 1 - attachment_node = self._get_attachment_node( - node, suffix, volume_name) - if attachment_node: - self.hot_resources.append(attachment_node) + if volume_name: + suffix = suffix + 1 + attachment_node = self._get_attachment_node( + node, suffix, volume_name) + if attachment_node: + self.hot_resources.append(attachment_node) for i in self.tosca.inputs: if (i.name == 'key_name' and node.get_property_value('key_name') is None): @@ -269,8 +270,12 @@ class TranslateNodeTemplates(object): policy_type.type != 'tosca.policies.Scaling.Cluster': TOSCA_TO_HOT_TYPE[policy_type.type] = \ TOSCA_TO_HOT_TYPE['tosca.policies.Scaling'] - if not policy.is_derived_from('tosca.policies.Scaling') and \ - policy_type.type not in TOSCA_TO_HOT_TYPE: + if policy.is_derived_from('tosca.policies.Monitoring'): + TOSCA_TO_HOT_TYPE[policy_type.type] = \ + TOSCA_TO_HOT_TYPE['tosca.policies.Monitoring'] + if not policy.is_derived_from('tosca.policies.Monitoring') and \ + not policy.is_derived_from('tosca.policies.Scaling') and \ + policy_type.type not in TOSCA_TO_HOT_TYPE: raise UnsupportedTypeError(type=_('%s') % policy_type.type) elif policy_type.type == 'tosca.policies.Scaling.Cluster': self.hot_template_version = '2016-04-08' @@ -587,7 +592,8 @@ class TranslateNodeTemplates(object): for key_r, value_n in node.relationships.items(): if key_r.is_derived_from('tosca.relationships.AttachesTo'): if value_n.is_derived_from('tosca.nodes.BlockStorage'): - attach = True + if volume_name == value_n.name: + attach = True if attach: relationship_tpl = None for req in node.requirements: -- cgit 1.2.3-korg