def test_Deserialize(self): """test HalMessage#DeSerialize, check the string message can't be deserialized, if not case fail check the unnormal binary HalMessage can't be deserialized, if not case fail. :keyword:HalMessage#DeSerialize :exception:"The input binary is None", "Cannot parse the message since the msgType" :parameter: :return: """ try: mas = HalMessage.DeSerialize("a") except Exception as e: self.assertEqual("The input binary is None", str(e)) try: msg = HalMessage.DeSerialize( "00000))))))00000))))))00000))))))00000))))))00000))))))00000))))))00000)))))" ")00000))))))00000))))))") except Exception as e: self.assertEqual( str(e).startswith( "Cannot parse the message since the msgType"), True)
def fault_management_cb(self, sock, mask): # pragma: no cover """Fault management callback. :param sock: zmq socket :param mask: event mask :return: """ if self.pushSock is not None and sock == self.pushSock.monitor: self.pushSock.monitorHandler(recv_monitor_message(sock)) return if self.pullSock is not None and sock == self.pullSock.monitor: self.pullSock.monitorHandler(recv_monitor_message(sock)) return if self.mgrConnection is not None and sock == self.mgrConnection.monitor: self.mgrConnection.monitorHandler(recv_monitor_message(sock)) return while sock.getsockopt(zmq.EVENTS) and zmq.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) self.logger.debug("###########Got a zmq msg:%s" % msg.msg) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) except zmq.ZMQError as e: self.logger.debug( "Getting an error when trying with nonblock read:" + str(e)) break except Exception as e: self.logger.error("Error happens, reason:%s" % str(e)) break
def openrpd_drv_hal_cb(self, sock, mask): self.logger.debug("Driver received hal cb event") if self.pushSock is not None and sock == self.pushSock.monitor: self.pushSock.monitorHandler(recv_monitor_message(sock)) return if self.pullSock is not None and sock == self.pullSock.monitor: self.pullSock.monitorHandler(recv_monitor_message(sock)) return if sock == self.mgrConnection.monitor: self.mgrConnection.monitorHandler(recv_monitor_message(sock)) return while sock.getsockopt(zmq.EVENTS) and zmq.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) self.logger.debug("Got a zmq msg:%s type:%s" % (msg.msg, msg.type)) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) except zmq.ZMQError as e: self.logger.debug( "Got an error when trying with nonblock read:" + str(e)) break except Exception as e: self.logger.error("Got an un-expected error:%s", str(e)) break
def register(self, clientID): """ send a register message to Hal and get the device ID from the Hal. :return: """ if clientID is None: registerMsg = HalMessage("HalClientRegister", ClientName=self.appName, ClientDescription=self.appDesc, ClientVersion=self.appVer) else: registerMsg = HalMessage("HalClientRegister", ClientName=self.appName, ClientDescription=self.appDesc, ClientVersion=self.appVer, ClientID=clientID) if self.mgrConnection is None: errMsg = "Cannot send the register since the mgr connection is not setup" self.logger.error(errMsg) raise HalClientError(errMsg) self.logger.debug("Send the register msg to Hal...") self.mgrConnection.send(registerMsg.Serialize()) bin = self.mgrConnection.recv() rsp = HalMessage.DeSerialize(bin) self.recvRegisterMsgCb(rsp)
def ClientRegisterRandom(): registerMsg = HalClientRegister() registerMsg.MsgType = "HalClientRegister" registerMsg.ClientName = "Test" + str(random.randint(1, 100)) registerMsg.ClientDescription = "This is a test msg" registerMsg.ClientVersion = "1.0" strMsg = registerMsg.SerializeToString() # dump the message hexdump.hexdump(strMsg) trans.send(strMsg) bin = trans.recv() rsp = HalMessage.DeSerialize(bin) print rsp.msg push = rsp.msg.PathFromHalToClient pull = rsp.msg.PathFromClientToHal context = HalTransport.context pullSock = context.socket(zmq.PULL) pushSock = context.socket(zmq.PUSH) pushSock.connect("ipc://" + pull) pullSock.connect("ipc://" + push) return (rsp.msg.ClientID, pullSock, pushSock)
def provmgr_cb(self, sock, mask): if self.pushSock is not None and sock == self.pushSock.monitor: self.pushSock.monitorHandler(recv_monitor_message(sock)) return if self.pullSock is not None and sock == self.pullSock.monitor: self.pullSock.monitorHandler(recv_monitor_message(sock)) return if self.mgrConnection is not None and sock == self.mgrConnection.monitor: self.mgrConnection.monitorHandler(recv_monitor_message(sock)) return while sock.getsockopt(zmq.EVENTS) and zmq.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) except zmq.ZMQError as e: self.logger.debug( "Got an error when trying with non-block read:" + str(e)) break except Exception as e: self.logger.warn( "Exception happens when provmgr hal recv socket, reason:%s" % str(e)) break
def start(self): """Start polling the transport socket. :return: """ self.logger.debug("Start the driver client poll...") self.connectionSetup() self.register(self.drvID) lastTimeout = time() while True: # Todo we should support quit flag? socks = self.poller.poll(self.pollTimeout) if time() - lastTimeout > self.pollTimeout / 1000: lastTimeout = time() # self.logger.debug("Got a timeout event") if self.recvNtf: rcp_msg = t_RcpMessage() rcp_msg.RpdDataMessage.RpdDataOperation = t_RpdDataMessage.RPD_CFG_READ rcp_msg.RcpMessageType = t_RcpMessage.RPD_CONFIGURATION rcp_msg.RpdDataMessage.RpdData.CopyFrom(config()) payload = rcp_msg.SerializeToString() self.sendCfgMsg(1025, payload) self.recvNtf -= 1 if not socks: continue for sock in socks: if self.pushSock is not None and sock == self.pushSock.monitor: self.pushSock.monitorHandler(recv_monitor_message(sock)) continue if self.pullSock is not None and sock == self.pullSock.monitor: self.pullSock.monitorHandler(recv_monitor_message(sock)) continue if sock == self.mgrConnection.monitor: self.mgrConnection.monitorHandler( recv_monitor_message(sock)) continue if socks[sock] == HalPoller.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) self.logger.debug("Got a zmq msg:%s" % msg.msg) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) else: self.logger.warn("Unsupported msg type:%s" % msg.type) except zmq.ZMQError as e: self.logger.debug( "Geting an error when trying with nonblock read:" + str(e)) except Exception as e: self.logger.debug("Geting an error:" + str(e)) continue
def start(self): """Start polling the transport socket. :return: """ self.logger.debug("Start the client poll...") self.connectionSetup() self.register(self.clientID) lastTimeout = time() sendOnce = False while True: # Todo we should support quit flag? socks = self.poller.poll(self.pollTimeout) if time() - lastTimeout > self.pollTimeout / 1000: lastTimeout = time() self.logger.debug("Got a timeout event") if not sendOnce: # self.sendCfgMsg(100, "hello") self.setHalDebugLevel("HalMain", logging.INFO) sendOnce = True if not socks: continue for sock in socks: # FIXME do we need to continue recv from the monitor interface? if self.pushSock is not None and sock == self.pushSock.monitor: self.pushSock.monitorHandler(recv_monitor_message(sock)) continue if self.pullSock is not None and sock == self.pullSock.monitor: self.pullSock.monitorHandler(recv_monitor_message(sock)) continue if self.mgrConnection is not None and sock == self.mgrConnection.monitor: self.mgrConnection.monitorHandler( recv_monitor_message(sock)) continue if socks[sock] == HalPoller.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) self.logger.debug("Got a zmq msg:%s" % msg.msg) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) else: self.logger.warn("Unsupported msg type:%s" % msg.type) except zmq.ZMQError as e: self.logger.debug( "Got an error when trying with non-block read:" + str(e)) except Exception as e: self.logger.error("Error happens, reason:%s" % str(e)) continue
def test_three_clients_send_and_recv_failed(self): sender_client = HalClientTest( "sender client", "sender client, used to send a hello msg to recv client", "1.0.0", (1, 2, 100, 102), (1, ), (1, )) sender_client.connect_to_hal() recv_client1 = HalClientTest( "receiver client", "receiver client, used to receive a hello msg from sender client", "1.0.0", (1024, ), (1, ), (1, )) recv_client1.connect_to_hal() recv_client2 = HalClientTestErrorRsp( "receiver client", "receiver client, used to receive a hello msg from sender client", "1.0.0", (1024, ), (1, ), (1, )) recv_client2.connect_to_hal() sender_client.sendCfgMsg(1024, "hello, I am a sender~") content = recv_client1.pullSock.recv() msg = HalMessage.DeSerialize(content) self.assertEqual(msg.msg.CfgMsgType, 1024) recv_client1.recvCfgMsgCb(msg) content = recv_client2.pullSock.recv() msg = HalMessage.DeSerialize(content) self.assertEqual(msg.msg.CfgMsgType, 1024) recv_client2.recvCfgMsgCb(msg) # try to receive the msg from sender content = sender_client.pullSock.recv() msg = HalMessage.DeSerialize(content) self.assertEqual(msg.msg.CfgMsgType, 1024) self.assertEqual(msg.msg.Rsp.Status, HalCommon_pb2.FAILED) recv_client1.close_connection() recv_client2.close_connection() sender_client.close_connection()
def connect_to_hal(self): self.connectionSetup() self.register(self.drvID) i = 0 max_times = 10 expected_msgs = [ "HalClientInterestNotificationCfgRsp", "HalClientHelloRsp" ] while expected_msgs != []: socks = self.poller.poll(1000) print socks i += 1 if i > max_times: self.logger.error("break while due to reach %d times" % max_times) break if not socks: continue for sock in socks: if self.pushSock is not None and sock == self.pushSock.monitor: self.pushSock.monitorHandler(recv_monitor_message(sock)) continue if self.pullSock is not None and sock == self.pullSock.monitor: self.pullSock.monitorHandler(recv_monitor_message(sock)) continue if self.mgrConnection is not None and sock == self.mgrConnection.monitor: self.mgrConnection.monitorHandler( recv_monitor_message(sock)) continue if socks[sock] == HalPoller.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) print msg.msg self.logger.debug("Got a zmq msg:%s" % msg.msg) if msg.msg.MsgType in expected_msgs: expected_msgs.remove(msg.msg.MsgType) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) else: self.logger.error("Unsupported msg type:%s" % msg.type) except zmq.ZMQError as e: self.logger.debug( "Got an error when trying with non-block read:" + str(e)) except Exception as e: self.logger.error("Error happens, reason:%s" % str(e)) continue
def hal_message_cb(self, sock): try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) self.logger.debug("###########Got a zmq msg:%s" % msg.msg) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) except zmq.ZMQError as e: self.logger.debug( "Getting an error when trying with nonblock read:" + str(e)) return False except Exception as e: self.logger.error("Error happens, reason:%s" % str(e)) return False return True
def recvMsg(self, timeout=None): if self.pullSock: try: bin = self.pullSock.recv() except Exception as e: print("Got exception when receiving the msg, reason:%s" % str(e)) return None rsp = HalMessage.DeSerialize(bin) if rsp.msg.Rsp.Status != HalCommon_pb2.SUCCESS: self.logger.error("Get rsp msg fail, reason[%s]" % rsp.msg.Rsp.ErrorDescription) return None cli_msg = t_CliMessage() cli_msg.ParseFromString(rsp.msg.CfgMsgPayload) return cli_msg else: self.logger.error("Cannot receive msg since the pull socket is NULL") return None
def RecvHalMsg(self, timeout=None): hal_ipc = self.cli.hal_ipc if hal_ipc.pullSock: try: bin = hal_ipc.pullSock.recv() except Exception as e: print("Got exception when receiving the msg, reason:%s" % str(e)) return None rsp = HalMessage.DeSerialize(bin) if rsp.msg.Rsp.Status != HalCommon_pb2.SUCCESS: hal_ipc.logger.error("Get rsp msg fail, reason[%s]" % rsp.msg.Rsp.ErrorDescription) return None return rsp.msg.CfgMsgPayload else: hal_ipc.logger.error( "Cannot receive msg since the pull socket is NULL") return None
def connect_to_hal(self): self.connectionSetup() self.register(self.drvID) i = 0 while i < 5: socks = self.poller.poll(1000) print socks i += 1 if not socks: continue for sock in socks: if self.pushSock is not None and sock == self.pushSock.monitor: self.pushSock.monitorHandler(recv_monitor_message(sock)) continue if self.pullSock is not None and sock == self.pullSock.monitor: self.pullSock.monitorHandler(recv_monitor_message(sock)) continue if self.mgrConnection is not None and sock == self.mgrConnection.monitor: self.mgrConnection.monitorHandler( recv_monitor_message(sock)) continue if socks[sock] == HalPoller.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) print msg.msg self.logger.debug("Got a zmq msg:%s" % msg.msg) if msg.type in self.HalMsgsHandler: handler = self.HalMsgsHandler[msg.type] handler(msg) else: self.logger.error("Unsupported msg type:%s" % msg.type) except zmq.ZMQError as e: self.logger.debug( "Got an error when trying with non-block read:" + str(e)) except Exception as e: self.logger.error("Error happens, reason:%s" % str(e)) continue
def test_two_client_send_and_recv(self): sender_client = HalClientTest( "sender client", "sender client, used to send a hello msg to recv client", "1.0.0", (1, 2, 100, 102), (1, ), (1, )) sender_client.connect_to_hal() recv_client = HalClientTest( "receiver client", "receiver client, used to receive a hello msg from sender client", "1.0.0", (1024, ), (1, ), (1, )) recv_client.connect_to_hal() sender_client.sendCfgMsg(1024, "hello, I am a sender~") content = recv_client.pullSock.recv() msg = HalMessage.DeSerialize(content) self.assertEqual(msg.msg.CfgMsgType, 1024) recv_client.close_connection() sender_client.close_connection()
def getClientstats(self, clientId): """ Send a client statistics request message :return: """ if self.disconnected: self.logger.error("The client is on disconencted state," " skip to send the message.") return None self.logger.debug("Send a client statistics message to Hal") statsQueryMsg = HalMessage("HalAgentStatsReq", ClientID=clientId) self.mgrConnection.send(statsQueryMsg.Serialize()) try: bin = self.mgrConnection.recv() except Exception as e: print("Got exception when receiving the msg, reason:%s" % str(e)) return None rsp = HalMessage.DeSerialize(bin) if rsp.msg.MsgType != "HalAgentStatsRsp": self.logger.error("Cannot Query client statistics, " "reason[msgType mismatch:%s]" % rsp.msg.MsgType) return None return rsp
def clientQuery(self): """ Send a client query message to get all registered client info :return: """ if self.disconnected: self.logger.error("The client is on disconencted state," " skip to send the message.") return None self.logger.debug("Send a client query message to Hal") clientQueryMsg = HalMessage("HalClientQuery", ClientID=self.clientID) self.mgrConnection.send(clientQueryMsg.Serialize()) try: bin = self.mgrConnection.recv() except Exception as e: print("Got exception when receiving the msg, reason:%s" % str(e)) return None rsp = HalMessage.DeSerialize(bin) if rsp.msg.MsgType != "HalClientQueryRsp": self.logger.error("Cannot Query client, " "reason[msgType mismatch:%s]" % rsp.msg.MsgType) return None return rsp
def _mainLoop(): """This fucntion create the HalClient manager, and then will loop the poller. Also this function will dispatch the following events to corresponding handler: * timeout: * will process the agent timeout list * will process the agent resend list * HalMessage events: * the function will decode all the incoming events and invoke the corresponding agent, and invoke corresponding handler. * monitor Events: * These messages are from the low level queue events, such as the reconnect/close/disconnect. These messages are handled by the corresponding agents. Please note that, in Hal design, everything are in a single thread, it is stateless and trigger by the events. :return: """ if logger is None: sys.exit(-1) logger.info("Start the poller...") HalGlobal.gPoller = HalPoller() logger.info("Start the client manager...") HalGlobal.gClientMgr = HalClientManager(HalGlobal.gPoller) logger.info("Staring poll all the events...") lastcalledTime = time() while not HalGlobal.StopHal: socks = HalGlobal.gPoller.poll(HalGlobal.gTimeout) # for timeout events if time() - lastcalledTime > HalGlobal.gTimeout / 1000: lastcalledTime = time() logger.debug("Got a timeout event") # for timeout list for agent in HalGlobal.gAgentDB: handler = getattr(agent, "processTimeoutObjs") handler() # for resend for clientID in HalGlobal.gClientDB: handler = getattr(HalGlobal.gClientDB[clientID]["agent"], "processResendList") handler() if socks is None: continue # For the HalMessage path for sock in socks: # For the low-level queue events if sock in HalGlobal.gMonitorSocketMappingTable: logger.debug("Got a monitor event...") handler = getattr(HalGlobal.gMonitorSocketMappingTable[sock], "monitorHandler") handler(recv_monitor_message(sock)) continue # For Halmessages if socks[sock] == HalPoller.POLLIN: try: bin = sock.recv(flags=zmq.NOBLOCK) msg = HalMessage.DeSerialize(bin) # logger.debug("Got a zmq msg:for remote, msg %s" % msg.msg) if msg.type in HalGlobal.gHandleTable and sock in HalGlobal.gSocketAgentMappingTable: func = getattr( HalGlobal.gSocketAgentMappingTable[sock], HalGlobal.gHandleTable[msg.type]) func(msg) else: logger.warn( "Cannot handle the POLLIN events for message:%s", msg) if sock == HalGlobal.gClientMgr.transport.socket: sock.send("dummy") HalGlobalStats.NrErrorMsgs += 1 except zmq.ZMQError as e: logger.debug( "Got an error when trying with non-block read:" + str(e)) except Exception as e: logger.warn("Get an unhandled exception:%s" % str(e)) else: logger.warn("Cannot handle the event, No handler for it:%s" % str(socks[sock]))
def main(): """Everything starts here.""" global logger parser = argparse.ArgumentParser("Hal args parser") parser.add_argument("--conf", metavar='C', type=str, help="Hal configuration path") args = parser.parse_args() config = _parseConfiguraion(args.conf) if config is None: sys.stderr.write( "Cannot load the configuration or the configuration format is not correct" ) sys.exit(-1) # setup the log setup_logging('HAL', filename="hal.log") # setup the logger logger = logging.getLogger("HalMain") # setup the Dispatcher HalGlobal.gDispatcher = HalDispatcher() # setup the database if "db" not in config: sys.stderr.write( "Cannot find the redis config information, using the default configuration" ) HalGlobal.gHalMsgDbConnection = HalDatabase("/tmp/redis.sock", 30, 12) HalGlobal.gHalClientDbConnection = HalDatabase("/tmp/redis.sock", 30, 11) else: dbConf = config["db"] logger.info( "Setting up the Hal database:\n\tPath:%s\n\tmsgDB:%d\n\tindexDB:%d" % (dbConf["address"], dbConf["msgDB"], dbConf["indexDB"])) HalGlobal.gHalMsgDbConnection = HalDatabase(dbConf["address"], dbConf["timeout"], dbConf["msgDB"]) HalGlobal.gHalClientDbConnection = HalDatabase(dbConf["address"], dbConf["timeout"], dbConf["indexDB"]) # Getting the un-handled message from the DB, we don't need to clean up # the DB since we have set the expire for keys if not HalGlobal.gHalMsgDbConnection.isDatabaseEmpty(): logger.info("Start to load all the resend messages to runtime memory") msgs = HalGlobal.gHalMsgDbConnection.listAllMsgs() for msg in msgs: logger.info("Loading message %s" % msg["Key"]) key = msg["Key"] gpbMsg = msg["Msg"] try: HalMsg = HalMessage.DeSerialize(gpbMsg) logger.debug("Got a zmq msg:%s" % HalMsg.msg) HalGlobal.gRestartResendMsg[key] = HalMsg except Exception as e: logger.error("Error happened when handling msg, error info:%s", str(e)) # get all the contents and put it in gClientIndex if not HalGlobal.gHalClientDbConnection.isDatabaseEmpty("ClientIndex"): logger.info( "Start to getting previous registered client ID and index... ") msgs = HalGlobal.gHalClientDbConnection.listAllMsgs("ClientIndex") for key in msgs: HalGlobal.gClientIndex[key] = msgs[key] _mainLoop()
def test_createHalMessage(self): """test create HalMessage. check the HalUSDriverRegisterRsp message can be serialized, if not case fail check the unnormal message can't be created, if not case fail check the none message can't be serialized, if not case fail. :keyword:createHalMessage :exception:assertEqual(regRsp.Serialize(), regRsp1.Serialize()), "Cannot create a msg since we can not find the msg definition", "Cannot serializing the msg since the msg is None", :parameter: :return: """ msg = HalMessage("HalClientRegister", ClientName="abc", ClientDescription="abc", ClientVersion="1.2.3", ClientSupportedMessages=[1, 2, 3], ClientSupportedNotificationMessages=[1, 2, 3]) msg = HalMessage("HalClientRegister", ClientName="abc", ClientDescription="abc", ClientVersion="1.2.3", ClientSupportedMessages=[1, 2, 3], ClientSupportedNotificationMessages=[]) msg.Serialize() regRsp = HalMessage("HalClientRegisterRsp", Rsp={ "Status": HalCommon_pb2.SUCCESS, "ErrorDescription": "Successful" }, ClientID="123", PathFromHalToClient="123", PathFromClientToHal="abc'") bin = regRsp.Serialize() regRsp1 = HalMessage.DeSerialize(bin) self.assertEqual(regRsp.Serialize(), regRsp1.Serialize()) # test line 85 rsp = HalMessage("HalClientQueryRsp", ClientID="123", Clients=[{ "ClientID": "clientID", "ClientName": "msg.msg.ClientName", "ClientDescription": "msg.msg.ClientDescription", "ClientVersion": "msg.msg.ClientVersion", "ClientSupportedMessages": [12, 3], "ClientSupportedNotificationMessages": [1, 2] }, { "ClientID": "clientID", "ClientName": "msg.msg.ClientName", "ClientDescription": "msg.msg.ClientDescription", "ClientVersion": "msg.msg.ClientDriverVersion", "ClientSupportedMessages": [12, 3], "ClientSupportedNotificationMessages": [1, 2] }]) try: rsp = HalMessage("HalClientInterestNotificationCfgRsp", ClientID="123", Rsp={ "Status": 1, "ErrorDescription": [] }) rsp = HalMessage("HalClientInterestNotificationCfgRsp", ClientID="123", Rsp={ "Status": 1, "ErrorDescription": [1, 2, 3] }) except AttributeError: pass try: msg = HalMessage("test") except Exception as e: self.assertEqual( str(e), "Cannot create a msg since we can not find the msg definition") try: rsp.msg = None rsp.Serialize() except Exception as e: self.assertEqual( str(e), "Cannot serializing the msg since the msg is None") """
registerMsg.ClientName = "Test" registerMsg.ClientDescription = "This is a test msg" registerMsg.ClientVersion = "1.0" registerMsg.ClientSupportedMessages.append(1) registerMsg.ClientSupportedMessages.append(123) registerMsg.ClientSupportedNotificationMessages.append(11) registerMsg.ClientSupportedNotificationMessages.append(12) strMsg = registerMsg.SerializeToString() # dump the message hexdump.hexdump(strMsg) trans.send(strMsg) bin = trans.recv() rsp = HalMessage.DeSerialize(bin) ClientID = rsp.msg.ClientID push = rsp.msg.PathFromHalToClient pull = rsp.msg.PathFromClientToHal print ClientID print pull print push # Create the Pull interface context = HalTransport.context pullSock = context.socket(zmq.PULL) pushSock = context.socket(zmq.PUSH)