Always use ssh -a to avoid agent socket errors. While I'm at it,
consolidate ssh command strings into a single function for cleanliness.
From: showard@google.com
git-svn-id: http://test.kernel.org/svn/autotest/trunk@812 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/hosts/ssh_host.py b/server/hosts/ssh_host.py
index 9aff6c6..a1a0adb 100644
--- a/server/hosts/ssh_host.py
+++ b/server/hosts/ssh_host.py
@@ -167,6 +167,13 @@
return result == 0
+ def ssh_command(self):
+ """Construct an ssh command with proper args for this host."""
+ return r'ssh -a -l %s -p %d %s' % (self.user,
+ self.port,
+ self.hostname)
+
+
def run(self, command, timeout=None, ignore_status=False):
"""
Run a command on the remote host.
@@ -188,9 +195,9 @@
execution was not 0
"""
#~ print "running %s" % (command,)
- result= utils.run(r'ssh -l %s -p %d %s "%s"' % (self.user,
- self.port, self.hostname, utils.sh_escape(command)),
- timeout, ignore_status)
+ result= utils.run(r'%s "%s"' % (self.ssh_command(),
+ utils.sh_escape(command)),
+ timeout, ignore_status)
return result
@@ -296,9 +303,8 @@
entry= format_string % (utils.sh_escape(os.path.abspath(entry)),)
processed_source.append(entry)
- result= utils.run('ssh -l %s %s rsync -h' % (self.user,
- self.hostname),
- ignore_status=True)
+ result = utils.run(r'%s rsync -h' % self.ssh_command(),
+ ignore_status=True)
if result.exit_status == 0:
utils.run('rsync --rsh=ssh -az %s %s@%s:"%s"' % (