Merge "v0.4.61 fixed 37 Deploying multisite get properly the information from sites...
[osm/RO.git] / httpserver.py
index d9d6cc8..cd40882 100644 (file)
@@ -321,6 +321,10 @@ def http_get_tenants():
     except db_base_Exception as e:
         logger.error("http_get_tenants 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 + '/tenants/<tenant_id>', method='GET')
 def http_get_tenant_id(tenant_id):
@@ -336,6 +340,10 @@ def http_get_tenant_id(tenant_id):
     except db_base_Exception as e:
         logger.error("http_get_tenant_id 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 + '/tenants', method='POST')
 def http_post_tenants():
@@ -352,6 +360,10 @@ def http_post_tenants():
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_tenants 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 + '/tenants/<tenant_id>', method='PUT')
 def http_edit_tenant_id(tenant_id):
@@ -374,6 +386,10 @@ def http_edit_tenant_id(tenant_id):
     except db_base_Exception as e:
         logger.error("http_edit_tenant_id 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 + '/tenants/<tenant_id>', method='DELETE')
 def http_delete_tenant_id(tenant_id):
@@ -385,7 +401,10 @@ def http_delete_tenant_id(tenant_id):
     except db_base_Exception as e:
         logger.error("http_delete_tenant_id 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 + '/<tenant_id>/datacenters', method='GET')
 def http_get_datacenters(tenant_id):
@@ -414,6 +433,10 @@ def http_get_datacenters(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_datacenters 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 + '/<tenant_id>/datacenters/<datacenter_id>', method='GET')
 def http_get_datacenter_id(tenant_id, datacenter_id):
@@ -467,6 +490,10 @@ def http_get_datacenter_id(tenant_id, datacenter_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_datacenter_id 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 + '/datacenters', method='POST')
 def http_post_datacenters():
@@ -483,6 +510,10 @@ def http_post_datacenters():
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_datacenters 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 + '/datacenters/<datacenter_id_name>', method='PUT')
 def http_edit_datacenter_id(datacenter_id_name):
@@ -500,6 +531,10 @@ def http_edit_datacenter_id(datacenter_id_name):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_edit_datacenter_id 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 + '/<tenant_id>/datacenters/<datacenter_id>/networks', method='GET')  #deprecated
 @bottle.route(url_base + '/<tenant_id>/datacenters/<datacenter_id>/netmaps', method='GET')
@@ -532,6 +567,10 @@ def http_getnetmap_datacenter_id(tenant_id, datacenter_id, netmap_id=None):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_getnetwork_datacenter_id 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 + '/<tenant_id>/datacenters/<datacenter_id>/netmaps', method='DELETE')
 @bottle.route(url_base + '/<tenant_id>/datacenters/<datacenter_id>/netmaps/<netmap_id>', method='DELETE')
@@ -558,6 +597,9 @@ def http_delnetmap_datacenter_id(tenant_id, datacenter_id, netmap_id=None):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_delnetmap_datacenter_id 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 + '/<tenant_id>/datacenters/<datacenter_id>/netmaps/upload', method='POST')
@@ -572,6 +614,10 @@ def http_uploadnetmap_datacenter_id(tenant_id, datacenter_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_uploadnetmap_datacenter_id 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 + '/<tenant_id>/datacenters/<datacenter_id>/netmaps', method='POST')
 def http_postnetmap_datacenter_id(tenant_id, datacenter_id):
@@ -592,6 +638,10 @@ def http_postnetmap_datacenter_id(tenant_id, datacenter_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_postnetmap_datacenter_id 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 + '/<tenant_id>/datacenters/<datacenter_id>/netmaps/<netmap_id>', method='PUT')
 def http_putnettmap_datacenter_id(tenant_id, datacenter_id, netmap_id):
@@ -610,6 +660,9 @@ def http_putnettmap_datacenter_id(tenant_id, datacenter_id, netmap_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_putnettmap_datacenter_id 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 + '/<tenant_id>/datacenters/<datacenter_id>/action', method='POST')
@@ -631,6 +684,9 @@ def http_action_datacenter_id(tenant_id, datacenter_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_action_datacenter_id 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 + '/datacenters/<datacenter_id>', method='DELETE')
@@ -644,6 +700,10 @@ def http_delete_datacenter_id( datacenter_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_delete_datacenter_id 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 + '/<tenant_id>/datacenters/<datacenter_id>', method='POST')
 def http_associate_datacenters(tenant_id, datacenter_id):
@@ -665,6 +725,10 @@ def http_associate_datacenters(tenant_id, datacenter_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_associate_datacenters 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 + '/<tenant_id>/datacenters/<datacenter_id>', method='DELETE')
 def http_deassociate_datacenters(tenant_id, datacenter_id):
@@ -676,6 +740,10 @@ def http_deassociate_datacenters(tenant_id, datacenter_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_deassociate_datacenters 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 + '/<tenant_id>/vim/<datacenter_id>/<item>', method='GET')
 @bottle.route(url_base + '/<tenant_id>/vim/<datacenter_id>/<item>/<name>', method='GET')
@@ -687,6 +755,10 @@ def http_get_vim_items(tenant_id, datacenter_id, item, name=None):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_vim_items 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 + '/<tenant_id>/vim/<datacenter_id>/<item>/<name>', method='DELETE')
 def http_del_vim_items(tenant_id, datacenter_id, item, name):
@@ -697,6 +769,11 @@ def http_del_vim_items(tenant_id, datacenter_id, item, name):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_del_vim_items 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 + '/<tenant_id>/vim/<datacenter_id>/<item>', method='POST')
 def http_post_vim_items(tenant_id, datacenter_id, item):
     logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
@@ -707,6 +784,10 @@ def http_post_vim_items(tenant_id, datacenter_id, item):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_vim_items 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 + '/<tenant_id>/vnfs', method='GET')
 def http_get_vnfs(tenant_id):
@@ -730,6 +811,10 @@ def http_get_vnfs(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_vnfs 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 + '/<tenant_id>/vnfs/<vnf_id>', method='GET')
 def http_get_vnf_id(tenant_id,vnf_id):
@@ -743,6 +828,10 @@ def http_get_vnf_id(tenant_id,vnf_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_vnf_id 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 + '/<tenant_id>/vnfs', method='POST')
 def http_post_vnfs(tenant_id):
@@ -766,6 +855,10 @@ def http_post_vnfs(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_vnfs 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 + '/<tenant_id>/vnfs/<vnf_id>', method='DELETE')
 def http_delete_vnf_id(tenant_id,vnf_id):
@@ -779,6 +872,10 @@ def http_delete_vnf_id(tenant_id,vnf_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_delete_vnf_id 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 + '/<tenant_id>/hosts/topology', method='GET')
 #@bottle.route(url_base + '/<tenant_id>/physicalview/Madrid-Alcantara', method='GET')
@@ -804,6 +901,9 @@ def http_get_hosts(tenant_id, datacenter):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_hosts 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 + '/<path:path>', method='OPTIONS')
@@ -836,6 +936,10 @@ def http_post_deploy(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_deploy 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 + '/<tenant_id>/topology/verify', method='POST')
 def http_post_verify(tenant_id):
@@ -873,6 +977,10 @@ def http_post_scenarios(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_scenarios 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 + '/<tenant_id>/scenarios/<scenario_id>/action', method='POST')
 def http_post_scenario_action(tenant_id, scenario_id):
@@ -911,6 +1019,10 @@ def http_post_scenario_action(tenant_id, scenario_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_scenario_action 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 + '/<tenant_id>/scenarios', method='GET')
 def http_get_scenarios(tenant_id):
@@ -935,6 +1047,10 @@ def http_get_scenarios(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_scenarios 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 + '/<tenant_id>/scenarios/<scenario_id>', method='GET')
 def http_get_scenario_id(tenant_id, scenario_id):
@@ -952,6 +1068,10 @@ def http_get_scenario_id(tenant_id, scenario_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_scenarios 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 + '/<tenant_id>/scenarios/<scenario_id>', method='DELETE')
 def http_delete_scenario_id(tenant_id, scenario_id):
@@ -967,6 +1087,9 @@ def http_delete_scenario_id(tenant_id, scenario_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_delete_scenario_id 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 + '/<tenant_id>/scenarios/<scenario_id>', method='PUT')
@@ -985,10 +1108,13 @@ def http_put_scenario_id(tenant_id, scenario_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_put_scenario_id 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 + '/<tenant_id>/instances', method='POST')
 def http_post_instances(tenant_id):
-    '''take an action over a scenario'''
+    '''create an instance-scenario'''
     logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url)
     try:
         #check valid tenant_id
@@ -1004,6 +1130,9 @@ def http_post_instances(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_instances 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))
 
 #
 # INSTANCES
@@ -1027,6 +1156,10 @@ def http_get_instances(tenant_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_instances 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 + '/<tenant_id>/instances/<instance_id>', method='GET')
 def http_get_instance_id(tenant_id, instance_id):
@@ -1052,6 +1185,10 @@ def http_get_instance_id(tenant_id, instance_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_get_instance_id 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 + '/<tenant_id>/instances/<instance_id>', method='DELETE')
 def http_delete_instance_id(tenant_id, instance_id):
@@ -1069,6 +1206,10 @@ def http_delete_instance_id(tenant_id, instance_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_delete_instance_id 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 + '/<tenant_id>/instances/<instance_id>/action', method='POST')
 def http_post_instance_scenario_action(tenant_id, instance_id):
@@ -1094,6 +1235,9 @@ def http_post_instance_scenario_action(tenant_id, instance_id):
     except (nfvo.NfvoException, db_base_Exception) as e:
         logger.error("http_post_instance_scenario_action 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.error(400)