diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a5c5ed4..b1eb01b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,7 +75,7 @@ jobs: python -m tox env: SDXLC_HOST: 'localhost' - SDXLC_DOMAIN: '' + SDXLC_DOMAIN: 'test_topology.net' SDXLC_PORT: '8080' SDXLC_VERSION: '1.0.0' SDXLC_NAME: 'test-lc' diff --git a/env.template b/env.template index 0c5bb1f..af78874 100644 --- a/env.template +++ b/env.template @@ -1,7 +1,7 @@ export SDX_MQ_IP='152.54.3.143' export SDXLC_VERSION='1.0.0' export SDXLC_NAME='lc1' -export SDXLC_DOMAIN='amlight' +export SDXLC_DOMAIN='amlight.net' export DB_NAME='test-db' export DB_CONFIG_TABLE_NAME='test-1' diff --git a/swagger_server/controllers/topology_controller.py b/swagger_server/controllers/topology_controller.py index 4c867fd..bdb4fe7 100644 --- a/swagger_server/controllers/topology_controller.py +++ b/swagger_server/controllers/topology_controller.py @@ -1,14 +1,10 @@ import json import logging import os -import threading import connexion -import six -from swagger_server import util from swagger_server.messaging.rpc_queue_producer import RpcProducer -from swagger_server.models.api_response import ApiResponse # noqa: E501 from swagger_server.models.topology import Topology # noqa: E501 from swagger_server.utils.db_utils import DbUtils @@ -27,13 +23,15 @@ db_instance.initialize_db() -def find_between(s, first, last): - try: - start = s.index(first) + len(first) - end = s.index(last, start) - return s[start:end] - except ValueError: - return "" +def find_domain_name(topology_id, delimiter): + """ + Find domain name from topology id. + + Topology IDs are expected to be of the format + "urn:ogf:network:sdx:topology:zaoxi.net" + """ + *_, domain_name = topology_id.split(delimiter) + return domain_name def add_topology(body): # noqa: E501 @@ -53,7 +51,7 @@ def add_topology(body): # noqa: E501 if msg_id is None: return "ID is missing." - domain_name = find_between(msg_id, "topology:", ".net") + domain_name = find_domain_name(msg_id, ":") if domain_name != SDXLC_DOMAIN: logger.debug("Domain name not matching LC domain. Returning 400 status.") return "Domain name not matching LC domain. Please check again.", 400 diff --git a/swagger_server/messaging/topic_queue_consumer.py b/swagger_server/messaging/topic_queue_consumer.py index b724439..5e667c7 100644 --- a/swagger_server/messaging/topic_queue_consumer.py +++ b/swagger_server/messaging/topic_queue_consumer.py @@ -93,7 +93,7 @@ def handle_mq_msg(self, msg_body): if is_json(msg_body): self.logger.info("JSON message") msg_json = json.loads(msg_body) - if "ingress_port" in msg_json and "egress_port" in msg_json: + if "uni_a" in msg_json and "uni_z" in msg_json: self.logger.info("Got connection message.") self.db_instance.add_key_value_pair_to_db(self.message_id, msg_body) self.logger.info("Save to database complete.") diff --git a/swagger_server/test/test_topology_controller.py b/swagger_server/test/test_topology_controller.py index 923856f..7751ca0 100644 --- a/swagger_server/test/test_topology_controller.py +++ b/swagger_server/test/test_topology_controller.py @@ -69,7 +69,7 @@ class TestTopologyController(BaseTestCase): ] __topology = Topology( - id="test_topology_id", + id="test:topology:test_topology.net", name="test_topology_name", domain_service=None, version=0,