]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add Remote.reconnect()
authorZack Cerza <zack@cerza.org>
Mon, 10 Feb 2014 20:08:10 +0000 (14:08 -0600)
committerZack Cerza <zack@cerza.org>
Thu, 20 Feb 2014 23:46:07 +0000 (17:46 -0600)
Also rename Remote._connect() to Remote.connect() and change its
semantics to match Remote.reconnect()

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/orchestra/remote.py

index 24b9453c427640289facc23d60e63dbfc478713e..8df6f221ba7c109ec4ac89f2bc52ba97030daf30 100644 (file)
@@ -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):