aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/vpp_papi.py
AgeCommit message (Collapse)AuthorFilesLines
2019-05-28papi: avoid IOError on disconnectVratko Polak1-1/+4
Change-Id: I331efb20b98a7e3c507d9158d0221ee7d5353b18 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-05-23vpp_papi: Do not raise before find_api_dir()Vratko Polak1-4/+1
The change https://gerrit.fd.io/r/18352 has introduced a check which raises when neither apifiles nor apidir are set. This change removes that check, as it broke CSIT. If such a check is intended, find_api_dir() should be removed. Also, make sure you do not break CSIT next time. Change-Id: I0faab7c41d199e3aa5d5bc6aab0defd1ab9e10da Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2019-05-15vpp_papi: remove dependency on environment var. VPP_API_DIR.Paul Vinciguerra1-6/+9
Change-Id: I9e3af8674e8aae27079fd03f6286f165d777814f Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-03-20vpp_papi: Expose the list of field attributes to the client.Paul Vinciguerra1-0/+1
Change-Id: I7aba1760f68798fc5bea1244ce798e4b528a4df4 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-03-19vpp_papi: specify encoding for .encode()/.decode()Paul Vinciguerra1-4/+5
py2 defaults to 'ascii', py3 defaults to 'utf-8'. Change-Id: Ib76d0ec56f24535e4bafd397cc6fb5e85967d508 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-03-04test framework: add factory function and default parametersOle Troan1-0/+2
This is the first step to be able to remove all the API message wrappers in vpp_papi_provider.py. This allows to remove all functions that do not override parameters (different from zero), and a separate dictionary for messages requiring different defaults. The general requirement is that all new tests should use named arguments directly. Not positional arguments through the wrapper. Note when removing functions, the calls in vpp_papi_provider wrappers do not necessarily follow message order. Change-Id: If64916c07f8622c138db3a9d7c4a98b93a058e68 Signed-off-by: Ole Troan <ot@cisco.com>
2019-02-28vpp_papi.py: Change VppEnum from explicit metaclass to metaclass ↵Paul Vinciguerra1-4/+11
wrapper/decorator. Change-Id: Iab41bb972e3c7ec005a1a13d5a25f654ae8c3932 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-12-18PAPI: Add MACAddress object wrapper for vl_api_mac_address_tOle Troan1-0/+2
Change the definition of vl_api_mac_address_t to an aliased type. Change-Id: I1434f316d0fad6a099592f39bceeb8faeaf1d134 Signed-off-by: Ole Troan <ot@cisco.com>
2018-12-13API: Use string type instead of u8.Ole Troan1-3/+43
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-12-12PAPI: Allow ipaddress object as argument and return values from API callsOle Troan1-10/+12
The API calls that use any of vl_api_address_t, vl_api_ip4_address, vl_api_ip6_address_t, vl_api_prefix_t, vl_api_ip4_prefix_t, vl_api_ip6_prefix_t now accepts either the old style dictionary, a text string (2001:db8::/32) or an ipaddress ojbect. Unless it is called with '_no_type_conversion':True, it will also return an appropriate ipaddress object. Change-Id: I84e4a1577bd57f6b5ae725f316a523988b6a955b Signed-off-by: Ole Troan <ot@cisco.com>
2018-12-10Python API: Use services to determine stream RPCOle Troan1-4/+11
The services {} definitions contain which APIs are streaming. In addition only create function definition for the client side (not for reply messages). Change-Id: I8e83d35386cdd9ebee83d4571eaebdc6dff19e82 Signed-off-by: Ole Troan <ot@cisco.com>
2018-11-29vpp_papi: Add custom exceptions.Paul Vinciguerra1-12/+37
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-29API: Add support for type aliasesOle Troan1-2/+9
Previously all types are compound. This adds support for aliases, so one can do things like: typedef u32 interface_index; or typedef u8 ip4_address[4]; Change-Id: I0455cad0123fc88acb491d2a3ea2725426bdb246 Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Klement Sekera <ksekera@cisco.com>
2018-11-28vpp_papi: Use new style classes.Paul Vinciguerra1-2/+2
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-05Alter logging semantics for VPP PAPI objectIgor Mikhailov (imichail)1-1/+1
Restore parts of commit d0e812f wiped out by a7564e80 The full description of the change is in d0e812f Change-Id: I632476cb10678a725396462f90f9b0bea9e572fa Signed-off-by: Igor Mikhailov (imichail) <imichail@cisco.com>
2018-10-22PAPI: Add support for format/unformat functions.Ole Troan1-0/+1
With the introduction of new types, like vl_api_address_t it is now possible to call a message using one of those functions with a string representation. E.g. for an IP address ip_add_address(address="1.1.1.1/24") The language wrapper will automatically convert the string into the vl_api_address_t representation. Currently the caller must do the reverse conversion from the returned named tuple with the unformat function. rv = get_address_on_interface(sw_if_index=1) print(VPPFormat.unformat(rv.address)) Change-Id: Ic872b4560b2f4836255bd5260289bfa38c75bc5d Signed-off-by: Ole Troan <ot@cisco.com>
2018-10-18PAPI: Expose API enums to tests / applicationsOle Troan1-16/+33
e.g: from vpp_papi import VppEnum VppEnum.vl_api_address_family_t.ADDRESS_IP4 Change-Id: I10c22d57234a1a06e98a889cf80b19085b468ed3 Signed-off-by: Ole Troan <ot@cisco.com>
2018-10-02PAPI: Use UNIX domain sockets instead of shared memoryOle Troan1-109/+37
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>
2018-09-07PAPI: Unpack embedded types with variable length arrays.Ole Troan1-4/+2
Change-Id: Ic952ed5b837ac8409fd95e2b5cb92eb028ba0c40 Signed-off-by: Ole Troan <ot@cisco.com>
2018-08-23CSIT-1139: Implement parallel test executionjuraj.linkes1-1/+1
The implementation of parallel test execution in VPP Test Framework. - VPPTestCase test methods are grouped together - tests are running in separate processes - VPP instances spawned by tests are assigned to different cores - output from these processes is redirected through pipes and printed out testcase by testcase - TEST_JOBS env var is used to specify the number of parallel processes - improved test summary - a bit of code cleanup Change-Id: I9ca93904d9fe2c3daf980500c64a8611838ae28c Signed-off-by: juraj.linkes <juraj.linkes@pantheon.tech>
2018-08-09PAPI: Python 3.7 uses async keyword.Ole Troan1-11/+11
Change-Id: I01e99c85598a7cb5bc1a506c7fd1fc3f6789d72e Signed-off-by: Ole Troan <ot@cisco.com>
2018-07-18vpp-api: improve naming for easier debuggingKlement Sekera1-2/+2
Change-Id: I487ccf2adabfbd22dac9f492ecff679d38046724 Signed-off-by: Klement Sekera <ksekera@cisco.com>
2018-06-22Python API: Add enum and union support.Ole Troan1-0/+679
As well as a rewrite of the encoders/decoders to make it more readable and extensible. (Re-commit after fix to verify build.) Change-Id: Ic244d3cebe070bb2570491f8a24f4a1e203f889a Signed-off-by: Ole Troan <ot@cisco.com>
2018-06-18Revert "Python API: Add enum and union support."Ole Trøan1-678/+0
This reverts commit a5ee900fb75201bbfceaf13c8bc57a13ed094988. Some of the unit tests breaks. Backing out until fixed. Change-Id: I1846fb417db44a2a772f7b59cda8bcfe6d39f8c3 Signed-off-by: Ole Troan <ot@cisco.com>
2018-06-17Python API: Add enum and union support.Ole Troan1-0/+678
As well as a rewrite of the encoders/decoders to make it more readable and extensible. Change-Id: I253369ac76303922bf9c11377622c8974fa92f19 Signed-off-by: Ole Troan <ot@cisco.com>
2017-03-15Python API: Change from cPython to CFFI.Ole Troan1-599/+0
Change-Id: I03e52466fb3f909ae52b8fba601168f3eadbd972 Signed-off-by: Ole Troan <ot@cisco.com>
2017-03-07Python API: Synchronous mode.Ole Troan1-105/+89
Change-Id: Ic8f186dbb35bb4e2e191d311cab51315a88a2d81 Signed-off-by: Ole Troan <ot@cisco.com>
2017-03-03python API: work towards python/vpp api separationKlement Sekera1-1/+30
This change improves vpp_papi behaviour by introducing alternate way of calling vpp APIs. The common code is the same: vpp = VPP(...) vpp.connect(...) Calling VPP API is different, instead of deprecated: vpp.show_version() # deprecated one should write vpp.api.show_version() this allows VPP messages like "connect" and "disconnect" to be used, once the old API is dropped (in 17.07). Also part of this patch is a check for name conflict, to prevent VPP object overwriting its own functionality with generated code based on json files. Change-Id: I22e573b6a45f8b2a1f0340c5c2597c194fe42ca4 Signed-off-by: Klement Sekera <ksekera@cisco.com>
2017-01-27Python API: event_callback not initialised.Ole Troan1-0/+1
Even when not requesting notification the VPP API sends event notifications on certain calls. E.g. creating interfaces. Traceback (most recent call last): File "/vpp/ipfix/src/vpp-api/python/vpp_papi/vpp_papi.py", line 447, in msg_handler_sync if self.event_callback: AttributeError: VPP instance has no attribute 'event_callback' Change-Id: I4ca30c49df298655dc8948c5ebd68de0b3d6a592 Signed-off-by: Ole Troan <ot@cisco.com>
2017-01-24Fix PAPI async responseWojciech Dec1-1/+1
Previous changes forgot to return the decoded result Change-Id: I4eb27802eb2672532d856d9b9671ef806374bcd0 Signed-off-by: Wojciech Dec <wdec@cisco.com>
2017-01-20Python API: Missing locking of results data structure.Ole Troan1-84/+219
The wrong assumption that the GIL combined with CPython's "mostly" thread safe assurance does not hold. The combination of a slow event handler for notification and calling the API at the same time let to contention on the results data structure. Added suitable locking. Also added an atexit() to attempt a VPP disconnect on shutdown. Also: lots more comments, docstrings, duplicated code removed. Some of the problem here was a disagreement between caller and author as to how the API should be used; the comments should help. Change-Id: I0cb7d0026db660ec141425c5ad474f14bacea36e Signed-off-by: Ole Troan <ot@cisco.com> Co-Authored-By: Ian Wells <iawells@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com>
2017-01-06python clients can set the API rx message queue lengthDave Barach1-3/+3
Change-Id: I7af1493a823747e0f7389ad6c2093e4cec6c2ce9 Signed-off-by: Dave Barach <dave@barachs.net>
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+450
Change-Id: I7b51f88292e057c6443b12224486f2d0c9f8ae23 Signed-off-by: Damjan Marion <damarion@cisco.com>