Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ingress_port and egress_port with uni_a and uni_z respectively #110

Merged
merged 14 commits into from
Apr 3, 2024
Merged
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion env.template
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
22 changes: 10 additions & 12 deletions swagger_server/controllers/topology_controller.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion swagger_server/messaging/topic_queue_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion swagger_server/test/test_topology_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading