X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=httpserver.py;h=edf1e8d9183e45ce8360a34ba43900bf091dd529;hb=refs%2Fchanges%2F17%2F1317%2F3;hp=e35daf0012779b193035a2bf25dfc08f05ddda35;hpb=7bbf50e0ee85e14bca8db01694fbfb3322619ee7;p=osm%2Fopenvim.git diff --git a/httpserver.py b/httpserver.py index e35daf0..edf1e8d 100644 --- a/httpserver.py +++ b/httpserver.py @@ -1624,11 +1624,7 @@ def http_post_server_id(tenant_id): try: my.ovim.net_update_ofc_thread(net_id) except ovim.ovimException as e: - raise ovim.ovimException("http_post_servers, Error updating network with id '{}', '{}'". - format(net_id, str(e)), HTTP_Internal_Server_Error) - except Exception as e: - raise ovim.ovimException("http_post_servers, Error updating network with id '{}', '{}'". - format(net_id, str(e)), HTTP_Internal_Server_Error) + my.logger.error("http_post_servers, Error updating network with id '{}', '{}'".format(net_id, str(e))) # look for dhcp ip address r2, c2 = my.db.get_table(FROM="ports", SELECT=["mac", "ip_address", "net_id"], WHERE={"instance_id": new_instance}) @@ -1796,7 +1792,8 @@ def http_server_action(server_id, tenant_id, action): return http_get_image_id(tenant_id, image_uuid) #Update DB only for CREATING or DELETING status - data={'result' : 'in process'} + data={'result' : 'deleting in process'} + warn_text="" if new_status != None and new_status == 'DELETING': nets=[] ports_to_free=[] @@ -1808,20 +1805,14 @@ def http_server_action(server_id, tenant_id, action): for port in ports_to_free: r1,c1 = config_dic['host_threads'][ server['host_id'] ].insert_task( 'restore-iface',*port ) if r1 < 0: - print ' http_post_server_action error at server deletion ERROR resore-iface !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + c1 - data={'result' : 'deleting in process, but ifaces cannot be restored!!!!!'} + my.logger.error("http_post_server_action server deletion ERROR at resore-iface!!!! " + c1) + warn_text += "; Error iface '{}' cannot be restored '{}'".format(str(port), str(e)) for net_id in nets: try: my.ovim.net_update_ofc_thread(net_id) except ovim.ovimException as e: - raise ovim.ovimException("http_post_servers, Error updating network with id '{}', '{}'". - format(net_id, str(e)), HTTP_Internal_Server_Error) - except Exception as e: - raise ovim.ovimException("http_post_server_action error at server deletion " - "ERROR UPDATING NET '{}', '{}'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!". - format(net_id, str(e)), HTTP_Internal_Server_Error) - - data = {'result': 'deleting in process, but openflow rules cannot be deleted!!!!!'} + my.logger.error("http_server_action, Error updating network with id '{}', '{}'".format(net_id, str(e))) + warn_text += "; Error openflow rules of network '{}' cannot be restore '{}'".format(net_id, str (e)) # look for dhcp ip address if r2 >0 and config_dic.get("dhcp_server"): @@ -1840,7 +1831,7 @@ def http_server_action(server_id, tenant_id, action): delete_dhcp_ovs_bridge(vlan, net_id) delete_mac_dhcp(vm_ip, vlan, mac) config_dic['host_threads'][server['host_id']].insert_task('del-ovs-port', vlan, net_id) - return format_out(data) + return format_out(data + warn_text) @@ -2196,9 +2187,9 @@ def http_put_openflow_id(network_id): data = {'result': str(result) + " nets updates"} return format_out(data) - +@bottle.route(url_base + '/networks/clear/openflow/', method='DELETE') @bottle.route(url_base + '/networks/clear/openflow', method='DELETE') -def http_clear_openflow_rules(): +def http_clear_openflow_rules(ofc_id=None): """ To make actions over the net. The action is to delete ALL openflow rules :return: @@ -2208,7 +2199,7 @@ def http_clear_openflow_rules(): if not my.admin: bottle.abort(HTTP_Unauthorized, "Needed admin privileges") try: - my.ovim.delete_openflow_rules() + my.ovim.delete_openflow_rules(ofc_id) except ovim.ovimException as e: my.logger.error(str(e), exc_info=True) bottle.abort(e.http_code, str(e)) @@ -2219,16 +2210,25 @@ def http_clear_openflow_rules(): data = {'result': " Clearing openflow rules in process"} return format_out(data) - +@bottle.route(url_base + '/networks/openflow/ports/', method='GET') @bottle.route(url_base + '/networks/openflow/ports', method='GET') -def http_get_openflow_ports(): +def http_get_openflow_ports(ofc_id=None): """ Obtain switch ports names of openflow controller :return: """ my = config_dic['http_threads'][threading.current_thread().name] - ports = my.ovim.get_openflow_ports() - data = {'ports': ports} + + try: + ports = my.ovim.get_openflow_ports(ofc_id) + data = {'ports': ports} + except ovim.ovimException as e: + my.logger.error(str(e), exc_info=True) + bottle.abort(e.http_code, str(e)) + except Exception as e: + my.logger.error(str(e), exc_info=True) + bottle.abort(HTTP_Bad_Request, str(e)) + return format_out(data) # # PORTS @@ -2356,7 +2356,7 @@ def http_delete_port_id(port_id): @bottle.route(url_base + '/openflow/mapping', method='POST') def http_of_port_mapping(): """ - Insert a tenant into the database. + Create new compute port mapping entry :return: """ my = config_dic['http_threads'][threading.current_thread().name] @@ -2384,7 +2384,7 @@ def http_of_port_mapping(): @bottle.route(url_base + '/openflow/mapping', method='GET') def get_of_port_mapping(): """ - Insert a tenant into the database. + Get compute port mapping :return: """ my = config_dic['http_threads'][threading.current_thread().name]