diff --git a/src/service/clmcservice/graphapi/views.py b/src/service/clmcservice/graphapi/views.py index 4226f7beba0b0db119b68015f6f1ff322deb9185..7c2ecc950614f8f8475bdb479f43d52b4d54b03f 100644 --- a/src/service/clmcservice/graphapi/views.py +++ b/src/service/clmcservice/graphapi/views.py @@ -59,7 +59,8 @@ class GraphAPI(object): An API endpoint to build a temporal graph and store it in neo4j based on the posted JSON query document. :raises HTTPBadRequest: if request body is not a valid JSON with the queries per service function - :return: A JSON document containing the posted request body, along with meta data about the built graph (time range and uuid, which can then be reused for other API calls) + + :return: A JSON document containing metadata about the built graph (time range and uuid, which can then be reused for other API calls) """ try: @@ -91,7 +92,8 @@ class GraphAPI(object): """ An API endpoint to delete a temporal graph associated with a uuid generated by the CLMC service. - :return: A JSON document containing the UUID of the deleted subgraph + :return: A JSON document containing the number of deleted nodes. + :raises HTTPNotFound: if the request is not associated with any subgraph """ @@ -110,6 +112,7 @@ class GraphAPI(object): An API endpoint to run the round trip time cypher query over the graph associated with a given request ID. :return: A JSON response with a list of forward latencies, reverse latencies and SF endpoint response time. + :raises HTTPBadRequest: if the request URL doesn't contain the required URL query parameters :raises HTTPNotFound: if the request is not associated with any subgraph or the compute node / endpoint node doesn't exist """ @@ -213,7 +216,7 @@ class GraphAPI(object): """ An API endpoint to build/update the network topology in the neo4j graph. - :return: A JSON response with the number of switches and clusters that were built. + :return: A JSON response with the number of switches, clusters and ues that were built. """ graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db @@ -326,7 +329,7 @@ class GraphAPI(object): """ An API endpoint to delete the network topology in the neo4j graph. - :return: A JSON response with the number of switches and clusters that were deleted. + :return: A JSON response with the number of switches, clusters and ues that were deleted. """ graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db @@ -337,6 +340,11 @@ class GraphAPI(object): @view_config(route_name='graph_execute_pipeline', request_method='POST') def execute_graph_pipeline(self): + """ + An API endpoint to execute the graph pipeline script as a background process. + + :return: A JSON response with the database name and request's uuid. + """ try: body = self.request.body.decode(self.request.charset) @@ -344,11 +352,14 @@ class GraphAPI(object): except AssertionError as e: raise HTTPBadRequest("Bad request content: {0}".format(e.args)) - graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) influx_client = InfluxDBClient(host=self.request.registry.settings['influx_host'], port=self.request.registry.settings['influx_port'], timeout=10) database_name = json_queries["service_function_chain"] if database_name not in [db["name"] for db in influx_client.get_list_database()]: raise HTTPBadRequest("Database for service function chain {0} not found.".format(database_name)) - return json_queries + request_uuid = str(uuid4()) + + # TODO start a background process running the pipeline script + + return {"database": database_name, "uuid": request_uuid}