aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/PapiExecutor.py
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2019-06-20 19:49:35 +0200
committerJan Gelety <jgelety@cisco.com>2019-06-16 15:19:59 +0200
commit56c1c013bd0d632256efa4cb6b0224bf9c608afa (patch)
treecdce8cac975158c4dc44b5738935d028b40013d8 /resources/libraries/python/PapiExecutor.py
parent755842654e0d7144de9fafb836fedc6ebe794c95 (diff)
FIX: IPUtil after vpp api changes
+ do not log all ip_route_add_del api calls to PAPI history in case of scale tests + fix for SRv6 proxy tests + support of more complex structures in api calls/replies in PapiExecutor + update of vpp stable build to version 19.08-rc0~487-gb98dbb1 Change-Id: I9972e126b68ce1cb57f781e3d90ea9b3914de69e Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/libraries/python/PapiExecutor.py')
-rw-r--r--resources/libraries/python/PapiExecutor.py41
1 files changed, 34 insertions, 7 deletions
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py
index 5e35422a1b..30a90473f5 100644
--- a/resources/libraries/python/PapiExecutor.py
+++ b/resources/libraries/python/PapiExecutor.py
@@ -290,20 +290,24 @@ class PapiExecutor(object):
def __exit__(self, exc_type, exc_val, exc_tb):
self._ssh.disconnect(self._node)
- def add(self, csit_papi_command="vpp-stats", **kwargs):
+ def add(self, csit_papi_command="vpp-stats", history=True, **kwargs):
"""Add next command to internal command list; return self.
The argument name 'csit_papi_command' must be unique enough as it cannot
be repeated in kwargs.
:param csit_papi_command: VPP API command.
+ :param history: Enable/disable adding command to PAPI command history.
:param kwargs: Optional key-value arguments.
:type csit_papi_command: str
+ :type history: bool
:type kwargs: dict
:returns: self, so that method chaining is possible.
:rtype: PapiExecutor
"""
- PapiHistory.add_to_papi_history(self._node, csit_papi_command, **kwargs)
+ if history:
+ PapiHistory.add_to_papi_history(
+ self._node, csit_papi_command, **kwargs)
self._api_command_list.append(dict(api_name=csit_papi_command,
api_args=kwargs))
return self
@@ -480,10 +484,13 @@ class PapiExecutor(object):
:rtype: dict or str or int
"""
if isinstance(val, dict):
- val_dict = dict()
for val_k, val_v in val.iteritems():
- val_dict[str(val_k)] = process_value(val_v)
- return val_dict
+ val[str(val_k)] = process_value(val_v)
+ return val
+ elif isinstance(val, list):
+ for idx, val_l in enumerate(val):
+ val[idx] = process_value(val_l)
+ return val
else:
return binascii.hexlify(val) if isinstance(val, str) else val
@@ -509,12 +516,32 @@ class PapiExecutor(object):
:returns: Processed API reply / a part of API reply.
:rtype: dict
"""
+ def process_value(val):
+ """Process value.
+
+ :param val: Value to be processed.
+ :type val: object
+ :returns: Processed value.
+ :rtype: dict or str or int
+ """
+ if isinstance(val, dict):
+ for val_k, val_v in val.iteritems():
+ val[str(val_k)] = process_value(val_v)
+ return val
+ elif isinstance(val, list):
+ for idx, val_l in enumerate(val):
+ val[idx] = process_value(val_l)
+ return val
+ elif isinstance(val, unicode):
+ return binascii.unhexlify(val)
+ else:
+ return val
+
reply_dict = dict()
reply_value = dict()
for reply_key, reply_v in api_r.iteritems():
for a_k, a_v in reply_v.iteritems():
- reply_value[a_k] = binascii.unhexlify(a_v) \
- if isinstance(a_v, unicode) else a_v
+ reply_value[a_k] = process_value(a_v)
reply_dict[reply_key] = reply_value
return reply_dict