aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/vpp_format.py
AgeCommit message (Collapse)AuthorFilesLines
2022-05-10tests: replace pycodestyle with blackKlement Sekera1-115/+101
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>
2020-12-03papi: remove python2 patternsPaul Vinciguerra1-6/+2
Type: refactor Change-Id: I541759b4b788acf08599661eb9e7abc58e9283d2 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-08-11papi: allow unknown address familyOle Troan1-10/+19
In unions all representations of the union are decoded. Which means trying to decode something that isn't an address might have invalid address family types. Type: fix Ticket: VPP-1884 Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Id3381ef8cc885952c1eb488ebc70e276eaceb366
2020-04-28tests: implement ipaddress convenience methodsPaul Vinciguerra1-0/+5
Add vpp specific properties to ip addresses for use in the api. .vapi_af -- returns [ADDRESS_IP4, ADDRESS_IP6] .vapi_af_name -- returns the string ['ip4', 'ip6'] Update tests to demonstrate usage. Type: feature Change-Id: I43447a1522769d99f89debdc714c51700068d771 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-09-19api: split vl_api_prefix into twoOle Troan1-1/+71
One type for address with prefix and one type for prefix. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Icfec51d9b7d5cde1d69fbecdd97498688ab7b295 Signed-off-by: Ole Troan <ot@cisco.com> Signed-off-by: Klement Sekera <ksekera@cisco.com> Signed-off-by: Ole Troan <ot@cisco.com>
2019-07-31api papi: add alias for timestamp(datetime)/timedeltaPaul Vinciguerra1-1/+8
Now that we have support for f64: - create explicit types for timestamp(datetime)/timedelta - update log_details to use timestamp and remove redundant string representation. If you need the string representation, in python do str(timestamp). If you prefer the raw f64 value, the client can pass in the _no_type_conversion option. Type: feature Change-Id: I547b5fa7122d2afa12628b7db0192c23babbbae8 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-07-12papi: fix vpp_format from change in vl_api_prefix_tPaul Vinciguerra1-2/+2
cherry picking fix for bug introduced by https://gerrit.fd.io/r/#/c/20011/ - also fixes unit tests. Type: fix Fixes: ab05508e1eb96749b68de8ccd2f6f88ff3e64fad Change-Id: I8287385f094911ea70de4751a716a7e0e6521b64 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-06-26api: refactor format_vl_api_prefix_t return keysPaul Vinciguerra1-12/+12
format_vl_api_prefix_t returns a dict with keys 'address' and 'address_length', but other format_vl_api_prefix functions return a dict with 'prefix', and 'len'. Refactor all format_vl_api_prefix_t to return consistent keys 'address' and 'len'. Type: refactor Change-Id: I5f9558fc2da8742a303266e011102f5b2db80aad Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-06-07vpp_papi: Fix format_vl_api_address_t under python3.Paul Vinciguerra1-1/+3
Under PY3, inet_pton returns OSError, not socket.error. Type: fix Change-Id: Id270a684c0ab124cbe1ddcb7123e14e85af844b8 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-06-07vpp_papi: Accept ipaddress.Network objects on prefix_t methods.Paul Vinciguerra1-1/+16
vl_api_prefix_t returns ipaddress.<IPv[46]>Network objects. Accept Network objects as well as existing string format. Type: refactor. Change-Id: Iba5403724a7b3e1da3b3740027fccd43631bf31e Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2018-12-18PAPI: Add MACAddress object wrapper for vl_api_mac_address_tOle Troan1-0/+7
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-12PAPI: Allow ipaddress object as argument and return values from API callsOle Troan1-132/+102
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-06API: Change ip4_address and ip6_address to use type alias.Ole Troan1-8/+8
Change-Id: Id8669bbadd1d6b2054865a310a654e9b38d1667d 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-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-10-22PAPI: Add support for format/unformat functions.Ole Troan1-0/+144
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>