diff --git a/src/service/clmcservice/__init__.py b/src/service/clmcservice/__init__.py index 07f8d88205d7c256156b54ed8fd0a3f8f2ea91ef..b2248c354978037e781fcf69a46dc065b1554666 100644 --- a/src/service/clmcservice/__init__.py +++ b/src/service/clmcservice/__init__.py @@ -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 diff --git a/src/service/clmcservice/alertsapi/tests.py b/src/service/clmcservice/alertsapi/tests.py index 5c5b4fa7a9bbfd196a1b3b32bd3d6e7a7bbc46a8..8fd2ac04547db1eb5876df0f6d4afd44bdfb05e2 100644 --- a/src/service/clmcservice/alertsapi/tests.py +++ b/src/service/clmcservice/alertsapi/tests.py @@ -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) diff --git a/src/service/clmcservice/alertsapi/views.py b/src/service/clmcservice/alertsapi/views.py index 20892c396e5827ccbc413b553a5f9f1a3275ccb9..d794e656293407823bf9bf64668e32c0192b6d25 100644 --- a/src/service/clmcservice/alertsapi/views.py +++ b/src/service/clmcservice/alertsapi/views.py @@ -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) diff --git a/src/service/clmcservice/graphapi/views.py b/src/service/clmcservice/graphapi/views.py index afa9a5cb5b082a23a4dad25a460a721f19d1d7eb..15cf0702c027ea4821f1e3f0ee1430c086e68728 100644 --- a/src/service/clmcservice/graphapi/views.py +++ b/src/service/clmcservice/graphapi/views.py @@ -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.") diff --git a/src/test/clmctest/alerts/resources_test_config.yaml b/src/test/clmctest/alerts/resources_test_config.yaml index 9bd17df6fb473fcea31b132aeae249168e997d58..6f83faa50183b9d0d3504da362c937cd288f27fa 100644 --- a/src/test/clmctest/alerts/resources_test_config.yaml +++ b/src/test/clmctest/alerts/resources_test_config.yaml @@ -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.