aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2019-03-06 21:47:28 +0100
committerVratko Polak <vrpolak@cisco.com>2019-04-01 10:03:15 +0000
commit81853d468a1ff40b0e03343b73412aff96a46dd0 (patch)
tree62a41fd2a58de85132fcc10d5215db567ca46942 /resources/tools
parenta64513984cf0b336ba314f8eda27890f81978a39 (diff)
CSIT-1337: Migrate L2Util library from VAT to PAPI
Change-Id: I22879c7bdd100d00216b9528663bf17406169826 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/tools')
-rwxr-xr-xresources/tools/papi/vpp_papi_provider.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/resources/tools/papi/vpp_papi_provider.py b/resources/tools/papi/vpp_papi_provider.py
index 299cd2c962..cec8197329 100755
--- a/resources/tools/papi/vpp_papi_provider.py
+++ b/resources/tools/papi/vpp_papi_provider.py
@@ -96,7 +96,20 @@ def _convert_reply(api_r):
reply_value = dict()
for item in dir(api_r):
if not item.startswith('_') and item not in unwanted_fields:
- reply_value[item] = getattr(api_r, item)
+ attr_value = getattr(api_r, item)
+ if isinstance(attr_value, list) or isinstance(attr_value, dict):
+ value = attr_value
+ elif hasattr(attr_value, '__int__'):
+ value = int(attr_value)
+ elif hasattr(attr_value, '__str__'):
+ value = binascii.hexlify(str(attr_value))
+ # Next handles parameters not supporting preferred integer or string
+ # representation to get it logged
+ elif hasattr(attr_value, '__repr__'):
+ value = repr(attr_value)
+ else:
+ value = attr_value
+ reply_value[item] = value
reply_dict[reply_key] = reply_value
return reply_dict
@@ -182,7 +195,11 @@ def process_stats(args):
data = stats.dump(directory)
reply.append(data)
- return json.dumps(reply)
+ try:
+ return json.dumps(reply)
+ except UnicodeDecodeError as err:
+ raise RuntimeError('PAPI reply {reply} error:\n{exc}'.format(
+ reply=reply, exc=repr(err)))
def main():