Skip to content
Snippets Groups Projects
Commit d2e95b26 authored by Michael Boniface's avatar Michael Boniface
Browse files

Merge branch 'clmc-service' into 'integration'

CLMC version 2.0.4

See merge request FLAME/consortium/3rdparties/flame-clmc!62
parents 82314913 f3a9771b
No related branches found
No related tags found
No related merge requests found
...@@ -35,8 +35,8 @@ build:tests: ...@@ -35,8 +35,8 @@ build:tests:
- python setup.py sdist --dist-dir=$CI_PROJECT_DIR/build - python setup.py sdist --dist-dir=$CI_PROJECT_DIR/build
artifacts: artifacts:
paths: paths:
- build/clmctest-2.0.3.tar.gz - build/clmctest-2.0.4.tar.gz
- build/clmcservice-2.0.3.tar.gz - build/clmcservice-2.0.4.tar.gz
expire_in: 1 day expire_in: 1 day
test:all: test:all:
...@@ -50,8 +50,8 @@ test:all: ...@@ -50,8 +50,8 @@ test:all:
- echo "REPO_PASS=${REPO_PASS}" >> $CI_PROJECT_DIR/reporc - echo "REPO_PASS=${REPO_PASS}" >> $CI_PROJECT_DIR/reporc
- sudo scripts/test/fixture.sh create -f src/test/clmctest/rspec.json -r $CI_PROJECT_DIR -c all - sudo scripts/test/fixture.sh create -f src/test/clmctest/rspec.json -r $CI_PROJECT_DIR -c all
- sudo mkdir /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build - sudo mkdir /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build
- sudo cp build/clmctest-2.0.3.tar.gz /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build - sudo cp build/clmctest-2.0.4.tar.gz /var/lib/lxd/containers/test-runner/rootfs/opt/clmc/build
- sudo lxc exec test-runner -- pip3 install /opt/clmc/build/clmctest-2.0.3.tar.gz - sudo lxc exec test-runner -- pip3 install /opt/clmc/build/clmctest-2.0.4.tar.gz
- sudo lxc exec test-runner -- pytest -s --tb=short -rfp --pyargs clmctest - sudo lxc exec test-runner -- pytest -s --tb=short -rfp --pyargs clmctest
when: on_success when: on_success
......
...@@ -163,4 +163,5 @@ cp ${REPO_ROOT}/scripts/clmc-service/nginx.conf /etc/nginx/nginx.conf ...@@ -163,4 +163,5 @@ 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 # move the graph pipeline script
cp ${REPO_ROOT}/scripts/clmc-service/graph-pipeline.sh /usr/local/bin/ cp ${REPO_ROOT}/scripts/clmc-service/graph-pipeline.sh /usr/local/bin/
\ No newline at end of file chmod u+x /usr/local/bin/graph-pipeline.sh
\ No newline at end of file
__version__ = "2.0.3" __version__ = "2.0.4"
\ No newline at end of file \ No newline at end of file
...@@ -203,6 +203,9 @@ def graph_network_topology(): ...@@ -203,6 +203,9 @@ def graph_network_topology():
global links, switches, clusters global links, switches, clusters
graph = Graph(host="localhost", password="admin") graph = Graph(host="localhost", password="admin")
graph.node_cache.clear()
graph.relationship_cache.clear()
build_network_graph(graph, switches, links, clusters, ues) build_network_graph(graph, switches, links, clusters, ues)
yield yield
......
...@@ -73,7 +73,7 @@ class GraphAPI(object): ...@@ -73,7 +73,7 @@ class GraphAPI(object):
except AssertionError as e: except AssertionError as e:
raise HTTPBadRequest("Bad request content: {0}".format(e.args)) 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']) graph = self.get_graph_reference()
influx_client = InfluxDBClient(host=self.request.registry.settings['influx_host'], port=self.request.registry.settings['influx_port'], timeout=10) 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"] database_name = json_queries["service_function_chain"]
...@@ -102,7 +102,7 @@ class GraphAPI(object): ...@@ -102,7 +102,7 @@ class GraphAPI(object):
""" """
graph_id = self.request.matchdict['graph_id'] # get the UUID of the subgraph from the URL graph_id = self.request.matchdict['graph_id'] # get the UUID of the subgraph from the URL
graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db graph = self.get_graph_reference()
if graph.nodes.match("Reference", uuid=graph_id).first() is None: if graph.nodes.match("Reference", uuid=graph_id).first() is None:
raise HTTPNotFound("No subgraph found associated with the request ID {0}".format(graph_id)) raise HTTPNotFound("No subgraph found associated with the request ID {0}".format(graph_id))
...@@ -121,7 +121,7 @@ class GraphAPI(object): ...@@ -121,7 +121,7 @@ class GraphAPI(object):
""" """
sfc_id = self.request.matchdict['sfc_id'] # get the SFC identifier from the URL sfc_id = self.request.matchdict['sfc_id'] # get the SFC identifier from the URL
graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db graph = self.get_graph_reference()
# check if this SFC node exists # check if this SFC node exists
sfc_node = graph.nodes.match("ServiceFunctionChain", name=sfc_id).first() sfc_node = graph.nodes.match("ServiceFunctionChain", name=sfc_id).first()
...@@ -162,7 +162,7 @@ class GraphAPI(object): ...@@ -162,7 +162,7 @@ class GraphAPI(object):
startpoint_node_label = params["startpoint"] startpoint_node_label = params["startpoint"]
endpoint_node_label = params["endpoint"] endpoint_node_label = params["endpoint"]
graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db graph = self.get_graph_reference()
all_nodes = graph.nodes all_nodes = graph.nodes
...@@ -260,7 +260,7 @@ class GraphAPI(object): ...@@ -260,7 +260,7 @@ class GraphAPI(object):
:return: A JSON response with the number of switches, clusters and ues 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 graph = self.get_graph_reference()
sdn_controller_ip = self.request.registry.settings['sdn_controller_ip'] sdn_controller_ip = self.request.registry.settings['sdn_controller_ip']
sdn_controller_port = self.request.registry.settings['sdn_controller_port'] sdn_controller_port = self.request.registry.settings['sdn_controller_port']
...@@ -360,7 +360,7 @@ class GraphAPI(object): ...@@ -360,7 +360,7 @@ class GraphAPI(object):
:return: A JSON response with the number of switches, clusters and ues 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 graph = self.get_graph_reference()
deleted_switches, deleted_clusters, deleted_ues = delete_network_graph(graph) deleted_switches, deleted_clusters, deleted_ues = delete_network_graph(graph)
...@@ -388,7 +388,8 @@ class GraphAPI(object): ...@@ -388,7 +388,8 @@ class GraphAPI(object):
raise HTTPBadRequest("Database for service function chain {0} not found.".format(database_name)) raise HTTPBadRequest("Database for service function chain {0} not found.".format(database_name))
# get the list of UEs from the Neo4j graph - if no UEs are found, the network topology has not been built yet, so return bad request # get the list of UEs from the Neo4j graph - if no UEs are found, the network topology has not been built yet, so return bad request
graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) graph = self.get_graph_reference()
ue_nodes = graph.nodes.match("UserEquipment") ue_nodes = graph.nodes.match("UserEquipment")
ues_list = [ue_node["name"] for ue_node in ue_nodes] ues_list = [ue_node["name"] for ue_node in ue_nodes]
# return bad request for empty list of UEs # return bad request for empty list of UEs
...@@ -440,3 +441,19 @@ class GraphAPI(object): ...@@ -440,3 +441,19 @@ class GraphAPI(object):
MonitoringProcess.delete(request_id) MonitoringProcess.delete(request_id)
return response return response
def get_graph_reference(self):
"""
A utility function to get a Graph DB object reference and clear the cache of py2neo since it might lead to erroneous behaviour
:return: reference to the graph DB object
"""
graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password'])
# TODO we probably need to remove the caching functionality of py2neo and maintain our own version
# NOTE: make sure Py2neo caching is disabled!
graph.node_cache.clear()
graph.relationship_cache.clear()
return graph
__version__ = "2.0.3" __version__ = "2.0.4"
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment