summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/vpp_transport_socket.py
AgeCommit message (Collapse)AuthorFilesLines
2022-05-10tests: replace pycodestyle with blackKlement Sekera1-19/+15
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2021-03-16api: allow specifying no timeoutKlement Sekera1-1/+1
This functionality is used in make test when DEBUG=gdb is used. Type: fix Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I1339e6460aa624a3bcb4b03db46991590e126f92
2021-03-15tests: use socket transport instead of shared memoryOle Troan1-2/+2
Type: improvement Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I9e65c94a5a05047a5104e9361ea36eac77b40442 Signed-off-by: Ole Troan <ot@cisco.com>
2020-12-18papi: remove import vpp_transport_socketPaul Vinciguerra1-2/+2
See discussion in: https://gerrit.fd.io/r/c/vpp/+/19472 Type: refactor Change-Id: Icbf686f615f13898d12fd211f68c3498d373a5d7 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-03papi: remove python2 patternsPaul Vinciguerra1-5/+2
Type: refactor Change-Id: I541759b4b788acf08599661eb9e7abc58e9283d2 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-03papi: allow client control over loggersPaul Vinciguerra1-0/+3
This change enables a client to set debug levels globally as well as individually. exposes loggers as vpp_papi vpp_papi.serializer vpp_papi.transport Type: improvement Change-Id: Ib6bd1a1f552b51a22c9fe3de819a5fb970963ae5 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-12-03papi: add a per-call _timeout optionPaul Vinciguerra1-2/+4
add the ability to override the default timeout value on a per-call basis. Use: rv = self.vapi.papi.cli_inband(cmd='wait 10', _timeout=15) Type: feature Change-Id: Ia90a58586a1f63e02118599a2a4b7141e5a0b90d Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-10-14papi: fix socket sendall callsVratko Polak1-4/+6
No point in checking the return value, as .sendall() raises on error (and the previous check was missing "not"). Type: fix Change-Id: I9e07709ddd7093f91ffef87808abbab264b8aa5a Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-10-11papi: harden socket handlingVratko Polak1-18/+24
In the previous implementation of socket transport for PAPI, socket methods .send and .recv_into were used. But they are not guaranteed to send/receive all the data for the full message. The receive part contained a loop, but it handled only the main message, not the header. This patch replaces .send with .sendall and uses newly defined _read_fixed method. Also, removed Paul from maintainers, as he is not active much, lately. Type: fix Change-Id: Iae1a68bf8f9e666856b7c7d62ebfe22defc5dfe1 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-09-04api: memclnt api use string type.Ole Troan1-1/+1
Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Idad79286b7730c8e85202c4b8e675ea50f8bbc48 Signed-off-by: Ole Troan <ot@cisco.com>
2019-06-26papi: prevent message_table inconsistenciesVratko Polak1-0/+2
Socket transport is maintaining message_table to map message name to index. After disconnect and re-connect, the VPP may have been restarted with different set of plugins, so message_table has to be wiped. + Edited MAINTAINERS to recognize "papi" as a separate component. Type: fix Change-Id: I1f16ad7ee0886e03bbc6a17bcddbfcaa322354e5 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-06-18misc: vpp_papi- add tests, clean up pep8Paul Vinciguerra1-0/+2
Type: test Change-Id: Ic81bd4a9eba3c89a746e7a9b9e471b59cd87fa40 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-06-12papi: make socket disconnect more robustVratko Polak1-1/+1
Previusly, read error could happen before message_thread starts, so do not attempt to join in that case. Change-Id: Ie119916831e320e38eb02e48515b4c6a9cb937e5 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-06-07API: Add support for "defaults"Ole Troan1-6/+6
Add support in the API language for specifying a field default. Add default support in Python binding. define foo { u16 mtu [default = 1500]; }; This is client side only. I.e. if the mtu argument is not passed to the foo function, the client language binding will set it default to 1500. Change-Id: I5df43f3cd87cb300b40ca38e15dcab25b40e424a Signed-off-by: Ole Troan <ot@cisco.com>
2019-05-28papi: avoid IOError on disconnectVratko Polak1-5/+14
Change-Id: I331efb20b98a7e3c507d9158d0221ee7d5353b18 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-05-10vpp_transport_socket: make connect more resilientVratko Polak1-11/+32
This should make connect() partially retriable, at least against "No such file or directory on socket", and when disconnect() is called before retrying connect(). Added TODOs for future improvements. Change-Id: I5ee727fbc17d66446589b8c781f270055187db68 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-05-09Improve exceptions in vpp_transport_socket.pyVratko Polak1-2/+4
Added TODOs for further improvements. Change-Id: I6724dd8b3de5537518a5c6e0ee9abe72f57b273e Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-05-09Fix copypaste in vpp_papi/vpp_transport_socket.pyVratko Polak1-3/+2
Change-Id: I80e6ccd6f63e3eca2ba723f3b39a47475ae9aed0 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-05-08Fix Exception typo in vpp_papi/vpp_transport_socket.py.Paul Vinciguerra1-1/+1
Change-Id: I80ef74abcb14136984a4c94ba60414a1348015d3 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-05-07Allow repeated connects on PAPI socket transportVratko Polak1-1/+10
The previous implementation fails with RuntimeError("cannot set daemon status of active thread") when a second connect() follows first disconnect(). Change-Id: I671005923eb020130a57b0b484a3386a05d7be33 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-04-23API: Python and Unix domain socket improvementOle Troan1-27/+19
Handle the case where buffer overflows. Then SOCK_SEQPACKET assumption that multiple API messages are not returned by recv() is broken. Use SOCK_STREAM for API exchanges instead. Add support for running tests over sockets. make test SOCKET=1 Change-Id: Ibe5fd69b1bf617de4c7ba6cce0a7c2b3f97a2821 Signed-off-by: Ole Troan <ot@cisco.com>
2018-12-13API: Use string type instead of u8.Ole Troan1-2/+1
The new string type is modelled after string in proto3. It is always variable length. Change-Id: I64884067e28a80072c8dac31b7c7c82d6e306051 Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Michal Cmarada <mcmarada@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com>
2018-11-29vpp_papi: Add custom exceptions.Paul Vinciguerra1-4/+11
This patchset adds and raises the following custom exception classes: * class VPPApiError(Exception): * class VPPNotImplementedError(NotImplementedError): * class VPPIOError(IOError): * class VPPRuntimeError(RuntimeError): * class VPPValueError(ValueError): * class VPPSerializerValueError(ValueError): * class VPPStatsIOError(IOError): * class VPPStatsClientLoadError(RuntimeError): * class VppTransportShmemIOError(IOError): * class VppTransportSocketIOError(IOError) Change-Id: Ia40900fd2dcef148d01125d6c691329fc666901e Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-11-29vpp_papi: Fix: raise NotImplemented.Paul Vinciguerra1-1/+1
'raise NotImplemented' should be 'raise NotImplementedError'. NotImplemented is not part of the Exception heirarchy. Change-Id: I7fb647f1d56e689fafa2cd9a5566da826def072b Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-11-29VPP-1508: vpp_transport_socket.py fix importPaul Vinciguerra1-1/+4
Import queue in an py2-py3 compatable way. Change-Id: I83f166a959c4ee55438e3997edbcb596dc72059f Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-11-28vpp_papi: Reserved keywords.Paul Vinciguerra1-1/+1
'async' and 'await' are reserved keywords starting with Python 3.7. This change is necessary to support VPP-1508. Change-Id: Iba2b3aef98a0ecaabc1622719b364f8f4ab5d5a3 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-11-28vpp_papi: Use new style classes.Paul Vinciguerra1-1/+1
Python2 defaults to old style classes to maintain compatability with python 2.1. Moving to new style classes will ensure consistent behavior across interpreters. Change-Id: I89493d608d1edb63989000c17a9566a97785a4aa Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-11-05Provide return value for PAPI disconnect()Igor Mikhailov (imichail)1-0/+2
Change-Id: I209f570634636725ce8fda5f61e900a71227b888 Signed-off-by: Igor Mikhailov (imichail) <imichail@cisco.com>
2018-10-16PAPI: Add timeout support for socket transportOle Troan1-3/+6
Change-Id: I0402989e0ac738cab2f918e6e3d73c571457c08e Signed-off-by: Ole Troan <ot@cisco.com>
2018-10-02PAPI: Use UNIX domain sockets instead of shared memoryOle Troan1-0/+176
Adds support for running the API purely across Unix domain sockets. Usage: vpp = VPP(use_socket=True) Change-Id: Iafc1301e03dd3edc3f4d702dd6c0b98d3b50b69e Signed-off-by: Ole Troan <ot@cisco.com>