diff options
author | Matej Klotton <mklotton@cisco.com> | 2016-03-11 13:56:39 +0100 |
---|---|---|
committer | Stefan Kobza <skobza@cisco.com> | 2016-04-13 16:09:31 +0000 |
commit | 6d9fe9bb4bd353b1d4fec3b2569bcd743f87fc4a (patch) | |
tree | 7a21e9072114ba6670fab95421ded8796335c1c4 /resources/libraries/python/VatExecutor.py | |
parent | 5a2fd159dce96a70f2e5157314391aceb6d80197 (diff) |
VXLAN test with dot1q tagging.
Change-Id: I3dbd12983736e338d757c580570d91680aedd83f
Signed-off-by: Matej Klotton <mklotton@cisco.com>
Diffstat (limited to 'resources/libraries/python/VatExecutor.py')
-rw-r--r-- | resources/libraries/python/VatExecutor.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/resources/libraries/python/VatExecutor.py b/resources/libraries/python/VatExecutor.py index 136b7cc0ef..9851d93edd 100644 --- a/resources/libraries/python/VatExecutor.py +++ b/resources/libraries/python/VatExecutor.py @@ -142,18 +142,25 @@ class VatTerminal(object): """VAT interactive terminal :param node: Node to open VAT terminal on. + :param json_param: Defines if outputs from VAT are in JSON format. + Default is True. + :type node: dict + :type json_param: bool + """ __VAT_PROMPT = "vat# " __LINUX_PROMPT = ":~$ " - def __init__(self, node): + def __init__(self, node, json_param=True): + json_text = ' json' if json_param else '' + self.json = json_param self._ssh = SSH() self._ssh.connect(node) self._tty = self._ssh.interactive_terminal_open() self._ssh.interactive_terminal_exec_command( self._tty, - 'sudo -S {vat} json'.format(vat=Constants.VAT_BIN_NAME), + 'sudo -S {}{}'.format(Constants.VAT_BIN_NAME, json_text), self.__VAT_PROMPT) def __enter__(self): @@ -167,15 +174,19 @@ class VatTerminal(object): :param cmd: Command to be executed. - :return: Command output in python representation of JSON format. + :return: Command output in python representation of JSON format or + None if not in JSON mode. """ logger.debug("Executing command in VAT terminal: {}".format(cmd)) out = self._ssh.interactive_terminal_exec_command(self._tty, cmd, self.__VAT_PROMPT) logger.debug("VAT output: {}".format(out)) - json_out = json.loads(out) - return json_out + if self.json: + json_out = json.loads(out) + return json_out + else: + return None def vat_terminal_close(self): """Close VAT terminal.""" |