Line length: Fix recent merges
[csit.git] / resources / tools / papi / vpp_papi_provider.py
index 6f3b066..ff52de5 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 
-# Copyright (c) 2019 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -67,7 +67,7 @@ if do_import:
                 break
     if modules_path:
         sys.path.append(modules_path)
-        from vpp_papi import VPP
+        from vpp_papi import VPPApiClient
         from vpp_papi.vpp_stats import VPPStats
     else:
         raise RuntimeError(u"vpp_papi module not found")
@@ -140,7 +140,7 @@ def process_json_request(args):
     """
 
     try:
-        vpp = VPP()
+        vpp = VPPApiClient()
     except Exception as err:
         raise RuntimeError(f"PAPI init failed:\n{err!r}")
 
@@ -209,6 +209,8 @@ def process_json_request(args):
 def process_stats(args):
     """Process the VPP Stats.
 
+    The reply contains single item covering all paths.
+
     :param args: Command line arguments passed to VPP PAPI Provider.
     :type args: ArgumentParser
     :returns: JSON formatted string.
@@ -221,14 +223,9 @@ def process_stats(args):
     except Exception as err:
         raise RuntimeError(f"PAPI init failed:\n{err!r}")
 
-    json_data = json.loads(args.data)
-
-    reply = list()
-
-    for path in json_data:
-        directory = stats.ls(path)
-        data = stats.dump(directory)
-        reply.append(data)
+    paths = json.loads(args.data)
+    directory = stats.ls(paths)
+    reply = [stats.dump(directory)]
 
     try:
         return json.dumps(reply)