summaryrefslogtreecommitdiff
path: root/chef/lib/chef
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-10-06 17:12:31 -0700
committerDaniel DeLeo <dan@opscode.com>2010-10-06 17:12:31 -0700
commit30b8eed605006e3962388c912fe7ffeb20ae4694 (patch)
tree7bcee2919380deeb36f60cb8db0cf89452bb2152 /chef/lib/chef
parentf8c172409d89c43dc334b6a6480b6111b20afdc8 (diff)
downloadchef-30b8eed605006e3962388c912fe7ffeb20ae4694.tar.gz
fix and refactor tests for ec2 server create
Diffstat (limited to 'chef/lib/chef')
-rw-r--r--chef/lib/chef/knife/bootstrap.rb2
-rw-r--r--chef/lib/chef/knife/ec2_server_create.rb29
2 files changed, 19 insertions, 12 deletions
diff --git a/chef/lib/chef/knife/bootstrap.rb b/chef/lib/chef/knife/bootstrap.rb
index b582b4a771..8e36ab5680 100644
--- a/chef/lib/chef/knife/bootstrap.rb
+++ b/chef/lib/chef/knife/bootstrap.rb
@@ -120,7 +120,7 @@ class Chef
exit 1
end
- config[:server_name] = @name_args.first
+ config[:server_name] = Array(@name_args).first
$stdout.sync = true
diff --git a/chef/lib/chef/knife/ec2_server_create.rb b/chef/lib/chef/knife/ec2_server_create.rb
index dbfb26e5f5..3311786817 100644
--- a/chef/lib/chef/knife/ec2_server_create.rb
+++ b/chef/lib/chef/knife/ec2_server_create.rb
@@ -119,6 +119,7 @@ class Chef
tcp_socket = TCPSocket.new(hostname, 22)
readable = IO.select([tcp_socket], nil, nil, 5)
if readable
+ Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
yield
true
else
@@ -179,17 +180,8 @@ class Chef
print(".") until tcp_test_ssh(server.dns_name) { sleep @initial_sleep_delay ||= 10; puts("done") }
- bootstrap = Chef::Knife::Bootstrap.new
- bootstrap.name_args = [server.dns_name]
- bootstrap.config[:run_list] = @name_args
- bootstrap.config[:ssh_user] = config[:ssh_user]
- bootstrap.config[:identity_file] = config[:identity_file]
- bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
- bootstrap.config[:prerelease] = config[:prerelease]
- bootstrap.config[:distro] = config[:distro]
- bootstrap.config[:use_sudo] = true
- bootstrap.config[:template_file] = config[:template_file]
- bootstrap.run
+
+ bootstrap_for_node(server).run
puts "\n"
puts "#{h.color("Instance ID", :cyan)}: #{server.id}"
@@ -204,6 +196,21 @@ class Chef
puts "#{h.color("Private IP Address", :cyan)}: #{server.private_ip_address}"
puts "#{h.color("Run List", :cyan)}: #{@name_args.join(', ')}"
end
+
+ def bootstrap_for_node(server)
+ bootstrap = Chef::Knife::Bootstrap.new
+ bootstrap.name_args = [server.dns_name]
+ bootstrap.config[:run_list] = @name_args
+ bootstrap.config[:ssh_user] = config[:ssh_user]
+ bootstrap.config[:identity_file] = config[:identity_file]
+ bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
+ bootstrap.config[:prerelease] = config[:prerelease]
+ bootstrap.config[:distro] = config[:distro]
+ bootstrap.config[:use_sudo] = true
+ bootstrap.config[:template_file] = config[:template_file]
+ bootstrap
+ end
+
end
end
end