Proper error message shown when no image could be found at VIM
[osm/RO.git] / nfvo.py
diff --git a/nfvo.py b/nfvo.py
index ba670c7..c8ef020 100644 (file)
--- a/nfvo.py
+++ b/nfvo.py
@@ -364,7 +364,8 @@ def create_or_use_image(mydb, vims, image_dict, rollback_list, only_create_at_vi
                     rollback_list.append({"where":"vim", "vim_id": vim_id, "what":"image","uuid":image_vim_id})
                     image_created="true"
                 else:
-                    raise vimconn.vimconnException("Cannot create image without location")
+                    #If we reach this point, then the image has image name, and optionally checksum, and could not be found
+                    raise vimconn.vimconnException(str(e))
             except vimconn.vimconnException as e:
                 if return_on_error:
                     logger.error("Error creating image at VIM '%s': %s", vim["name"], str(e))
@@ -547,6 +548,7 @@ def new_vnf(mydb, tenant_id, vnf_descriptor):
     # Step 1. Check the VNF descriptor
     check_vnf_descriptor(vnf_descriptor, vnf_descriptor_version=1)
     # Step 2. Check tenant exist
+    vims = {}
     if tenant_id != "any":
         check_tenant(mydb, tenant_id) 
         if "tenant_id" in vnf_descriptor["vnf"]:
@@ -556,9 +558,8 @@ def new_vnf(mydb, tenant_id, vnf_descriptor):
         else:
             vnf_descriptor['vnf']['tenant_id'] = tenant_id
         # Step 3. Get the URL of the VIM from the nfvo_tenant and the datacenter
-        vims = get_vim(mydb, tenant_id)
-    else:
-        vims={}
+        if global_config["auto_push_VNF_to_VIMs"]:
+            vims = get_vim(mydb, tenant_id)
 
     # Step 4. Review the descriptor and add missing  fields
     #print vnf_descriptor
@@ -681,6 +682,7 @@ def new_vnf_v02(mydb, tenant_id, vnf_descriptor):
     # Step 1. Check the VNF descriptor
     check_vnf_descriptor(vnf_descriptor, vnf_descriptor_version=2)
     # Step 2. Check tenant exist
+    vims = {}
     if tenant_id != "any":
         check_tenant(mydb, tenant_id) 
         if "tenant_id" in vnf_descriptor["vnf"]:
@@ -690,9 +692,8 @@ def new_vnf_v02(mydb, tenant_id, vnf_descriptor):
         else:
             vnf_descriptor['vnf']['tenant_id'] = tenant_id
         # Step 3. Get the URL of the VIM from the nfvo_tenant and the datacenter
-        vims = get_vim(mydb, tenant_id)
-    else:
-        vims={}
+        if global_config["auto_push_VNF_to_VIMs"]:
+            vims = get_vim(mydb, tenant_id)
 
     # Step 4. Review the descriptor and add missing  fields
     #print vnf_descriptor