Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
added support for custom ssh port
Browse files Browse the repository at this point in the history
  • Loading branch information
summatix committed Oct 20, 2011
1 parent d15fba4 commit 8c9d296
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/chef/knife/rackspace_server_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ class RackspaceServerCreate < Knife
:long => "--ssh-password PASSWORD",
:description => "The ssh password"

option :ssh_port,
:short => "-p PORT",
:long => "--ssh-port PORT",
:description => "The ssh port",
:default => "22",
:proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }

option :identity_file,
:short => "-i IDENTITY_FILE",
:long => "--identity-file IDENTITY_FILE",
Expand Down Expand Up @@ -110,7 +117,8 @@ class RackspaceServerCreate < Knife
:default => ""

def tcp_test_ssh(hostname)
tcp_socket = TCPSocket.new(hostname, 22)
ssh_port = Chef::Config[:knife][:ssh_port] || config[:ssh_port]
tcp_socket = TCPSocket.new(hostname, ssh_port)
readable = IO.select([tcp_socket], nil, nil, 5)
if readable
Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
Expand Down Expand Up @@ -194,6 +202,7 @@ def bootstrap_for_node(server)
bootstrap.config[:run_list] = config[:run_list]
bootstrap.config[:ssh_user] = config[:ssh_user] || "root"
bootstrap.config[:ssh_password] = server.password
bootstrap.config[:ssh_port] = Chef::Config[:knife][:ssh_port] || config[:ssh_port]
bootstrap.config[:identity_file] = config[:identity_file]
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
bootstrap.config[:prerelease] = config[:prerelease]
Expand Down

0 comments on commit 8c9d296

Please sign in to comment.