From fe1975eb1ac994df1bd759deda7154bb7dd9d7a7 Mon Sep 17 00:00:00 2001 From: Jan Gelety Date: Mon, 18 Mar 2019 13:30:11 +0100 Subject: CSIT-1468: InterfaceUtil migration from VAT to PAPI Change-Id: I0062710d58996be767a852dc00545fedd60a5c72 Signed-off-by: Jan Gelety --- resources/tools/papi/vpp_papi_provider.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'resources/tools/papi') diff --git a/resources/tools/papi/vpp_papi_provider.py b/resources/tools/papi/vpp_papi_provider.py index cec8197329..ee0d538fba 100755 --- a/resources/tools/papi/vpp_papi_provider.py +++ b/resources/tools/papi/vpp_papi_provider.py @@ -131,6 +131,19 @@ def process_json_request(args): reply = list() + def process_value(val): + 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 + elif isinstance(val, unicode): + return binascii.unhexlify(val) + elif isinstance(val, int): + return val + else: + return str(val) + json_data = json.loads(args.data) vpp.connect(CLIENT_NAME) for data in json_data: @@ -139,8 +152,7 @@ def process_json_request(args): api_reply = dict(api_name=api_name) api_args = dict() for a_k, a_v in api_args_unicode.items(): - value = binascii.unhexlify(a_v) if isinstance(a_v, unicode) else a_v - api_args[str(a_k)] = value if isinstance(value, int) else str(value) + api_args[str(a_k)] = process_value(a_v) try: papi_fn = getattr(vpp.api, api_name) rep = papi_fn(**api_args) -- cgit 1.2.3-korg