@@ -37,19 +37,37 @@ def __init__(self):
3737 self .heartbeat_id = 0
3838 self .message_id = 0
3939
40- def send_conn_response_to_sdx_controller (self , service_id , operation , oxp_response ):
41- try :
42- oxp_response_json = oxp_response .json ()
43- except :
40+ def send_conn_response_to_sdx_controller (
41+ self , service_id , operation , oxp_response = None , oxp_response_code = None
42+ ):
43+ if oxp_response_code is not None :
44+ response_code = oxp_response_code
45+ elif oxp_response is not None :
46+ response_code = oxp_response .status_code
47+ else :
48+ response_code = 503
49+
50+ if isinstance (oxp_response , dict ):
51+ oxp_response_json = oxp_response
52+ elif oxp_response is None :
4453 oxp_response_json = {
45- "msg" : "Failed to parse OXP response. Please check the OXP logs."
54+ "msg" : "No response received from OXP." ,
55+ "error_source" : "sdx-lc" ,
56+ "error_type" : "no_oxp_response" ,
4657 }
58+ else :
59+ try :
60+ oxp_response_json = oxp_response .json ()
61+ except Exception :
62+ oxp_response_json = {
63+ "msg" : "Failed to parse OXP response. Please check the OXP logs."
64+ }
4765 rpc_msg = {
4866 "lc_domain" : SDXLC_DOMAIN ,
4967 "msg_type" : "oxp_conn_response" ,
5068 "service_id" : service_id ,
5169 "operation" : operation ,
52- "oxp_response_code" : oxp_response . status_code ,
70+ "oxp_response_code" : response_code ,
5371 "oxp_response" : oxp_response_json ,
5472 }
5573 self .rpc_producer = RpcProducer (5 , "" , PUB_QUEUE )
@@ -59,6 +77,15 @@ def send_conn_response_to_sdx_controller(self, service_id, operation, oxp_respon
5977 f"Sent OXP connection response to SDX controller via MQ. MQ response: { response } "
6078 )
6179
80+ def _build_no_response_payload (self , operation , error ):
81+ return {
82+ "msg" : f"No response received from OXP during { operation .upper ()} request." ,
83+ "error_source" : "sdx-lc" ,
84+ "error_type" : "no_oxp_response" ,
85+ "operation" : operation ,
86+ "details" : str (error ),
87+ }
88+
6289 def process_sdx_controller_json_msg (self , msg ):
6390 if "Heart Beat" in str (msg ):
6491 self .heartbeat_id += 1
@@ -113,6 +140,13 @@ def process_sdx_controller_json_msg(self, msg):
113140 self .logger .info (
114141 "Check your configuration and make sure OXP service is running."
115142 )
143+ self .send_conn_response_to_sdx_controller (
144+ service_id ,
145+ msg_json ["operation" ],
146+ oxp_response = self ._build_no_response_payload ("post" , e ),
147+ oxp_response_code = 503 ,
148+ )
149+ return
116150 self .logger .info (
117151 f"Status from OXP: { oxp_response } - { oxp_response .text } "
118152 )
@@ -136,6 +170,13 @@ def process_sdx_controller_json_msg(self, msg):
136170 self .logger .info (
137171 "Check your configuration and make sure OXP service is running."
138172 )
173+ self .send_conn_response_to_sdx_controller (
174+ service_id ,
175+ msg_json ["operation" ],
176+ oxp_response = self ._build_no_response_payload ("delete" , e ),
177+ oxp_response_code = 503 ,
178+ )
179+ return
139180 self .logger .info (
140181 f"Status from OXP: { oxp_response } - { oxp_response .text } "
141182 )
0 commit comments