def handle_close_wait_rpc_response_control(self, response_suc_flag=False, response_message=None): """ 关闭等待PRC执行结果控制,根据ACS返回结果进程处理,并将消息发送回RPC请求端 """ if not self.rpc_request_node_message: return #[step-0] tmp_request_msg = self.rpc_request_node_message[0] tmp_request_client_conn = self.rpc_request_node_message[1] #[step-1] if (True == response_suc_flag and None != response_message): # send rpc response message to client ResponseClientHandle.handle_send_response(response_message, tmp_request_client_conn) log.debug_info("Agent send rpc response suc to client") else: # send rpc except message to client err_info = "ACS server's rpc response message type error" log.debug_err(err_info) ResponseClientHandle.handle_except(tmp_request_msg, tmp_request_client_conn, err_info) log.debug_info("Agent send rpc response error to client") #[step-2] #reset self.rpc_request_node_message value self.rpc_request_node_message = None
def hanale_worklistserver_response(self, message, conn): """ check worklist server response data and call continue event """ #检查消息的完整性 tmp_msg_is_complete = ResponseClientHandle.check_message_complete( message) if False == tmp_msg_is_complete: log.debug_info(message) err_info = "Recv WorkList server's response incomplete" log.debug_info(err_info) self.handle_request_except(self.msg, self.conn, err_info) return else: response = ResponseClientHandle.switch_msg_stream_type_str2dict( message) msg_group = int(response.get(event.KEY_MESSAGE)) & 0xFF00 if (msg_group == event.EVENT_WORKLIST_GROUP): #检查返回消息与请求消息的匹配关系 if not self.handle_response_message_type_verify( response.get(event.KEY_MESSAGE)): err_info = "WorkList server's response message type error" log.debug_info(err_info) self.handle_request_except(self.msg, self.conn, err_info) return #当请求消息是执行工单时,特殊处理, if (event.EV_WORKLIST_EXECUTE_RQST == self.msg_type): #更新工单等待执行状态,表示发起工单成功 self.set_worklist_execute_request_WLServer_check_response( "request_suc") else: #worklist download #其他消息正常处理 # send worklist down to user or ACS ResponseClientHandle.handle_send_response(response, conn) else: err_info = "Unsupport msg event group:%d" % msg_group log.debug_info(err_info) self.handle_request_except(self.msg, self.conn, err_info) return
def keepalive_request_response(request_message, conn): """ 处理守护进程的心跳包数据 """ message_type = request_message.get(event.KEY_MESSAGE) if message_type != event.EV_QUERY_IS_HANG_RQST: return False try: msg_obj = request_message.get(event.KEY_OBJECT) strio = StringIO(msg_obj) recv_data_obj = pickle.load(strio) except Exception, e: err_info = "keepalive_request_response: Unpickle event.KEY_OBJECT occurs error:%s" % e log.debug_err(err_info) request_message[event.KEY_MESSAGE] = message_type + 2 #发送响应消息 ResponseClientHandle.handle_send_response(request_message, conn) return True
def handle_ACS_worklist_info_response(self, message, conn): """ check acs server response worklist info data and call continue event """ response = ResponseClientHandle.switch_msg_stream_type_str2dict( message) msg_type = response.get(event.KEY_MESSAGE) msg_group = int(msg_type) & 0xFF00 if (msg_group == event.EVENT_WORKLIST_GROUP): # check worklist reseve response if (msg_type == event.EV_WORKLIST_RESERVE_RSP): log.debug_info("ACS server's response worklist reserve suc") # call worklist execute start request DUTqueue.ResponseWLexecHandle.handle_WLexec_start_request( self.msg, response, None) elif (msg_type == event.EV_WORKLIST_RESERVE_FAIL): log.debug_info("ACS server's response worklist reserve fail") ResponseClientHandle.handle_send_response(response, conn) # check worklist start response elif (msg_type == event.EV_WORKLIST_EXEC_START_RSP): log.debug_info( "ACS server's response worklist execute start suc") # call worklist execute request DUTqueue.ResponseWLexecHandle.handle_WLexec_request( self.dut_obj_handle, self.msg, response, conn) elif (msg_type == event.EV_WORKLIST_EXEC_START_FAIL): log.debug_info( "ACS server's response worklist execute start fail") ResponseClientHandle.handle_send_response(response, conn) # check worklist finish response elif (msg_type == event.EV_WORKLIST_EXEC_FINISH_RSP): log.debug_info( "ACS server's response worklist execute finish suc") elif (msg_type == event.EV_WORKLIST_EXEC_FINISH_FAIL): log.debug_info( "ACS server's response worklist execute finish fail") # check worklist build/bind/download response else: ResponseClientHandle.handle_send_response(response, conn) else: err_info = "Unsupport msg event group:%d" % msg_group log.debug_info(err_info) ResponseClientHandle.handle_except(self.msg, self.conn, err_info)
try: msg_obj = request_message.get(event.KEY_OBJECT) strio = StringIO(msg_obj) recv_data_obj = pickle.load(strio) except Exception, e: err_info = "keepalive_request_response: Unpickle event.KEY_OBJECT occurs error:%s" % e log.debug_err(err_info) request_message[event.KEY_MESSAGE] = message_type + 2 #发送响应消息 ResponseClientHandle.handle_send_response(request_message, conn) return True if not (isinstance(recv_data_obj, event.MsgQueryIsHang)): #构造错误的返回消息 error_info = "keepalive_request_response: Request message obj is not MsgQueryIsHang" log.app_err(error_info) request_message[event.KEY_MESSAGE] = message_type + 2 else: #构造正常响应消息 request_message[event.KEY_MESSAGE] = message_type + 1 #发送响应消息 ResponseClientHandle.handle_send_response(request_message, conn) return True
def handle_acsserver_response(self, message, conn): """ check acs server response data and call continue event """ response = ResponseClientHandle.switch_msg_stream_type_str2dict( message) msg_type = response.get(event.KEY_MESSAGE) msg_group = int(msg_type) & 0xFF00 #特殊处理AGENT 构建的给ACS的TIMOUT消息响应 if self.msg_type == event.EV_RPC_AGENT_TIMEOUT_POST: if msg_type == event.EV_RPC_AGENT_TIMEOUT_RSP: log.debug_info( "ACS server's response check agent timeout rpc request suc" ) else: log.debug_info( "ACS server's response check agent timeout rpc request fail" ) return #检查消息的合法性 #response message type error if not self.handle_response_message_type_verify( msg_group, msg_type, response): #check EV_RPC_CHECK_FAIL response if (msg_type == event.EV_RPC_CHECK_FAIL): tmp_obj = response.get(event.KEY_OBJECT) strio = StringIO(tmp_obj) tmp_msg_key_obj = pickle.load(strio) if not (isinstance(tmp_msg_key_obj, event.MsgUserRpcCheck)): err_info = "ACS server's rpc response message type error" log.debug_info(err_info) else: tmp_response_dict_ret = tmp_msg_key_obj.dict_ret if "str_result" in tmp_response_dict_ret: rc_str_result = tmp_response_dict_ret.get("str_result") err_info = "ACS server's rpc response check message fail, str_result: " + rc_str_result log.debug_info(err_info) else: err_info = "ACS server's rpc response message not found dict_ret data" log.debug_info(err_info) else: err_info = "ACS server's rpc response message type error" log.debug_info(err_info) ResponseClientHandle.handle_except(self.msg, self.conn, err_info) return #response rpc post if (msg_group == event.EVENT_QUERY_GROUP or msg_group == event.EVENT_CONFIGURE_GROUP): # send response to user or ACS ResponseClientHandle.handle_send_response(response, conn) elif (msg_group == event.EVENT_RPC_GROUP): if not DUTqueue.WAIT_RPC_RESPONSE_POST_FALG: # send response to user or ACS ResponseClientHandle.handle_send_response(response, conn) else: self.set_rpc_request_ACSServer_check_response("request_suc") #response worklist build/bind/reserve/start/finish info post elif (msg_group == event.EVENT_WORKLIST_GROUP): self.handle_ACS_worklist_info_response(response, conn) else: err_info = "Unsupport msg event group:%d" % msg_group log.debug_info(err_info) ResponseClientHandle.handle_except(self.msg, self.conn, err_info)