summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2020-04-26 22:04:32 -0400
committerOle Tr�an <otroan@employees.org>2021-02-15 17:28:25 +0000
commit6531514569d8b08242c738c61d3453468a44f7ca (patch)
tree1b9100bfa4bcbf42298ffbc4494e8e3ae207c88f /src/vpp-api/python
parentae936086fd4390cc54300c02491bef337934a772 (diff)
papi: add method to retrieve field options
Sample usage: cls.MEMIF_DEFAULT_BUFFER_SIZE = cls.vapi.vpp.get_field_options( 'memif_create', 'buffer_size')['default'] Type: improvement Change-Id: I298f4687623003a78c93a703d32f59a937e37bc2 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vpp-api/python')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py
index b5310a1f68a..86bf7cbee30 100644
--- a/src/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/src/vpp-api/python/vpp_papi/vpp_papi.py
@@ -686,6 +686,15 @@ class VPPApiClient:
n[1]['avg'], n[1]['max'])
return s
+ def get_field_options(self, msg, fld_name):
+ # when there is an option, the msgdef has 3 elements.
+ # ['u32', 'ring_size', {'default': 1024}]
+ for _def in self.messages[msg].msgdef:
+ if isinstance(_def, list) and \
+ len(_def) == 3 and \
+ _def[1] == fld_name:
+ return _def[2]
+
def _call_vpp(self, i, msgdef, service, **kwargs):
"""Given a message, send the message and await a reply.