diff --git a/src/service/clmcservice/__init__.py b/src/service/clmcservice/__init__.py index c35e2ec20a48d8440e215eef52b0375582b45b17..07f8d88205d7c256156b54ed8fd0a3f8f2ea91ef 100644 --- a/src/service/clmcservice/__init__.py +++ b/src/service/clmcservice/__init__.py @@ -24,7 +24,6 @@ # Python standard libs -from json import load from os.path import dirname, abspath import os @@ -54,10 +53,7 @@ def main(global_config, **settings): settings['influx_port'] = int(settings['influx_port']) # the influx port setting must be converted to integer instead of a string settings['kapacitor_port'] = int(settings['kapacitor_port']) # the kapacitor port setting must be converted to integer instead of a string - network_config_file_path = settings["network_configuration_path"] - with open(network_config_file_path) as f: - network = load(f) - settings["network_bandwidth"] = network["bandwidth"] + settings["network_bandwidth"] = 104857600 # TODO currently assumed fixed bandwidth across all links config = Configurator(settings=settings) diff --git a/src/service/clmcservice/graphapi/views.py b/src/service/clmcservice/graphapi/views.py index c3441afba313621425ba0512886e35d55164f34d..ca9e3a0ddf5868586e2497d3d9329d28ea0f68f5 100644 --- a/src/service/clmcservice/graphapi/views.py +++ b/src/service/clmcservice/graphapi/views.py @@ -25,12 +25,13 @@ from clmcservice.graphapi.utilities import validate_json_queries_body, validate_graph_url_params, \ build_network_graph, delete_network_graph, build_temporal_subgraph, delete_temporal_subgraph, validate_graph_rtt_params, RTT_CYPHER_QUERY_TEMPLATE -from uuid import uuid4 from influxdb import InfluxDBClient from py2neo import Graph from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound, HTTPServiceUnavailable, HTTPNotImplemented from pyramid.view import view_defaults, view_config from requests import exceptions, get +from uuid import uuid4 +from json import load import logging @@ -271,7 +272,16 @@ class GraphAPI(object): log.error("Unexpected error: {0}".format(msg)) raise HTTPNotImplemented("The SDN controller failed to return a valid JSON response when querying for the network topology.") - clusters = {} # TODO this mapping should be retrieved somehow + # TODO this is a temporary solution - currently the service router to clusters mapping is read from a file (which must be manually prepared beforehand) + clusters_file = self.request.registry.settings["network_configuration_path"] + try: + with open(clusters_file) as fh: + clusters = load(fh) + except Exception as e: + log.error("Unexpected error: {0}".format(e)) + log.error("No service_router-to-cluster mapping was found while building the network topology.") + clusters = {} + # build the network graph and retrieve the number of switch nodes and cluster nodes that were created switch_count, clusters_count = build_network_graph(graph, switches, links, clusters) diff --git a/src/service/development.ini b/src/service/development.ini index cbc930b6b81038ed0ef4b074d0ff0e674458e9b9..ea65782e94adf07bc350c65764a26a5c33159ad8 100644 --- a/src/service/development.ini +++ b/src/service/development.ini @@ -15,7 +15,7 @@ pyramid.includes = pyramid_debugtoolbar pyramid_exclog exclog.ignore = -network_configuration_path = /vagrant/src/service/resources/GraphAPI/network_config.json +network_configuration_path = /vagrant/src/service/resources/GraphAPI/network_clusters.json # PostgreSQL connection url sqlalchemy.url = postgresql://clmc:clmc_service@localhost:5432/whoamidb diff --git a/src/service/production.ini b/src/service/production.ini index 4d9613152f2ad78fe7bdab6c811a18b3fc8f3cec..083bb91d2bc1cae25c1021b93081c87ff5a3b73f 100644 --- a/src/service/production.ini +++ b/src/service/production.ini @@ -15,7 +15,7 @@ pyramid.includes = pyramid_exclog exclog.ignore = -network_configuration_path = /opt/clmc/src/service/resources/GraphAPI/network_config.json +network_configuration_path = /opt/clmc/src/service/resources/GraphAPI/network_clusters.json # PostgreSQL connection url sqlalchemy.url = postgresql://clmc:clmc_service@localhost:5432/whoamidb diff --git a/src/service/resources/GraphAPI/network_clusters.json b/src/service/resources/GraphAPI/network_clusters.json new file mode 100644 index 0000000000000000000000000000000000000000..40fe2629a6ab664643591eb95533bfe7613520b8 --- /dev/null +++ b/src/service/resources/GraphAPI/network_clusters.json @@ -0,0 +1,6 @@ +{ + "172.20.231.11": "20-sr1-cluster1-cluster", + "172.20.231.18": "22-sr1-cluster1-cluster", + "172.20.231.17": "23-sr1-cluster1-cluster", + "172.20.231.2": "24-sr1-cluster1-cluster" +} \ No newline at end of file