X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fhttpserver.py;h=381016c602d8c0e1cdc102c05422b927ecbbef84;hb=7f426e900d00a76c3d583839f299982bbaf4c317;hp=b04326789085597c2a927f6ca74fba8240941cd0;hpb=d2b560beb317500d1f9a3d67068c02fba29d8670;p=osm%2FRO.git diff --git a/osm_ro/httpserver.py b/osm_ro/httpserver.py index b0432678..381016c6 100644 --- a/osm_ro/httpserver.py +++ b/osm_ro/httpserver.py @@ -1088,15 +1088,13 @@ def http_get_vnfs(tenant_id): nfvo.check_tenant(mydb, tenant_id) select_,where_,limit_ = filter_query_string(bottle.request.query, None, ('uuid', 'name', 'osm_id', 'description', 'public', "tenant_id", "created_at") ) - where_or = {} if tenant_id != "any": - where_or["tenant_id"] = tenant_id - where_or["public"] = True - vnfs = mydb.get_rows(FROM='vnfs', SELECT=select_,WHERE=where_,WHERE_OR=where_or, WHERE_AND_OR="AND",LIMIT=limit_) - #change_keys_http2db(content, http2db_vnf, reverse=True) + where_["OR"]={"tenant_id": tenant_id, "public": True} + vnfs = mydb.get_rows(FROM='vnfs', SELECT=select_, WHERE=where_, LIMIT=limit_) + # change_keys_http2db(content, http2db_vnf, reverse=True) utils.convert_str2boolean(vnfs, ('public',)) convert_datetime2str(vnfs) - data={'vnfs' : vnfs} + data={'vnfs': vnfs} return format_out(data) except bottle.HTTPError: raise @@ -1398,11 +1396,9 @@ def http_get_scenarios(tenant_id): #obtain data s,w,l=filter_query_string(bottle.request.query, None, ('uuid', 'name', 'osm_id', 'description', 'tenant_id', 'created_at', 'public')) - where_or={} if tenant_id != "any": - where_or["tenant_id"] = tenant_id - where_or["public"] = True - scenarios = mydb.get_rows(SELECT=s, WHERE=w, WHERE_OR=where_or, WHERE_AND_OR="AND", LIMIT=l, FROM='scenarios') + w["OR"] = {"tenant_id": tenant_id, "public": True} + scenarios = mydb.get_rows(SELECT=s, WHERE=w, LIMIT=l, FROM='scenarios') convert_datetime2str(scenarios) utils.convert_str2boolean(scenarios, ('public',) ) data={'scenarios':scenarios} @@ -1543,19 +1539,15 @@ def http_get_instance_id(tenant_id, instance_id): '''get instances details, can use both uuid or name''' logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) try: + #check valid tenant_id if tenant_id != "any": nfvo.check_tenant(mydb, tenant_id) if tenant_id == "any": tenant_id = None - #obtain data (first time is only to check that the instance exists) - instance_dict = mydb.get_instance_scenario(instance_id, tenant_id, verbose=True) - try: - 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 - instance = mydb.get_instance_scenario(instance_id, tenant_id) + + instance = nfvo.get_instance_id(mydb, tenant_id, instance_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", ()):