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

Moves SDN controller and SFEMC port numbers out of implementation - passed to...

Moves SDN controller and SFEMC port numbers out of implementation - passed to CLMC as environment variables, default 8080 port used if not passed
parent 9ce5f012
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,9 @@ def main(global_config, **settings):
Base.metadata.bind = engine # bind the engine to the Base class metadata
settings['sfemc_fqdn'] = os.environ['SFEMC_FQDN'] # read the SFEMC FQDN from the OS environment
settings['sfemc_port'] = os.environ.get('SFEMC_PORT', 8080) # read the SFEMC port number from the OS environment, if not set use 8080 as default
settings['sdn_controller_ip'] = os.environ['SDN_CONTROLLER_IP'] # read the SDN controller IP address from the OS environment
settings['sdn_controller_port'] = os.environ.get('SDN_CONTROLLER_PORT', 8080) # read the SDN controller port number from the OS environment, if not set use 8080 as default
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
......
......@@ -62,7 +62,7 @@ class TestAlertsConfigurationAPI(object):
"""
self.registry = testing.setUp()
self.registry.add_settings({"kapacitor_host": "localhost", "kapacitor_port": 9092, "sfemc_fqdn": "sfemc.localhost"})
self.registry.add_settings({"kapacitor_host": "localhost", "kapacitor_port": 9092, "sfemc_fqdn": "sfemc.localhost", "sfemc_port": 8081})
yield
......@@ -301,7 +301,7 @@ def extract_alert_spec_data(alert_spec):
for handler_url in trigger.trigger_tpl["action"]["implementation"]:
if handler_url == "flame_sfemc":
handler_url = "http://sfemc.localhost:8080/sfemc/event/{0}/{1}/{2}".format(sfc, policy_id, "trigger_id_{0}".format(version))
handler_url = "http://sfemc.localhost:8081/sfemc/event/{0}/{1}/{2}".format(sfc, policy_id, "trigger_id_{0}".format(version))
handler_id = "{0}\n{1}\n{2}\n{3}\n{4}".format(sfc, sfc_instance, policy_id, trigger_id, handler_url)
handler_id = AlertsConfigurationAPI.get_hash(handler_id)
......
......@@ -326,7 +326,8 @@ class AlertsConfigurationAPI(object):
# check for flame_sfemc entry, if found replace with sfemc FQDN
if http_handler_url == SFEMC:
sfemc_fqdn = self.request.registry.settings['sfemc_fqdn']
http_handler_url = "http://{0}:8080/sfemc/event/{1}/{2}/{3}".format(sfemc_fqdn, sfc, policy_id, trigger_id)
sfemc_port = self.request.registry.settings['sfemc_port']
http_handler_url = "http://{0}:{1}/sfemc/event/{2}/{3}/{4}".format(sfemc_fqdn, sfemc_port, sfc, policy_id, trigger_id)
handler_id = "{0}\n{1}\n{2}\n{3}\n{4}".format(sfc, sfc_i, policy_id, event_id, http_handler_url)
handler_id = self.get_hash(handler_id)
......
......@@ -221,13 +221,14 @@ class GraphAPI(object):
graph = Graph(host=self.request.registry.settings['neo4j_host'], password=self.request.registry.settings['neo4j_password']) # connect to the neo4j graph db
sdn_controller_ip = self.request.registry.settings['sdn_controller_ip']
sdn_controller_port = self.request.registry.settings['sdn_controller_port']
# retrieve all switches - if SDN controller is unavailable on the given IP address return 503 Service Unavailable
try:
url = "http://{0}:8080{1}".format(sdn_controller_ip, "/wm/core/controller/switches/json")
url = "http://{0}:{1}{2}".format(sdn_controller_ip, sdn_controller_port, "/wm/core/controller/switches/json")
response = get(url)
except exceptions.ConnectionError:
msg = "The SDN controller is not available on IP {0} and port 8080.".format(sdn_controller_ip)
msg = "The SDN controller is not available on IP {0} and port {1}.".format(sdn_controller_ip, sdn_controller_port)
log.error("Unexpected error: {0}".format(msg))
raise HTTPServiceUnavailable("The SDN controller couldn't be reached when trying to build the network topology.")
......@@ -252,10 +253,10 @@ class GraphAPI(object):
# retrieve all external links (gathered through BDDP) - if SDN controller is unavailable on the given IP address return 503 Service Unavailable
try:
url = "http://{0}:8080{1}".format(sdn_controller_ip, "/wm/topology/external-links/json")
url = "http://{0}:{1}{2}".format(sdn_controller_ip, sdn_controller_port, "/wm/topology/external-links/json")
response = get(url)
except exceptions.ConnectionError:
msg = "The SDN controller is not available on IP {0} and port 8080.".format(sdn_controller_ip)
msg = "The SDN controller is not available on IP {0} and port {1}.".format(sdn_controller_ip, sdn_controller_port)
log.error("Unexpected error: {0}".format(msg))
raise HTTPServiceUnavailable("The SDN controller couldn't be reached when trying to build the network topology.")
......@@ -274,10 +275,10 @@ class GraphAPI(object):
# retrieve all local links (gathered through LLDP) - if SDN controller is unavailable on the given IP address return 503 Service Unavailable
try:
url = "http://{0}:8080{1}".format(sdn_controller_ip, "/wm/topology/links/json")
url = "http://{0}:{1}{2}".format(sdn_controller_ip, sdn_controller_port, "/wm/topology/links/json")
response = get(url)
except exceptions.ConnectionError:
msg = "The SDN controller is not available on IP {0} and port 8080.".format(sdn_controller_ip)
msg = "The SDN controller is not available on IP {0} and port {1}.".format(sdn_controller_ip, sdn_controller_port)
log.error("Unexpected error: {0}".format(msg))
raise HTTPServiceUnavailable("The SDN controller couldn't be reached when trying to build the network topology.")
......
......@@ -3,7 +3,7 @@ tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
metadata:
template_name: Flame CLMC Alerts Integration Test
servicefunctionchain: MS_Template_1
sfci: MS_I1
# sfci: MS_I1
# Import own definitions of nodes, capabilities and policy syntax.
......
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