Fix parser test bug with functest in real env. 33/18733/1
authorshangxdy <shang.xiaodong@zte.com.cn>
Tue, 16 Aug 2016 11:48:25 +0000 (19:48 +0800)
committershangxdy <shang.xiaodong@zte.com.cn>
Tue, 16 Aug 2016 11:48:25 +0000 (19:48 +0800)
Traceback (most recent call last):
  File "/usr/local/bin/heat-translator", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/translator/shell.py",
line 225, in main
    TranslatorShell().main(args)
  File "/usr/local/lib/python2.7/dist-packages/translator/shell.py",
line 121, in main
    parsed_params, a_file, deploy)
  File "/usr/local/lib/python2.7/dist-packages/translator/shell.py",
line 168, in _translate
    output = translator.translate()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca_translator.py",
line 42, in translate
    self.hot_template.resources = self.node_translator.translate()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/translate_node_templates.py",
line 159, in translate
    return self._translate_nodetemplates()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/translate_node_templates.py",
line 302, in _translate_nodetemplates
    self._recursive_handle_properties(resource)
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/translate_node_templates.py",
line 173, in _recursive_handle_properties
    resource.handle_properties()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca/tosca_compute.py",
line 105, in handle_properties
    self.nodetemplate.get_capability('os'))
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca/tosca_compute.py",
line 134, in translate_compute_flavor_and_image
    image = self._best_image(os_cap_props)
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca/tosca_compute.py",
line 266, in _best_image
    if len(resp.keys()) > 0:
AttributeError: 'NoneType' object has no attribute 'keys'
Traceback (most recent call last):
  File "/usr/local/bin/heat-translator", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/translator/shell.py",
line 225, in main
    TranslatorShell().main(args)
  File "/usr/local/lib/python2.7/dist-packages/translator/shell.py",
line 121, in main
    parsed_params, a_file, deploy)
  File "/usr/local/lib/python2.7/dist-packages/translator/shell.py",
line 168, in _translate
    output = translator.translate()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca_translator.py",
line 42, in translate
    self.hot_template.resources = self.node_translator.translate()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/translate_node_templates.py",
line 159, in translate
    return self._translate_nodetemplates()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/translate_node_templates.py",
line 302, in _translate_nodetemplates
    self._recursive_handle_properties(resource)
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/translate_node_templates.py",
line 173, in _recursive_handle_properties
    resource.handle_properties()
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca/tosca_compute.py",
line 105, in handle_properties
    self.nodetemplate.get_capability('os'))
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca/tosca_compute.py",
line 134, in translate_compute_flavor_and_image
    image = self._best_image(os_cap_props)
  File
"/usr/local/lib/python2.7/dist-packages/translator/hot/tosca/tosca_compute.py",
line 266, in _best_image
    if len(resp.keys()) > 0:
AttributeError: 'NoneType' object has no attribute 'keys'
The request you have made requires authentication. (HTTP 401)
(Request-ID: req-027940ce-5a5f-4459-9d91-7e65329c4d13)
The request you have made requires authentication. (HTTP 401)
(Request-ID: req-32c378fb-6d3c-46c6-845e-a8dd50975acd)

JIRA:PARSER-89

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

index b8ad83c..45637ec 100644 (file)
@@ -263,7 +263,7 @@ class ToscaCompute(HotResource):
         images = IMAGES
         if translator.common.utils.check_for_env_variables():
             resp = self._populate_image_dict()
-            if len(resp.keys()) > 0:
+            if resp and len(resp.keys()) > 0:
                 images = resp
         match_all = images.keys()
         architecture = properties.get(self.ARCHITECTURE)