From 3e03585be2b32971b6696c2f8b8dcaf6316174c4 Mon Sep 17 00:00:00 2001 From: Yufeng Xin Date: Tue, 22 Oct 2024 21:33:05 -0400 Subject: [PATCH] keep two endpoints in response --- pyproject.toml | 2 +- sdx_controller/handlers/connection_handler.py | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ce9f98a..a689bb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ profile = "black" src_paths = ["sdx_controller", "bapm_server"] [tool.pytest.ini_options] -addopts = "--cov=sdx_controller --cov=bapm_server --cov-report html --cov-report term-missing" +addopts = "--cov=sdx_controller --cov=bapm_server" testpaths = [ "sdx_controller/test" ] diff --git a/sdx_controller/handlers/connection_handler.py b/sdx_controller/handlers/connection_handler.py index be329f2..daa81f8 100644 --- a/sdx_controller/handlers/connection_handler.py +++ b/sdx_controller/handlers/connection_handler.py @@ -397,10 +397,17 @@ def get_connection_status(db, service_id: str): endpoints.append(endpoint_a) if request_uni_a_id == uni_a_port: - response_endpoints.append(endpoint_a) - + ( + response_endpoints.append(endpoint_a) + if endpoint_a not in response_endpoints + else None + ) if request_uni_z_id == uni_a_port: - response_endpoints.append(endpoint_a) + ( + response_endpoints.append(endpoint_a) + if endpoint_a not in response_endpoints + else None + ) uni_z_port = breakdown.get("uni_z").get("port_id") uni_z_vlan = breakdown.get("uni_z").get("tag").get("value") @@ -413,10 +420,17 @@ def get_connection_status(db, service_id: str): endpoints.append(endpoint_z) if request_uni_a_id == uni_z_port: - response_endpoints.append(endpoint_z) + ( + response_endpoints.append(endpoint_z) + if endpoint_z not in response_endpoints + else None + ) if request_uni_z_id == uni_z_port: - response_endpoints.append(endpoint_z) - + ( + response_endpoints.append(endpoint_z) + if endpoint_z not in response_endpoints + else None + ) print( f"endpoints info: {request_uni_a_id}, {request_uni_z_id}, {uni_a_port}, {uni_z_port}" )