CSIT-1407 FIX vpp install after VPP changes
[csit.git] / resources / tools / papi / vpp_papi_provider.py
index 0d93497..845cc93 100644 (file)
@@ -60,7 +60,7 @@ if do_import:
 CLIENT_NAME = 'csit_papi'
 
 
-def papi_init(vpp_json_dir='/usr/share/vpp/api/'):
+def papi_init():
     """Construct a VPP instance from VPP JSON API files.
 
     :param vpp_json_dir: Directory containing all the JSON API files. If VPP is
@@ -71,18 +71,8 @@ def papi_init(vpp_json_dir='/usr/share/vpp/api/'):
     :raises PapiJsonFileError: If no api.json file found.
     :raises PapiInitError: If PAPI initialization failed.
     """
-    # construct a list of all the json api files
-    jsonfiles = []
-    for root, dirnames, filenames in os.walk(vpp_json_dir):
-        for filename in fnmatch.filter(filenames, '*.api.json'):
-            jsonfiles.append(os.path.join(vpp_json_dir, filename))
-    if not jsonfiles:
-        raise PapiJsonFileError(
-            'No json api files found in location {dir}'.format(
-                dir=vpp_json_dir))
-
     try:
-        vpp = VPP(jsonfiles)
+        vpp = VPP()
         return vpp
     except Exception as err:
         raise PapiInitError('PAPI init failed:\n{exc}'.format(exc=repr(err)))
@@ -130,7 +120,7 @@ def convert_reply(api_r):
     """Process API reply / a part of API reply for smooth converting to
     JSON string.
 
-    Apply binascii.hexlify() method for string values.
+    Apply binascii.hexlify() method for string values.
     :param api_r: API reply.
     :type api_r: Vpp_serializer reply object (named tuple)
     :returns: Processed API reply / a part of API reply.
@@ -143,9 +133,10 @@ def convert_reply(api_r):
     reply_value = dict()
     for item in dir(api_r):
         if not item.startswith('_') and item not in unwanted_fields:
-            attr_value = getattr(api_r, item)
-            value = binascii.hexlify(attr_value) \
-                if isinstance(attr_value, str) else attr_value
+            # attr_value = getattr(api_r, item)
+            # value = binascii.hexlify(attr_value) \
+            #     if isinstance(attr_value, str) else attr_value
+            value = getattr(api_r, item)
             reply_value[item] = value
     reply_dict[reply_key] = reply_value
     return reply_dict
@@ -190,9 +181,8 @@ def main():
                         help="Directory containing all vpp json api files.")
     args = parser.parse_args()
     json_string = args.json_data
-    vpp_json_dir = args.json_dir
 
-    vpp = papi_init(vpp_json_dir=vpp_json_dir)
+    vpp = papi_init()
 
     reply = list()
     json_data = json.loads(json_string)