From 2e599be1d167f61a380fa97af75b7d2007ecb36b Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Tue, 8 Oct 2024 14:36:31 -0400 Subject: [PATCH] Add archived connection API --- sdx_controller/controllers/l2vpn_controller.py | 17 ++++++++++++++++- sdx_controller/handlers/connection_handler.py | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/sdx_controller/controllers/l2vpn_controller.py b/sdx_controller/controllers/l2vpn_controller.py index 1234eca..1590dda 100644 --- a/sdx_controller/controllers/l2vpn_controller.py +++ b/sdx_controller/controllers/l2vpn_controller.py @@ -219,5 +219,20 @@ def patch_connection(service_id, body=None): # noqa: E501 return response, code + def get_archived_connections_by_id(service_id): - return "Do some magic" + """ + List archived connection by ID. + + :param service_id: ID of connection that needs to be fetched + :type service_id: str + + :rtype: Connection + """ + + value = get_connection_status(db_instance, service_id) + + if not value: + return "Connection not found", 404 + + return value diff --git a/sdx_controller/handlers/connection_handler.py b/sdx_controller/handlers/connection_handler.py index fff74c7..b644794 100644 --- a/sdx_controller/handlers/connection_handler.py +++ b/sdx_controller/handlers/connection_handler.py @@ -271,6 +271,14 @@ def handle_link_failure(self, te_manager, failed_links): logger.debug(connection) self.place_connection(te_manager, connection) + def get_archived_connections(self, service_id: str): + historical_connections = self.db_instance.read_from_db( + "historical_connections", service_id + ) + if not historical_connections: + return None + return historical_connections[service_id] + def get_connection_status(db, service_id: str): """