Judge volume node is error when translate compute node 83/18983/1
authorshangxdy <shang.xiaodong@zte.com.cn>
Thu, 18 Aug 2016 18:02:46 +0000 (02:02 +0800)
committershangxdy <shang.xiaodong@zte.com.cn>
Thu, 18 Aug 2016 18:02:46 +0000 (02:02 +0800)
Currently, when translate a compute node in heat-translator, code is
below:
                 for requires in requirements:
                        for value in requires.values():
                            if isinstance(value, dict):
                                for node_name in value.values():
                                    for n in self.nodetemplates:
                                        if n.name == node_name:
                                            volume_name = node_name
                                            break
                            else:  # unreachable code !
                                for n in self.nodetemplates:
                                    if n.name == node_name:
                                        volume_name = node_name
                                        break
  It's error in nfv tosca because there are more than one
requirements, So the unreachable code will reach.

Notes: the fix will submit to Openstack community.

JIRA:PARSER-92

Change-Id: Ife9c0d28ebe236c04d9d2c02f0025cf774bf6208
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
tosca2heat/heat-translator/translator/hot/translate_node_templates.py

index d8e7e48..f32d42b 100644 (file)
@@ -195,12 +195,16 @@ class TranslateNodeTemplates(object):
                             if isinstance(value, dict):
                                 for node_name in value.values():
                                     for n in self.nodetemplates:
-                                        if n.name == node_name:
+                                        if n.name == node_name and \
+                                            n.is_derived_from(
+                                                "tosca.nodes.BlockStorage"):
                                             volume_name = node_name
                                             break
                             else:  # unreachable code !
                                 for n in self.nodetemplates:
-                                    if n.name == node_name:
+                                    if n.name == value and \
+                                        n.is_derived_from(
+                                            "tosca.nodes.BlockStorage"):
                                         volume_name = node_name
                                         break