Skip to content

Commit

Permalink
Include OXP response in connection
Browse files Browse the repository at this point in the history
  • Loading branch information
congwang09 committed Jan 13, 2025
1 parent 4cfb2d4 commit 2623152
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 0 additions & 2 deletions sdx_controller/controllers/l2vpn_controller.py
Original file line number Diff line number Diff line change
@@ -137,8 +137,6 @@ def place_connection(body):
logger.info(
f"Handling request {service_id} with te_manager: {current_app.te_manager}"
)
print("-----PLACE CONNECTION-----")
print(body)
reason, code = connection_handler.place_connection(current_app.te_manager, body)

if code // 100 == 2:
8 changes: 8 additions & 0 deletions sdx_controller/handlers/connection_handler.py
Original file line number Diff line number Diff line change
@@ -376,6 +376,8 @@ 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")
oxp_response_code = request_dict.get("oxp_response_code")
oxp_response = request_dict.get("oxp_response")
print(f"request_dict: {request_dict}")
if request_dict.get("endpoints") is not None: # spec version 2.0.0
request_endpoints = request_dict.get("endpoints")
@@ -469,6 +471,12 @@ def get_connection_status(db, service_id: str):
if notifications:
response[service_id]["notifications"] = notifications

if oxp_response_code:
response[service_id]["oxp_response_code"] = oxp_response_code

if oxp_response:
response[service_id]["oxp_response"] = oxp_response

logger.info(f"Formed a response: {response}")

return response
21 changes: 21 additions & 0 deletions sdx_controller/handlers/lc_message_handler.py
Original file line number Diff line number Diff line change
@@ -22,6 +22,27 @@ 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":
logger.info("Received OXP connection response.")
service_id = msg_json.get("service_id")

if not service_id:
return

connection = self.db_instance.read_from_db("connections", service_id)

if not connection:
return

connection_json = json.loads(connection[service_id])
connection_json["oxp_response_code"] = msg_json.get("oxp_response_code")
connection_json["oxp_response"] = msg_json.get("oxp_response")
self.db_instance.add_key_value_pair_to_db("connections", service_id, json.dumps(connection_json))
logger.info("Connection updated: " + service_id)
print(self.db_instance.read_from_db("connections", service_id))
return

msg_id = msg_json["id"]
msg_version = msg_json["version"]

0 comments on commit 2623152

Please sign in to comment.