lib/chef_metal/transport/ssh.rb in clc-fork-chef-metal-0.14.alpha.3 vs lib/chef_metal/transport/ssh.rb in clc-fork-chef-metal-0.14.alpha.4
- old
+ new
@@ -8,10 +8,30 @@
require 'net/ssh/gateway'
module ChefMetal
class Transport
class SSH < ChefMetal::Transport
+ #
+ # Create a new SSH transport.
+ #
+ # == Arguments
+ #
+ # - host: the host to connect to, e.g. '145.14.51.45'
+ # - username: the username to connect with
+ # - ssh_options: a list of options to Net::SSH.start
+ # - options: a hash of options for the transport itself, including:
+ # - :prefix: a prefix to send before each command (e.g. "sudo ")
+ # - :ssh_pty_enable: set to false to disable pty (some instances don't
+ # support this, most do)
+ # - :ssh_gateway: the gateway to use, e.g. "jkeiser@145.14.51.45:222".
+ # nil (the default) means no gateway.
+ # - global_config: an options hash that looks suspiciously similar to
+ # Chef::Config, containing at least the key :log_level.
+ #
+ # The options are used in
+ # Net::SSH.start(host, username, ssh_options)
+
def initialize(host, username, ssh_options, options, global_config)
@host = host
@username = username
@ssh_options = ssh_options
@options = options
@@ -222,10 +242,10 @@
def gateway?
options.key?(:ssh_gateway) and ! options[:ssh_gateway].nil?
end
def gateway
- gw_host, gw_user = options[:ssh_gateway].split('@').reverse
+ gw_user, gw_host = options[:ssh_gateway].split('@')
gw_host, gw_port = gw_host.split(':')
gw_user = ssh_options[:ssh_username] unless gw_user
ssh_start_opts = { timeout:10 }.merge(ssh_options)
ssh_start_opts[:port] = gw_port || 22