X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fhttpserver.py;h=f9cbb9b47bb5365cd9cf5cbd93452bc00cccf500;hb=5461675ac6705ee92916ed741da1914bd2162482;hp=d6dc0c7abd17d9b28925dae58798b911f7fae957;hpb=6ddeded5129e36c83d91374265ac31eb5a355a42;p=osm%2FRO.git diff --git a/osm_ro/httpserver.py b/osm_ro/httpserver.py index d6dc0c7a..f9cbb9b4 100644 --- a/osm_ro/httpserver.py +++ b/osm_ro/httpserver.py @@ -43,7 +43,7 @@ from openmano_schemas import vnfd_schema_v01, vnfd_schema_v02, \ tenant_schema, tenant_edit_schema,\ datacenter_schema, datacenter_edit_schema, datacenter_action_schema, datacenter_associate_schema,\ object_schema, netmap_new_schema, netmap_edit_schema, sdn_controller_schema, sdn_controller_edit_schema, \ - sdn_port_mapping_schema + sdn_port_mapping_schema, sdn_external_port_schema import nfvo import utils @@ -915,6 +915,33 @@ def http_deassociate_datacenters(tenant_id, datacenter_id): logger.error("Unexpected exception: ", exc_info=True) bottle.abort(HTTP_Internal_Server_Error, type(e).__name__ + ": " + str(e)) +@bottle.route(url_base + '//vim//network//attach', method='POST') +def http_post_vim_net_sdn_attach(tenant_id, datacenter_id, network_id): + logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) + http_content, _ = format_in(sdn_external_port_schema) + try: + data = nfvo.vim_net_sdn_attach(mydb, tenant_id, datacenter_id, network_id, http_content) + return format_out(data) + except (nfvo.NfvoException, db_base_Exception) as e: + logger.error("http_post_vim_net_sdn_attach error {}: {}".format(e.http_code, str(e))) + bottle.abort(e.http_code, str(e)) + except Exception as e: + logger.error("Unexpected exception: ", exc_info=True) + bottle.abort(HTTP_Internal_Server_Error, type(e).__name__ + ": " + str(e)) + +@bottle.route(url_base + '//vim//network//detach', method='DELETE') +@bottle.route(url_base + '//vim//network//detach/', method='DELETE') +def http_delete_vim_net_sdn_detach(tenant_id, datacenter_id, network_id, port_id=None): + logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) + try: + data = nfvo.vim_net_sdn_detach(mydb, tenant_id, datacenter_id, network_id, port_id) + return format_out(data) + except (nfvo.NfvoException, db_base_Exception) as e: + logger.error("http_delete_vim_net_sdn_detach error {}: {}".format(e.http_code, str(e))) + bottle.abort(e.http_code, str(e)) + except Exception as e: + logger.error("Unexpected exception: ", exc_info=True) + bottle.abort(HTTP_Internal_Server_Error, type(e).__name__ + ": " + str(e)) @bottle.route(url_base + '//vim//', method='GET') @bottle.route(url_base + '//vim///', method='GET') @@ -1349,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)))