summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
7a518f5)
- remember if execution timed out and do not try to send "quit" on close
- increase timeout of vat command execution from 10s to 60s
Change-Id: I2b96a6dce1220eff45002276d1fe8a771fca2205
Signed-off-by: Miroslav Miklus <mmiklus@cisco.com>
self._tty,
'sudo -S {}{}'.format(Constants.VAT_BIN_NAME, json_text),
self.__VAT_PROMPT)
self._tty,
'sudo -S {}{}'.format(Constants.VAT_BIN_NAME, json_text),
self.__VAT_PROMPT)
+ self._exec_failure = False
def __enter__(self):
return self
def __enter__(self):
return self
None if not in JSON mode.
"""
logger.debug("Executing command in VAT terminal: {}".format(cmd))
None if not in JSON mode.
"""
logger.debug("Executing command in VAT terminal: {}".format(cmd))
- out = self._ssh.interactive_terminal_exec_command(self._tty,
+ try:
+ out = self._ssh.interactive_terminal_exec_command(self._tty,
+ except:
+ self._exec_failure = True
+ raise
+
logger.debug("VAT output: {}".format(out))
if self.json:
obj_start = out.find('{')
logger.debug("VAT output: {}".format(out))
if self.json:
obj_start = out.find('{')
array_end = out.rfind(']')
if -1 == obj_start and -1 == array_start:
array_end = out.rfind(']')
if -1 == obj_start and -1 == array_start:
- raise RuntimeError("No JSON data.")
+ raise RuntimeError("VAT: no JSON data.")
if obj_start < array_start or -1 == array_start:
start = obj_start
if obj_start < array_start or -1 == array_start:
start = obj_start
def vat_terminal_close(self):
"""Close VAT terminal."""
def vat_terminal_close(self):
"""Close VAT terminal."""
- self._ssh.interactive_terminal_exec_command(self._tty,
- 'quit',
- self.__LINUX_PROMPT)
+ #interactive terminal is dead, we only need to close session
+ if not self._exec_failure:
+ self._ssh.interactive_terminal_exec_command(self._tty,
+ 'quit',
+ self.__LINUX_PROMPT)
self._ssh.interactive_terminal_close(self._tty)
def vat_terminal_exec_cmd_from_template(self, vat_template_file, **args):
self._ssh.interactive_terminal_close(self._tty)
def vat_terminal_exec_cmd_from_template(self, vat_template_file, **args):
@staticmethod
def interactive_terminal_exec_command(chan, cmd, prompt,
@staticmethod
def interactive_terminal_exec_command(chan, cmd, prompt,
"""Execute command on interactive terminal.
interactive_terminal_open() method has to be called first!
"""Execute command on interactive terminal.
interactive_terminal_open() method has to be called first!