Skip to content
Snippets Groups Projects
Commit d08e1359 authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Adds implementation for the response of the execute pipeline endpoint

parent 4d2f244c
No related branches found
No related tags found
No related merge requests found
......@@ -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}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment