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

Modified the build_network_graph API endpoint to read the sr-cluster mappings...

Modified the build_network_graph API endpoint to read the sr-cluster mappings from a file - temporary solution
parent f31d156b
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
{
"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
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