Permalink
Browse files

Upgrade Sauce Connect to r21

  • Loading branch information...
1 parent c0c9f31 commit 54549389219562d6174d8ccbd42105fa07b5cbae @epall epall committed Dec 16, 2010
Showing with 40 additions and 31 deletions.
  1. +1 −1 VERSION
  2. +39 −30 support/sauce_connect
View
@@ -1 +1 @@
-0.12.2
+0.12.3
View
@@ -3,15 +3,13 @@
from __future__ import with_statement
# TODO:
-# * ?? Use "-o StrictHostKeyChecking no"
# * Move to REST API v1
# * windows: SSH link healthcheck (PuTTY session file hack?)
# * Daemonizing
# * issue: windows: no os.fork()
# * issue: unix: null file descriptors causes Expect script to fail
# * Renew tunnel lease (backend not implemented)
# * Check tunnel machine ports are open (backend not implemented)
-#
import os
import sys
@@ -39,7 +37,7 @@ except ImportError:
import simplejson as json # Python 2.5 dependency
NAME = "sauce_connect"
-RELEASE = 20
+RELEASE = 21
DISPLAY_VERSION = "%s release %s" % (NAME, RELEASE)
PRODUCT_NAME = u"Sauce Connect"
VERSIONS_URL = "http://saucelabs.com/versions.json"
@@ -352,11 +350,13 @@ class ReverseSSHError(Exception):
class ReverseSSH(object):
- def __init__(self, tunnel, host, ports, tunnel_ports, debug=False):
+ def __init__(self, tunnel, host, ports, tunnel_ports,
+ use_ssh_config=False, debug=False):
self.tunnel = tunnel
self.host = host
self.ports = ports
self.tunnel_ports = tunnel_ports
+ self.use_ssh_config = use_ssh_config
self.debug = debug
self.proc = None
@@ -375,12 +375,8 @@ class ReverseSSH(object):
ssh_config_file = os.path.join(os.environ['HOME'], ".ssh", "config")
if os.path.exists(ssh_config_file):
logger.debug("Found %s" % ssh_config_file)
-
- ssh_known_hosts = os.path.join(os.environ['HOME'], ".ssh", "known_hosts")
- if os.path.exists(ssh_known_hosts):
- if not os.path.isfile(ssh_known_hosts) or os.path.islink(ssh_known_hosts):
- logger.debug("SSH known_hosts file (%s) is not a regular file "
- % ssh_known_hosts)
+ if self.use_ssh_config:
+ logger.warn("Using local SSH config")
@property
def _dash_Rs(self):
@@ -390,27 +386,25 @@ class ReverseSSH(object):
return dash_Rs
def get_plink_command(self):
+ """Return the Windows SSH command."""
verbosity = "-v" if self.debug else ""
return ("plink\plink %s -l %s -pw %s -N %s %s"
% (verbosity, self.tunnel.user, self.tunnel.password,
self._dash_Rs, self.tunnel.host))
def get_expect_script(self):
+ """Return the Unix SSH command."""
wait = "wait"
if is_openbsd: # using 'wait;' hangs the script on OpenBSD
wait = "wait -nowait;sleep 1" # hack
verbosity = "-v" if self.debug else "-q"
+ config_file = "" if self.use_ssh_config else "-F /dev/null"
host_ip = socket.gethostbyname(self.tunnel.host)
script = (
- "spawn ssh-keygen %s -R %s;%s;"
- % (verbosity, self.tunnel.host, wait) +
- "spawn ssh-keygen %s -R %s;%s;" % (verbosity, host_ip, wait) +
- "spawn ssh %s -p 22 -l %s -o ServerAliveInterval=%s -N %s %s;"
- % (verbosity, self.tunnel.user, HEALTH_CHECK_INTERVAL,
- self._dash_Rs, self.tunnel.host) +
- 'expect \\"Are you sure you want to continue connecting'
- ' (yes/no)?\\";send yes\\r;'
+ "spawn ssh %s %s -p 22 -l %s -o ServerAliveInterval=%s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -N %s %s;"
+ % (verbosity, config_file, self.tunnel.user,
+ HEALTH_CHECK_INTERVAL, self._dash_Rs, self.tunnel.host) +
"expect *password:;send -- %s\\r;" % self.tunnel.password +
"expect -timeout -1 timeout")
return script
@@ -539,7 +533,7 @@ def peace_out(tunnel=None, returncode=0, atexit=False):
logger.info("\ Exiting /")
raise SystemExit(returncode)
else:
- logger.debug("--- fin ---")
+ logger.debug("-- fin --")
def setup_signal_handler(tunnel, options):
@@ -632,15 +626,15 @@ def check_domains(domains):
sys.stderr.write(
"Error: Domain contains illegal character '/' in it.\n")
print " Did you use a URL instead of just the domain?\n"
- print "Examples: -d example.com -d '*.example.com' -d cdn.example.org"
+ print "Examples: -d example.com -d '*.example.com' -d another.site"
print
raise SystemExit(1)
# no numerical addresses
if all(map(lambda c: c.isdigit() or c == '.', dom)):
sys.stderr.write("Error: Domain must be a hostname not an IP\n")
print
- print "Examples: -d example.com -d '*.example.com' -d cdn.example.org"
+ print "Examples: -d example.com -d '*.example.com' -d another.site"
print
raise SystemExit(1)
@@ -650,7 +644,16 @@ def check_domains(domains):
sys.stderr.write(
"Error: Domain requires a TLD of 2 characters or more\n")
print
- print "Example: -d example.tld -d '*.example.tld' -d cdn.example.tld"
+ print "Example: -d example.tld -d '*.example.tld' -d another.tld"
+ print
+ raise SystemExit(1)
+
+ # *.com will break uploading to S3
+ if dom == "*.com":
+ sys.stderr.write(
+ "Error: Matching *.com will break videos and logs. Use a hostname.\n")
+ print
+ print "Example: -d example.com -d *.example.com"
print
raise SystemExit(1)
@@ -709,16 +712,20 @@ Performance tip:
og.add_option("--readyfile",
help="Path of the file to drop when the tunnel is ready "
"for tests to run. By default, no file is dropped.")
+ og.add_option("--use-ssh-config", action="store_true", default=False,
+ help="Use the local SSH config. WARNING: Turning this on "
+ "may break the script!")
+ og.add_option("--rest-url", default="https://saucelabs.com/rest",
+ help=optparse.SUPPRESS_HELP)
+ og.add_option("--allow-unclean-exit", action="store_true", default=False,
+ help=optparse.SUPPRESS_HELP)
op.add_option_group(og)
og = optparse.OptionGroup(op, "Script debugging options")
- og.add_option("--rest-url", default="https://saucelabs.com/rest",
- help="[%default]")
- og.add_option("--debug-ssh", action="store_true", default=False)
+ og.add_option("--debug-ssh", action="store_true", default=False,
+ help="Log SSH output.")
og.add_option("--latency-log", type=int, default=LATENCY_LOG,
- help="Threshold above which latency (ms) will be "
- "logged. [%default]")
- og.add_option("--allow-unclean-exit", action="store_true", default=False)
+ help="Threshold for logging latency (ms) [%default]")
op.add_option_group(og)
(options, args) = op.parse_args()
@@ -872,8 +879,10 @@ def run(options, dependency_versions=None):
logger.info("** Please contact help@saucelabs.com")
peace_out(tunnel, returncode=1) # exits
- ssh = ReverseSSH(tunnel, options.host, options.ports, options.tunnel_ports,
- options.debug_ssh)
+ ssh = ReverseSSH(tunnel=tunnel, host=options.host,
+ ports=options.ports, tunnel_ports=options.tunnel_ports,
+ use_ssh_config=options.use_ssh_config,
+ debug=options.debug_ssh)
try:
ssh.run(options.readyfile)
except (ReverseSSHError, TunnelMachineError), e:

0 comments on commit 5454938

Please sign in to comment.