J. Richard Barnette | 24adbf4 | 2012-04-11 15:04:53 -0700 | [diff] [blame^] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Dale Curtis | aa5eedb | 2011-08-23 16:18:52 -0700 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
J. Richard Barnette | 24adbf4 | 2012-04-11 15:04:53 -0700 | [diff] [blame^] | 5 | from autotest_lib.server.hosts.chromiumos_host import SiteHost |
| 6 | |
| 7 | |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 8 | def make_ssh_command(user='root', port=22, opts='', hosts_file=None, |
| 9 | connect_timeout=None, alive_interval=None): |
| 10 | """Override default make_ssh_command to use options tuned for Chrome OS. |
| 11 | |
| 12 | Tuning changes: |
Chris Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 13 | - ConnectTimeout=30; maximum of 30 seconds allowed for an SSH connection |
| 14 | failure. Consistency with remote_access.sh. |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 15 | |
Dale Curtis | aa5eedb | 2011-08-23 16:18:52 -0700 | [diff] [blame] | 16 | - ServerAliveInterval=180; which causes SSH to ping connection every |
| 17 | 180 seconds. In conjunction with ServerAliveCountMax ensures that if the |
| 18 | connection dies, Autotest will bail out quickly. Originally tried 60 secs, |
| 19 | but saw frequent job ABORTS where the test completed successfully. |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 20 | |
Chris Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 21 | - ServerAliveCountMax=3; consistency with remote_access.sh. |
| 22 | |
| 23 | - ConnectAttempts=4; reduce flakiness in connection errors; consistency |
| 24 | with remote_access.sh. |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 25 | |
| 26 | - UserKnownHostsFile=/dev/null; we don't care about the keys. Host keys |
| 27 | change with every new installation, don't waste memory/space saving them. |
Chris Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 28 | |
| 29 | - SSH protocol forced to 2; needed for ServerAliveInterval. |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 30 | """ |
| 31 | base_command = ('/usr/bin/ssh -a -x %s -o StrictHostKeyChecking=no' |
| 32 | ' -o UserKnownHostsFile=/dev/null -o BatchMode=yes' |
Chris Sosa | f7fcd6e | 2011-09-27 17:30:47 -0700 | [diff] [blame] | 33 | ' -o ConnectTimeout=30 -o ServerAliveInterval=180' |
| 34 | ' -o ServerAliveCountMax=3 -o ConnectionAttempts=4' |
| 35 | ' -o Protocol=2 -l %s -p %d') |
Dale Curtis | cb7bfaf | 2011-06-07 16:21:57 -0700 | [diff] [blame] | 36 | return base_command % (opts, user, port) |