From 0462dae7115301f5d5b19e042ed3e7c090106015 Mon Sep 17 00:00:00 2001 From: Italo Valcy Date: Tue, 19 Mar 2024 17:31:58 -0300 Subject: [PATCH 01/11] change ingress_port/egress_port with uni_a/uni_z --- swagger_server/messaging/topic_queue_consumer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swagger_server/messaging/topic_queue_consumer.py b/swagger_server/messaging/topic_queue_consumer.py index 138e4dd..55e4ba0 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.") From b146012642e22abfb847dfb3c6743c78b9d5fa95 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Sun, 24 Mar 2024 21:13:45 -0400 Subject: [PATCH 02/11] Use dot to split and get LC domain --- swagger_server/controllers/topology_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swagger_server/controllers/topology_controller.py b/swagger_server/controllers/topology_controller.py index 4c867fd..3f1cb47 100644 --- a/swagger_server/controllers/topology_controller.py +++ b/swagger_server/controllers/topology_controller.py @@ -53,7 +53,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_between(msg_id, "topology:", ".") 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 From 1c2483700a1097bf3a8108fa5c216dfb9f37652c Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 28 Mar 2024 11:00:09 -0400 Subject: [PATCH 03/11] Use full domain name --- swagger_server/controllers/topology_controller.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/swagger_server/controllers/topology_controller.py b/swagger_server/controllers/topology_controller.py index 3f1cb47..3bbd78a 100644 --- a/swagger_server/controllers/topology_controller.py +++ b/swagger_server/controllers/topology_controller.py @@ -27,11 +27,10 @@ db_instance.initialize_db() -def find_between(s, first, last): +def find_after(s, splitter): try: - start = s.index(first) + len(first) - end = s.index(last, start) - return s[start:end] + start = s.index(splitter) + len(splitter) + return s[start:] except ValueError: return "" @@ -53,7 +52,7 @@ def add_topology(body): # noqa: E501 if msg_id is None: return "ID is missing." - domain_name = find_between(msg_id, "topology:", ".") + domain_name = find_after(msg_id, "topology:") 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 From 0528b30791cac0ea09f8c6f128f158f28e51b4d2 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 28 Mar 2024 11:02:07 -0400 Subject: [PATCH 04/11] update env.template --- env.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' From d0c533605cf2fc8e4af294fb26f457c7938cf06e Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 28 Mar 2024 11:03:44 -0400 Subject: [PATCH 05/11] Fix typo --- swagger_server/controllers/topology_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swagger_server/controllers/topology_controller.py b/swagger_server/controllers/topology_controller.py index 3bbd78a..6787f8c 100644 --- a/swagger_server/controllers/topology_controller.py +++ b/swagger_server/controllers/topology_controller.py @@ -27,9 +27,9 @@ db_instance.initialize_db() -def find_after(s, splitter): +def find_after(s, delimiter): try: - start = s.index(splitter) + len(splitter) + start = s.index(delimiter) + len(delimiter) return s[start:] except ValueError: return "" From 66c1fffdfe4951e919db518fce05bf427b1552f5 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 28 Mar 2024 11:42:36 -0400 Subject: [PATCH 06/11] Use split to find domain name --- .../controllers/topology_controller.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/swagger_server/controllers/topology_controller.py b/swagger_server/controllers/topology_controller.py index 6787f8c..ede8171 100644 --- a/swagger_server/controllers/topology_controller.py +++ b/swagger_server/controllers/topology_controller.py @@ -27,12 +27,15 @@ db_instance.initialize_db() -def find_after(s, delimiter): - try: - start = s.index(delimiter) + len(delimiter) - return s[start:] - 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 @@ -52,7 +55,7 @@ def add_topology(body): # noqa: E501 if msg_id is None: return "ID is missing." - domain_name = find_after(msg_id, "topology:") + 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 From 60d11733d8c0b361aef2e05e3926572e3962cd76 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 28 Mar 2024 11:48:02 -0400 Subject: [PATCH 07/11] Remove unused import --- swagger_server/controllers/topology_controller.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/swagger_server/controllers/topology_controller.py b/swagger_server/controllers/topology_controller.py index ede8171..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 From b8bb75f305eebe61b5d43d54e37896e5f77587c1 Mon Sep 17 00:00:00 2001 From: Italo Valcy Date: Tue, 2 Apr 2024 15:36:47 -0300 Subject: [PATCH 08/11] fix black formatting issue --- swagger_server/models/base_model_.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/swagger_server/models/base_model_.py b/swagger_server/models/base_model_.py index 703f3e0..d30aa67 100644 --- a/swagger_server/models/base_model_.py +++ b/swagger_server/models/base_model_.py @@ -40,9 +40,11 @@ def to_dict(self): elif isinstance(value, dict): result[attr] = dict( map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, + lambda item: ( + (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item + ), value.items(), ) ) From 162d5755a8456a0d85a7366a4ca959b7c1fbf305 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Tue, 2 Apr 2024 20:53:45 -0400 Subject: [PATCH 09/11] Update unit test --- .github/workflows/test.yml | 2 +- swagger_server/test/test_topology_controller.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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, From ac7224bcc944741d12bd76177c1ce4293385e65e Mon Sep 17 00:00:00 2001 From: Italo Valcy Date: Tue, 19 Mar 2024 17:31:58 -0300 Subject: [PATCH 10/11] change ingress_port/egress_port with uni_a/uni_z --- swagger_server/messaging/topic_queue_consumer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.") From fc19bb61ac5f0c79fd0733cdb44f54e7231a490a Mon Sep 17 00:00:00 2001 From: Italo Valcy Date: Wed, 3 Apr 2024 14:04:10 -0300 Subject: [PATCH 11/11] Revert "fix black formatting issue" This reverts commit b8bb75f305eebe61b5d43d54e37896e5f77587c1. --- swagger_server/models/base_model_.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/swagger_server/models/base_model_.py b/swagger_server/models/base_model_.py index d30aa67..703f3e0 100644 --- a/swagger_server/models/base_model_.py +++ b/swagger_server/models/base_model_.py @@ -40,11 +40,9 @@ def to_dict(self): elif isinstance(value, dict): result[attr] = dict( map( - lambda item: ( - (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item - ), + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, value.items(), ) )