+ vpp.disconnect()
+
+ return json.dumps(reply)
+
+
+def process_stats(args):
+ """Process the VPP Stats.
+
+ :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)))
+
+ json_data = json.loads(args.data)
+
+ reply = list()
+
+ for path in json_data:
+ directory = stats.ls(path)
+ data = stats.dump(directory)
+ reply.append(data)
+
+ try:
+ return json.dumps(reply)
+ except UnicodeDecodeError as err:
+ raise RuntimeError('PAPI reply {reply} error:\n{exc}'.format(
+ 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", {}))