diff options
author | Tibor Frank <tifrank@cisco.com> | 2019-06-03 12:55:55 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2019-06-19 13:54:08 +0000 |
commit | 3c863def2096b573832499985e3a12bbccf82ea8 (patch) | |
tree | 91aac8216465b211dbd4c7f8b1d7887aa9ba9c7f /resources/libraries/python/PapiExecutor.py | |
parent | 287ef8c6dc057220e403a1493cb23450dd8db2b2 (diff) |
VAT-to-PAPI: VPPCounters
Change-Id: I5954fdd61ead9b4143f8cc4e20294cf8e199e0af
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python/PapiExecutor.py')
-rw-r--r-- | resources/libraries/python/PapiExecutor.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py index 98eb59cae7..5e35422a1b 100644 --- a/resources/libraries/python/PapiExecutor.py +++ b/resources/libraries/python/PapiExecutor.py @@ -327,6 +327,25 @@ class PapiExecutor(object): return json.loads(stdout) + def get_stats_reply(self, err_msg="Failed to get statistics.", timeout=120): + """Get VPP Stats reply from VPP Python API. + + :param err_msg: The message used if the PAPI command(s) execution fails. + :param timeout: Timeout in seconds. + :type err_msg: str + :type timeout: int + :returns: Requested VPP statistics. + :rtype: list + """ + + args = self._api_command_list[0]['api_args'] + self._api_command_list = list() + + stdout, _ = self._execute_papi( + args, method='stats_request', err_msg=err_msg, timeout=timeout) + + return json.loads(stdout) + def get_replies(self, err_msg="Failed to get replies.", process_reply=True, ignore_errors=False, timeout=120): """Get reply/replies from VPP Python API. @@ -536,7 +555,8 @@ class PapiExecutor(object): if not api_data: RuntimeError("No API data provided.") - json_data = json.dumps(api_data) if method == "stats" \ + json_data = json.dumps(api_data) \ + if method in ("stats", "stats_request") \ else json.dumps(self._process_api_data(api_data)) cmd = "{fw_dir}/{papi_provider} --method {method} --data '{json}'".\ |