diff options
author | Tibor Frank <tifrank@cisco.com> | 2019-06-10 12:49:51 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2019-06-19 06:17:30 +0000 |
commit | 92fbe3b8d880f9a3dd63e1309d76772b1685a037 (patch) | |
tree | 45fffdeac82afb4ad2484415f1a6d832ccb13335 /resources/libraries/python/PapiExecutor.py | |
parent | 5982882c045085b1656b14efc4e52bbb59c4b264 (diff) |
VAT-to-PAPI: VPPUtils
Change-Id: If4eb592e2718c4564f1f7929ca6ff91c02f074a6
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/libraries/python/PapiExecutor.py')
-rw-r--r-- | resources/libraries/python/PapiExecutor.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py index e296e23c1f..c2f966fb6d 100644 --- a/resources/libraries/python/PapiExecutor.py +++ b/resources/libraries/python/PapiExecutor.py @@ -365,6 +365,34 @@ class PapiExecutor(object): method='dump', process_reply=process_reply, ignore_errors=ignore_errors, err_msg=err_msg, timeout=timeout) + @staticmethod + def run_cli_cmd(node, cmd, log=True): + """Run a CLI command. + + :param node: Node to run command on. + :param cmd: The CLI command to be run on the node. + :param log: If True, the response is logged. + :type node: dict + :type cmd: str + :type log: bool + :returns: Verified data from PAPI response. + :rtype: dict + """ + + cli = 'cli_inband' + args = dict(cmd=cmd) + err_msg = "Failed to run 'cli_inband {cmd}' PAPI command on host " \ + "{host}".format(host=node['host'], cmd=cmd) + + with PapiExecutor(node) as papi_exec: + data = papi_exec.add(cli, **args).get_replies(err_msg). \ + verify_reply(err_msg=err_msg) + + if log: + logger.info("{cmd}:\n{data}".format(cmd=cmd, data=data["reply"])) + + return data + def execute_should_pass(self, err_msg="Failed to execute PAPI command.", process_reply=True, ignore_errors=False, timeout=120): |