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

Updates graph-pipeline script and modifies install script to copy pipeline script in /usr/local/bin

parent a1c2eee0
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ read query_period db_name results_measurement <<< ${fields} ...@@ -37,6 +37,7 @@ read query_period db_name results_measurement <<< ${fields}
JSON_CONFIG=$(echo ${JSON_CONFIG} | jq 'del(.query_period, .results_measurement_name)') JSON_CONFIG=$(echo ${JSON_CONFIG} | jq 'del(.query_period, .results_measurement_name)')
# TODO this shouldn't be in the script maybe move it to the clmc isntall script
echo "Building network subgraph..." echo "Building network subgraph..."
response=$(curl -s -X POST http://${CLMC_IP}/clmc-service/graph/network) response=$(curl -s -X POST http://${CLMC_IP}/clmc-service/graph/network)
echo ${response} echo ${response}
......
...@@ -35,7 +35,7 @@ sudo -u postgres bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"whoamidb\ ...@@ -35,7 +35,7 @@ sudo -u postgres bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE \"whoamidb\
# install virtualenvwrapper to manage python environments - and check # install virtualenvwrapper to manage python environments - and check
echo "----> Installing Python3, Pip3 and curl" echo "----> Installing Python3, Pip3 and curl"
apt-get install -y python3 python3-pip curl apt-get install -y python3 python3-pip curl jq
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 update-alternatives --install /usr/bin/python python /usr/bin/python3 10
echo "----> Installing virtualenv and wrapper" echo "----> Installing virtualenv and wrapper"
...@@ -161,3 +161,6 @@ done ...@@ -161,3 +161,6 @@ done
apt-get install nginx -y apt-get install nginx -y
cp ${REPO_ROOT}/scripts/clmc-service/nginx.conf /etc/nginx/nginx.conf cp ${REPO_ROOT}/scripts/clmc-service/nginx.conf /etc/nginx/nginx.conf
systemctl restart nginx # nginx is already started on installation, to read the new conf it needs to be restarted systemctl restart nginx # nginx is already started on installation, to read the new conf it needs to be restarted
# move the graph pipeline script
cp ${REPO_ROOT}/scripts/clmc-service/graph-pipeline.sh /usr/local/bin/
\ No newline at end of file
...@@ -529,7 +529,7 @@ class TestGraphAPI(object): ...@@ -529,7 +529,7 @@ class TestGraphAPI(object):
response = GraphAPI(request).execute_graph_pipeline() response = GraphAPI(request).execute_graph_pipeline()
assert response == {"uuid": uuid_mock.return_value, "database": "test_sfc"} assert response == {"uuid": uuid_mock.return_value, "database": "test_sfc"}
popen_mock.assert_called_once_with(["./graph_pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request popen_mock.assert_called_once_with(["graph-pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request
pid_property_mock.assert_called_once_with() # assert that the process ID attribute was called and saved pid_property_mock.assert_called_once_with() # assert that the process ID attribute was called and saved
returncode_property_mock.assert_called_once_with() # assert that the process return code attribute was called to check if the process has started successfully returncode_property_mock.assert_called_once_with() # assert that the process return code attribute was called to check if the process has started successfully
...@@ -544,7 +544,7 @@ class TestGraphAPI(object): ...@@ -544,7 +544,7 @@ class TestGraphAPI(object):
error_raised = True error_raised = True
assert error_raised, "Expecting a 500 HTTP error if the process terminated immediately after it was started" assert error_raised, "Expecting a 500 HTTP error if the process terminated immediately after it was started"
popen_mock.assert_called_with(["./graph_pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request popen_mock.assert_called_with(["graph-pipeline.sh", body]) # assert that the graph pipeline script is ran with the JSON config that was received in the request
pid_property_mock.assert_called_with() # assert that the process ID attribute was called and saved pid_property_mock.assert_called_with() # assert that the process ID attribute was called and saved
returncode_property_mock.assert_called_with() # assert that the process return code attribute was called to check if the process has started successfully returncode_property_mock.assert_called_with() # assert that the process return code attribute was called to check if the process has started successfully
......
...@@ -154,7 +154,11 @@ class GraphAPI(object): ...@@ -154,7 +154,11 @@ class GraphAPI(object):
query_to_execute = RTT_CYPHER_QUERY_TEMPLATE.format(startpoint_node_type, startpoint_node_label, endpoint_node_label, graph_id) query_to_execute = RTT_CYPHER_QUERY_TEMPLATE.format(startpoint_node_type, startpoint_node_label, endpoint_node_label, graph_id)
log.info("Executing cypher query: {0}".format(query_to_execute)) log.info("Executing cypher query: {0}".format(query_to_execute))
data = graph.run(query_to_execute).data() # returns a list of dictionaries, each dictionary represents a row in the result data = graph.run(query_to_execute).data() # returns a list of dictionaries, each dictionary represents a row in the result
result = data[0] try:
result = data[0]
except Exception as e:
log.error("Unexpected error occurred while executing RTT cypher query for graph with UUID {0} - {1}".format(graph_id, e))
raise HTTPBadRequest("The Neo4j cypher query didn't return a valid result for the temporal graph with ID {0}".format(graph_id))
sf_node = graph.match(nodes=(None, endpoint_node), r_type="realisedBy").first().start_node sf_node = graph.match(nodes=(None, endpoint_node), r_type="realisedBy").first().start_node
if sf_node is None: if sf_node is None:
...@@ -362,7 +366,7 @@ class GraphAPI(object): ...@@ -362,7 +366,7 @@ class GraphAPI(object):
request_uuid = str(uuid4()) request_uuid = str(uuid4())
sfc = json_queries["service_function_chain"] sfc = json_queries["service_function_chain"]
process = Popen(["./graph_pipeline.sh", body]) process = Popen(["graph-pipeline.sh", body])
process_pid = process.pid process_pid = process.pid
process_return_code = process.returncode process_return_code = process.returncode
......
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