provide only one vnf:vm IP address at NBI 30/2030/2
authortierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 13 Jul 2017 13:44:34 +0000 (15:44 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Fri, 14 Jul 2017 09:42:47 +0000 (11:42 +0200)
Change-Id: Id895f3674a1f01aa358ec49742da3d483adcc5f2
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_ro/httpserver.py
osm_ro/nfvo.py

index 94544f6..f9cbb9b 100644 (file)
@@ -1376,10 +1376,18 @@ def http_get_instance_id(tenant_id, instance_id):
             nfvo.refresh_instance(mydb, tenant_id, instance_dict)
         except (nfvo.NfvoException, db_base_Exception) as e:
             logger.warn("nfvo.refresh_instance couldn't refresh the status of the instance: %s" % str(e))
-        #obtain data with results upated
+        # obtain data with results upated
         instance = mydb.get_instance_scenario(instance_id, tenant_id)
+        # Workaround to SO, convert vnfs:vms:interfaces:ip_address from ";" separated list to report the first value
+        for vnf in instance.get("vnfs", ()):
+            for vm in vnf.get("vms", ()):
+                for iface in vm.get("interfaces", ()):
+                    if iface.get("ip_address"):
+                        index = iface["ip_address"].find(";")
+                        if index >= 0:
+                            iface["ip_address"] = iface["ip_address"][:index]
         convert_datetime2str(instance)
-        #print json.dumps(instance, indent=4)
+        # print json.dumps(instance, indent=4)
         return format_out(instance)
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_instance_id error {}: {}".format(e.http_code, str(e)))
index f542df6..a559941 100644 (file)
@@ -1923,6 +1923,7 @@ def get_vim_thread(mydb, tenant_id, datacenter_id_name=None, datacenter_tenant_i
     except db_base_Exception as e:
         raise NfvoException("{} {}".format(type(e).__name__ , str(e)), e.http_code)
 
+
 def get_datacenter_by_name_uuid(mydb, tenant_id, datacenter_id_name=None, **extra_filter):
     datacenter_id = None
     datacenter_name = None