From: Zack Cerza Date: Mon, 10 Feb 2014 20:08:10 +0000 (-0600) Subject: Add Remote.reconnect() X-Git-Tag: 1.1.0~1646^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=297096b560b79f4e2a963d9c1440c3db7d6c1a89;p=teuthology.git Add Remote.reconnect() Also rename Remote._connect() to Remote.connect() and change its semantics to match Remote.reconnect() Signed-off-by: Zack Cerza --- diff --git a/teuthology/orchestra/remote.py b/teuthology/orchestra/remote.py index 24b9453c4..8df6f221b 100644 --- a/teuthology/orchestra/remote.py +++ b/teuthology/orchestra/remote.py @@ -2,7 +2,7 @@ Support for paramiko remote objects. """ from . import run -from .connection import connect +import connection from teuthology import misc import time import pexpect @@ -37,12 +37,19 @@ class Remote(object): self.keep_alive = keep_alive self.console = console if ssh is None: - ssh = self._connect() - self.ssh = ssh - - def _connect(self): - return connect(user_at_host=self.name, host_key=self.host_key, - keep_alive=self.keep_alive) + ssh = self.connect() + else: + self.ssh = ssh + + def connect(self): + self.ssh = connection.connect(user_at_host=self.name, + host_key=self.host_key, + keep_alive=self.keep_alive) + return self.ssh + + def reconnect(self): + self.ssh.close() + self.ssh = self.connect() @property def shortname(self):