From ba084a5336945ddbf6ac332cd43137cf30b53611 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 11 Dec 2025 10:29:20 -0500 Subject: [PATCH 1/8] handle LC connection status change message --- sdx_controller/handlers/lc_message_handler.py | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index 0b641dd3..258b07fd 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -29,7 +29,37 @@ def process_lc_json_msg( logger.info("MQ received message:" + str(msg)) msg_json = json.loads(msg) - if msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_response": + if msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_status_change": + logger.info("Received OXP connection status change.") + service_id = msg_json.get("service_id") + + if not service_id: + return + + connection = self.db_instance.get_value_from_db( + MongoCollections.CONNECTIONS, service_id + ) + if not connection: + return + + if connection.get("status") and ( + connection.get("status") + == str(ConnectionStateMachine.State.RECOVERING) + ): + connection, _ = connection_state_machine( + connection, ConnectionStateMachine.State.ERROR + ) + elif ( + connection.get("status") + and connection.get("status") + != str(ConnectionStateMachine.State.DOWN) + and connection.get("status") + != str(ConnectionStateMachine.State.ERROR) + ): + connection, _ = connection_state_machine( + connection, ConnectionStateMachine.State.DOWN + ) + elif msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_response": logger.info("Received OXP connection response.") service_id = msg_json.get("service_id") From 6a1ecf82020b40193f78aed3fcd23925725a7633 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Wed, 11 Feb 2026 11:46:36 -0500 Subject: [PATCH 2/8] Update connection handling --- sdx_controller/handlers/lc_message_handler.py | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index 258b07fd..15d937fe 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -29,7 +29,10 @@ def process_lc_json_msg( logger.info("MQ received message:" + str(msg)) msg_json = json.loads(msg) - if msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_status_change": + if ( + msg_json.get("msg_type") + and msg_json["msg_type"] == "oxp_conn_status_change" + ): logger.info("Received OXP connection status change.") service_id = msg_json.get("service_id") @@ -43,22 +46,29 @@ def process_lc_json_msg( return if connection.get("status") and ( - connection.get("status") - == str(ConnectionStateMachine.State.RECOVERING) - ): - connection, _ = connection_state_machine( - connection, ConnectionStateMachine.State.ERROR - ) - elif ( - connection.get("status") - and connection.get("status") - != str(ConnectionStateMachine.State.DOWN) - and connection.get("status") - != str(ConnectionStateMachine.State.ERROR) - ): - connection, _ = connection_state_machine( - connection, ConnectionStateMachine.State.DOWN - ) + connection.get("status") == str(ConnectionStateMachine.State.RECOVERING) + ): + connection, _ = connection_state_machine( + connection, ConnectionStateMachine.State.ERROR + ) + connection["status"] = "error" + elif ( + connection.get("status") + and connection.get("status") != str(ConnectionStateMachine.State.DOWN) + and connection.get("status") != str(ConnectionStateMachine.State.ERROR) + ): + connection, _ = connection_state_machine( + connection, ConnectionStateMachine.State.DOWN + ) + connection["status"] = "down" + + self.db_instance.add_key_value_pair_to_db( + MongoCollections.CONNECTIONS, + service_id, + connection, + ) + logger.info("Connection updated: " + service_id) + elif msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_response": logger.info("Received OXP connection response.") service_id = msg_json.get("service_id") From d60b524ae80fbfa21e242dd07e1f7e7439c47fdd Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Tue, 17 Feb 2026 22:14:22 -0500 Subject: [PATCH 3/8] Update connection status handling --- sdx_controller/handlers/lc_message_handler.py | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index 15d937fe..f195b961 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -35,8 +35,10 @@ def process_lc_json_msg( ): logger.info("Received OXP connection status change.") service_id = msg_json.get("service_id") + new_status = msg_json.get("new_status") + existing_status = msg_json.get("existing_status") - if not service_id: + if not service_id or new_status is None: return connection = self.db_instance.get_value_from_db( @@ -45,30 +47,30 @@ def process_lc_json_msg( if not connection: return - if connection.get("status") and ( - connection.get("status") == str(ConnectionStateMachine.State.RECOVERING) - ): - connection, _ = connection_state_machine( - connection, ConnectionStateMachine.State.ERROR - ) - connection["status"] = "error" - elif ( - connection.get("status") - and connection.get("status") != str(ConnectionStateMachine.State.DOWN) - and connection.get("status") != str(ConnectionStateMachine.State.ERROR) - ): - connection, _ = connection_state_machine( - connection, ConnectionStateMachine.State.DOWN - ) - connection["status"] = "down" + current_status = connection.get("status") + + # If status is unchanged, do nothing + if current_status == new_status: + logger.info(f"Status unchanged for {service_id}") + return + + logger.info( + f"Updating connection {service_id} status: " + f"{current_status} -> {new_status}" + ) + + # Directly reflect LC/OXP status into controller DB + connection["status"] = new_status self.db_instance.add_key_value_pair_to_db( MongoCollections.CONNECTIONS, service_id, connection, ) - logger.info("Connection updated: " + service_id) - + logger.info( + f"Connection {service_id} status updated from '{current_status}' to '{new_status}'" + ) + return elif msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_response": logger.info("Received OXP connection response.") service_id = msg_json.get("service_id") From e015b8525b002e30d015cccc91d76f0a53bd64b9 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Wed, 18 Feb 2026 11:00:58 -0500 Subject: [PATCH 4/8] update log msg --- sdx_controller/handlers/lc_message_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index f195b961..53f1fea1 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -68,7 +68,7 @@ def process_lc_json_msg( connection, ) logger.info( - f"Connection {service_id} status updated from '{current_status}' to '{new_status}'" + f"Connection {service_id} status updated." ) return elif msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_response": From b3c8eedbcbea49b1f661439bb31ae25259b15da9 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Wed, 18 Feb 2026 11:01:13 -0500 Subject: [PATCH 5/8] Format --- sdx_controller/handlers/lc_message_handler.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index 53f1fea1..9dc80770 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -67,9 +67,7 @@ def process_lc_json_msg( service_id, connection, ) - logger.info( - f"Connection {service_id} status updated." - ) + logger.info(f"Connection {service_id} status updated.") return elif msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_response": logger.info("Received OXP connection response.") From 5ee082d9eb89444b678fab257287ca1d8af8d49f Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 26 Mar 2026 01:33:38 +0000 Subject: [PATCH 6/8] Update logging --- sdx_controller/handlers/lc_message_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index 9dc80770..a18548ac 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -33,7 +33,7 @@ def process_lc_json_msg( msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_status_change" ): - logger.info("Received OXP connection status change.") + logger.info(f"Received OXP connection status change {service_id=} {existing_status=} {new_status=}") service_id = msg_json.get("service_id") new_status = msg_json.get("new_status") existing_status = msg_json.get("existing_status") @@ -51,7 +51,7 @@ def process_lc_json_msg( # If status is unchanged, do nothing if current_status == new_status: - logger.info(f"Status unchanged for {service_id}") + logger.debug(f"Status unchanged for {service_id}") return logger.info( From f8ce0a592f6902a49d69289851c3e4c47feff849 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 26 Mar 2026 01:42:59 +0000 Subject: [PATCH 7/8] Format --- sdx_controller/handlers/lc_message_handler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index a18548ac..f23fe07c 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -33,7 +33,9 @@ def process_lc_json_msg( msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_status_change" ): - logger.info(f"Received OXP connection status change {service_id=} {existing_status=} {new_status=}") + logger.info( + f"Received OXP connection status change {service_id=} {existing_status=} {new_status=}" + ) service_id = msg_json.get("service_id") new_status = msg_json.get("new_status") existing_status = msg_json.get("existing_status") From 537ea66f4da95c7ba60f42e924925dc20a2fe7f8 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 26 Mar 2026 13:21:54 +0000 Subject: [PATCH 8/8] Update logging --- sdx_controller/handlers/lc_message_handler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdx_controller/handlers/lc_message_handler.py b/sdx_controller/handlers/lc_message_handler.py index f23fe07c..76230361 100644 --- a/sdx_controller/handlers/lc_message_handler.py +++ b/sdx_controller/handlers/lc_message_handler.py @@ -33,12 +33,13 @@ def process_lc_json_msg( msg_json.get("msg_type") and msg_json["msg_type"] == "oxp_conn_status_change" ): - logger.info( - f"Received OXP connection status change {service_id=} {existing_status=} {new_status=}" - ) + service_id = msg_json.get("service_id") new_status = msg_json.get("new_status") existing_status = msg_json.get("existing_status") + logger.info( + f"Received OXP connection status change. service_id={service_id}, existing_status={existing_status}, new_status={new_status}." + ) if not service_id or new_status is None: return