aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api/python/pneum/api-gen.py
AgeCommit message (Collapse)AuthorFilesLines
2016-10-12VPP-362 Implement dumping of LISP adjacenciesFilip Tehlar1-0/+2
Change-Id: Ieea56f3bf9e749878d9f2b35d39d9f7a9cdabde4 Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
2016-09-30VPP-120: include custom types to Python representation of vpe.apiMarek Gradzki1-1/+1
Change-Id: Ide97a8bf55d3baf41a1e86af2c67c6b7b26b657a Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
2016-06-24VPP-118: add support for variable length arrays to jvppMarek Gradzki1-1/+1
* extends VPP's message definition language with the following syntax: u32 count: u8 array[count]; which is traslated to: u32 count; u8 array[0]; but now, python API representation generated by vppapigen contains information about where the array length is stored. * modifies existing response messages to use the new syntax Change-Id: I68210bc7a3a755d03d067e9b79a567f40e2d31f3 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
2016-04-28Python API: Fix mistaken removal of '_' in field names.Ole Troan1-1/+5
Change-Id: I1e39970bc6ded9e6da64385b2289321ba43bebfd Signed-off-by: Ole Troan <ot@cisco.com>
2016-04-25Python-API: Python 2 support.Ole Troan1-1/+1
Change-Id: I6bc656caf22e284233e27f9e003f11502f306c11 Signed-off-by: Ole Troan <ot@cisco.com>
2016-04-25Python-API: Support for zero-length arrays from caller to VPP. (Previously ↵Ole Troan1-20/+26
only VPP to caller was supported.) Change-Id: Id660caeb780f3b26cc091467291463980f485178 Signed-off-by: Ole Troan <ot@cisco.com>
2016-04-20Python-API: Inital commit of Python bindings for the VPP API.Ole Troan1-0/+337
See: https://wiki.fd.io/view/VPP/Python_API Change-Id: If135fc32208c7031787e1935b399d930e0e1ea1f Signed-off-by: Ole Troan <ot@cisco.com>
pan class="o">.setup_custom_logger('TRexServer') logger = logging.getLogger('TRexServer') class ZmqMonitorSession(threading.Thread): def __init__(self, trexObj , zmq_port): super(ZmqMonitorSession, self).__init__() self.stoprequest = threading.Event() self.first_dump = True self.zmq_port = zmq_port self.zmq_publisher = "tcp://localhost:{port}".format(port=self.zmq_port) self.trexObj = trexObj self.expect_trex = self.trexObj.expect_trex # used to signal if TRex is expected to run and if data should be considered self.decoder = JSONDecoder() self.zipped = zipmsg.ZippedMsg() logger.info("ZMQ monitor initialization finished") def run(self): try: self.context = zmq.Context() self.socket = self.context.socket(zmq.SUB) logger.info("ZMQ monitor started listening @ {pub}".format(pub=self.zmq_publisher)) self.socket.connect(self.zmq_publisher) self.socket.setsockopt(zmq.SUBSCRIBE, b'') while not self.stoprequest.is_set(): try: zmq_dump = self.socket.recv() # This call is BLOCKING until data received! if self.expect_trex.is_set(): self.parse_and_update_zmq_dump(zmq_dump) logger.debug("ZMQ dump received on socket, and saved to trexObject.") except Exception as e: if self.stoprequest.is_set(): # allow this exception since it comes from ZMQ monitor termination pass else: logger.error("ZMQ monitor thrown an exception. Received exception: {ex}".format(ex=e)) raise except Exception as e: logger.error('ZMQ monitor error: %s' % e) self.trexObj.zmq_error = e def join(self, timeout=None): self.stoprequest.set() logger.debug("Handling termination of ZMQ monitor thread") self.socket.close() self.context.term() logger.info("ZMQ monitor resources has been freed.") super(ZmqMonitorSession, self).join(timeout) def parse_and_update_zmq_dump(self, zmq_dump): unzipped = self.zipped.decompress(zmq_dump) if unzipped: zmq_dump = unzipped dict_obj = self.decoder.decode(zmq_dump.decode(errors = 'replace')) if type(dict_obj) is not dict: raise Exception('Expected ZMQ dump of type dict, got: %s' % type(dict_obj)) # add to trex_obj zmq latest dump, based on its 'name' header if dict_obj != {}: self.trexObj.zmq_dump[dict_obj['name']] = dict_obj if self.first_dump: # change TRexStatus from starting to Running once the first ZMQ dump is obtained and parsed successfully self.first_dump = False self.trexObj.set_status(TRexStatus.Running) self.trexObj.set_verbose_status("TRex is Running") logger.info("First ZMQ dump received and successfully parsed. TRex running state changed to 'Running'.") if __name__ == "__main__": pass