Allow images without checksum in the VIM; fixed image lookup in Opesntack connector 91/891/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 9 Jan 2017 08:46:31 +0000 (09:46 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 10 Jan 2017 10:58:58 +0000 (11:58 +0100)
Change-Id: Iedacddf3b7b32df344bb800db535a85f0106d856
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
nfvo.py
vimconn_openstack.py

diff --git a/nfvo.py b/nfvo.py
index 279eb07..a127969 100644 (file)
--- a/nfvo.py
+++ b/nfvo.py
@@ -290,9 +290,10 @@ def create_or_use_image(mydb, vims, image_dict, rollback_list, only_create_at_vi
             if image_dict['location'] is not None:
                 image_vim_id = vim.get_image_id_from_path(image_dict['location'])
             else:
-                filter_dict={}
-                filter_dict['name']=image_dict['universal_name']
-                filter_dict['checksum']=image_dict['checksum']
+                filter_dict = {}
+                filter_dict['name'] = image_dict['universal_name']
+                if image_dict.get('checksum') != None:
+                    filter_dict['checksum'] = image_dict['checksum']
                 #logger.debug('>>>>>>>> Filter dict: %s', str(filter_dict))
                 vim_images = vim.get_image_list(filter_dict)
                 if len(vim_images) > 1:
@@ -321,7 +322,7 @@ def create_or_use_image(mydb, vims, image_dict, rollback_list, only_create_at_vi
                 raise
             logger.warn("Error contacting VIM to know if the image exists at VIM: %s", str(e))
             image_vim_id = None
-            continue    
+            continue
         #if we reach here, the image has been created or existed
         if len(image_db)==0:
             #add new vim_id at datacenters_images
@@ -1761,6 +1762,7 @@ def create_instance(mydb, tenant_id, instance_dict):
                     myvims[d] = v
                     datacenter2tenant[d] = v['config']['datacenter_tenant_id']
                 scenario_vnf["datacenter"] = vnf_instance_desc["datacenter"]
+
     #0.1 parse cloud-config parameters
         cloud_config = scenarioDict.get("cloud-config", {})
         if instance_dict.get("cloud-config"):
index addee3a..2607e3f 100644 (file)
@@ -652,7 +652,7 @@ class vimconnector(vimconn.vimconnector):
             filtered_list = []
             for image in image_list:
                 image_dict=self.glance.images.get(image.id)
-                if filter_dict.get('checksum') == None or image_dict['checksum']==filter_dict.get('checksum'):
+                if 'checksum' in filter_dict and image_dict['checksum']==filter_dict.get('checksum'):
                     filtered_list.append(image)
             return filtered_list
         except (ksExceptions.ClientException, nvExceptions.ClientException, gl1Exceptions.CommunicationError, ConnectionError) as e: