X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FVatExecutor.py;h=9851d93edd7d3e8eec16922594688c0293aec193;hp=136b7cc0ef3ebb1494bf7580e64047dbc4f2f574;hb=6d9fe9bb4bd353b1d4fec3b2569bcd743f87fc4a;hpb=5a2fd159dce96a70f2e5157314391aceb6d80197 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."""