X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fhttpserver.py;fp=osm_ro%2Fhttpserver.py;h=d77846c8d161573a959ef7c5175fd75cb00a875e;hb=868220c566cfd302a38f9a45a75f4dbd4ebbf395;hp=66b744a129a6926cd6c8ef9e4ea7c02bc48f78bb;hpb=3a27977838f8da5f4ddbe061dc7ca95cf87a9a7b;p=osm%2FRO.git diff --git a/osm_ro/httpserver.py b/osm_ro/httpserver.py index 66b744a1..d77846c8 100644 --- a/osm_ro/httpserver.py +++ b/osm_ro/httpserver.py @@ -1478,7 +1478,12 @@ def http_delete_instance_id(tenant_id, instance_id): @bottle.route(url_base + '//instances//action', method='POST') def http_post_instance_scenario_action(tenant_id, instance_id): - '''take an action over a scenario instance''' + """ + take an action over a scenario instance + :param tenant_id: tenant where user belongs to + :param instance_id: instance indentity + :return: + """ logger.debug('FROM %s %s %s', bottle.request.remote_addr, bottle.request.method, bottle.request.url) # parse input data http_content, _ = format_in(instance_scenario_action_schema) @@ -1505,6 +1510,30 @@ def http_post_instance_scenario_action(tenant_id, instance_id): bottle.abort(HTTP_Internal_Server_Error, type(e).__name__ + ": " + str(e)) +@bottle.route(url_base + '//instances//action', method='GET') +@bottle.route(url_base + '//instances//action/', method='GET') +def http_get_instance_scenario_action(tenant_id, instance_id, action_id=None): + """ + List the actions done over an instance, or the action details + :param tenant_id: tenant where user belongs to. Can be "any" to ignore + :param instance_id: instance id, can be "any" to get actions of all instances + :return: + """ + 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) + data = nfvo.instance_action_get(mydb, tenant_id, instance_id, action_id) + return format_out(data) + except (nfvo.NfvoException, db_base_Exception) as e: + logger.error("http_get_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) @bottle.error(401) @bottle.error(404)