From 8618614867001f43702dc10a12db6c359433baa2 Mon Sep 17 00:00:00 2001 From: Yufeng Xin Date: Tue, 22 Oct 2024 12:50:57 -0400 Subject: [PATCH] v1 compitable --- sdx_controller/handlers/connection_handler.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sdx_controller/handlers/connection_handler.py b/sdx_controller/handlers/connection_handler.py index b765cea..e66035d 100644 --- a/sdx_controller/handlers/connection_handler.py +++ b/sdx_controller/handlers/connection_handler.py @@ -364,9 +364,17 @@ def get_connection_status(db, service_id: str): qos_metrics = request_dict.get("qos_metrics") scheduling = request_dict.get("scheduling") notifications = request_dict.get("notifications") - request_endpoints = request_dict.get("endpoints") - request_uni_a = request_endpoints[0] - request_uni_z = request_endpoints[1] + if request_dict.get("endpoints") is not None: # spec version 2.0.0 + request_endpoints = request_dict.get("endpoints") + request_uni_a = request_endpoints[0] + request_uni_a_id = request_uni_a.get("port_id") + request_uni_z = request_endpoints[1] + request_uni_z_id = request_uni_z.get("port_id") + else: # spec version 1.0.0 + request_uni_a = request_dict.get("ingress_port") + request_uni_a_id = request_uni_a.get("id") + request_uni_z = request_dict.get("egress_port") + request_uni_z_id = request_uni_z.get("id") response = {} @@ -381,10 +389,10 @@ def get_connection_status(db, service_id: str): endpoints.append(endpoint_a) - if request_uni_a.get("id") == uni_a_port: + if request_uni_a_id == uni_a_port: response_endpoints.append(endpoint_a) - if request_uni_z.get("id") == uni_a_port: + if request_uni_z_id == uni_a_port: response_endpoints.append(endpoint_a) uni_z_port = breakdown.get("uni_z").get("port_id") @@ -397,9 +405,9 @@ def get_connection_status(db, service_id: str): endpoints.append(endpoint_z) - if request_uni_a.get("id") == uni_z_port: + if request_uni_a_id == uni_z_port: response_endpoints.append(endpoint_z) - if request_uni_z.get("id") == uni_z_port: + if request_uni_z_id == uni_z_port: response_endpoints.append(endpoint_z) # TODO: we're missing many of the attributes in the response here