From f57559639b53fbe41421eff5212248321e655b19 Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 13 Jul 2017 15:44:34 +0200 Subject: [PATCH] provide only one vnf:vm IP address at NBI Change-Id: Id895f3674a1f01aa358ec49742da3d483adcc5f2 Signed-off-by: tierno --- osm_ro/httpserver.py | 12 ++++++++++-- osm_ro/nfvo.py | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/osm_ro/httpserver.py b/osm_ro/httpserver.py index 94544f6b..f9cbb9b4 100644 --- a/osm_ro/httpserver.py +++ b/osm_ro/httpserver.py @@ -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))) diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index f542df63..a5599418 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -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 -- 2.25.1