from robot.api import logger
-from resources.libraries.python.ssh import SSH
+from resources.libraries.python.ssh import SSH, SSHTimeout
from resources.libraries.python.constants import Constants
from resources.libraries.python.topology import NodeType
# Wait until VM boot
try:
self._wait_until_vm_boot()
- except RuntimeError:
+ except (RuntimeError, SSHTimeout):
self.qemu_kill()
self.qemu_clear_socks()
raise
# TODO: load priv key
+class SSHTimeout(Exception):
+ """This exception is raised when a timeout occurs."""
+ pass
+
+
class SSH(object):
"""Contains methods for managing and using SSH connections."""
:type timeout: int
:return return_code, stdout, stderr
:rtype: tuple(int, str, str)
- :raise socket.timeout: If command is not finished in timeout time.
+ :raise SSHTimeout: If command is not finished in timeout time.
"""
start = time()
stdout = StringIO.StringIO()
stderr.write(chan.recv_stderr(self.__MAX_RECV_BUF))
if time() - start > timeout:
- raise socket.timeout(
+ raise SSHTimeout(
'Timeout exception.\n'
'Current contents of stdout buffer: {0}\n'
'Current contents of stderr buffer: {1}\n'
from resources.libraries.python.ssh import SSH
+
def ssh_no_error(ssh, cmd, sudo=False):
"""Execute a command over ssh channel, and log and exit if the command
fails.
return stdo
+
def ssh_ignore_error(ssh, cmd, sudo=False):
"""Execute a command over ssh channel, ignore errors.
return stdo
+
def main():
"""Copy and installation of VPP packages."""