aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2019-06-03 12:55:55 +0200
committerTibor Frank <tifrank@cisco.com>2019-06-19 13:54:08 +0000
commit3c863def2096b573832499985e3a12bbccf82ea8 (patch)
tree91aac8216465b211dbd4c7f8b1d7887aa9ba9c7f /resources/tools
parent287ef8c6dc057220e403a1493cb23450dd8db2b2 (diff)
VAT-to-PAPI: VPPCounters
Change-Id: I5954fdd61ead9b4143f8cc4e20294cf8e199e0af Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools')
-rwxr-xr-xresources/tools/papi/vpp_papi_provider.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/resources/tools/papi/vpp_papi_provider.py b/resources/tools/papi/vpp_papi_provider.py
index ee0d538fba..ded3c3069e 100755
--- a/resources/tools/papi/vpp_papi_provider.py
+++ b/resources/tools/papi/vpp_papi_provider.py
@@ -214,6 +214,33 @@ def process_stats(args):
reply=reply, exc=repr(err)))
+def process_stats_request(args):
+ """Process the VPP Stats requests.
+
+ :param args: Command line arguments passed to VPP PAPI Provider.
+ :type args: ArgumentParser
+ :returns: JSON formatted string.
+ :rtype: str
+ :raises RuntimeError: If PAPI command error occurs.
+ """
+
+ try:
+ stats = VPPStats(args.socket)
+ except Exception as err:
+ raise RuntimeError('PAPI init failed:\n{err}'.format(err=repr(err)))
+
+ try:
+ json_data = json.loads(args.data)
+ except ValueError as err:
+ raise RuntimeError('Input json string is invalid:\n{err}'.
+ format(err=repr(err)))
+
+ papi_fn = getattr(stats, json_data["api_name"])
+ reply = papi_fn(**json_data.get("api_args", {}))
+
+ return json.dumps(reply)
+
+
def main():
"""Main function for the Python API provider.
"""
@@ -222,7 +249,8 @@ def main():
process_request = dict(
request=process_json_request,
dump=process_json_request,
- stats=process_stats
+ stats=process_stats,
+ stats_request=process_stats_request
)
parser = argparse.ArgumentParser(