aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/VatExecutor.py
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python/VatExecutor.py')
-rw-r--r--resources/libraries/python/VatExecutor.py21
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."""