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

Wait for RackConnect before bootstrapping #35

Closed
wants to merge 10 commits into from
30 changes: 26 additions & 4 deletions lib/chef/knife/rackspace_server_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class RackspaceServerCreate < Knife
:proc => Proc.new { |m| Chef::Config[:knife][:rackspace_metadata] = JSON.parse(m) },
:default => ""

option :rackconnect_wait,
:long => "--rackconnect-wait",
:description => "Wait until the Rackconnect automation setup is complete before bootstrapping chef"

option :hint,
:long => "--hint HINT_NAME[=HINT_FILE]",
:description => "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
Expand Down Expand Up @@ -184,19 +188,37 @@ def run
msg_pair("Name", server.name)
msg_pair("Flavor", server.flavor.name)
msg_pair("Image", server.image.name)
msg_pair("Metadata", server.metadata)

print "\n#{ui.color("Waiting server", :magenta)}"
msg_pair("Metadata", server.metadata.all)
msg_pair("RackConnect", Chef::Config[:knife][:rackconnect_wait] ? 'yes' : 'no')

# wait for it to be ready to do stuff
server.wait_for { print "."; ready? }
begin
server.wait_for(1200) {
print ".";
Chef::Log.debug("#{progress}%")
if Chef::Config[:knife][:rackconnect_wait]
Chef::Log.debug("rackconnect_automation_status: #{metadata.all['rackconnect_automation_status']}")
Chef::Log.debug("rax_service_level_automation: #{metadata.all['rax_service_level_automation']}")
ready? and metadata.all['rackconnect_automation_status'] == 'DEPLOYED' and metadata.all['rax_service_level_automation'] == 'Complete'
else
ready?
end
}
rescue Fog::Errors::TimeoutError
ui.error('Timeout waiting for the server to be created')
msg_pair('Progress', "#{server.progress}%")
msg_pair('rackconnect_automation_status', server.metadata.all['rackconnect_automation_status'])
msg_pair('rax_service_level_automation', server.metadata.all['rax_service_level_automation'])
Chef::Application.fatal! 'Server didn\'t finish on time'
end

puts("\n")

msg_pair("Public DNS Name", public_dns_name(server))
msg_pair("Public IP Address", public_ip(server))
msg_pair("Private IP Address", private_ip(server))
msg_pair("Password", server.password)
msg_pair("Metadata", server.metadata.all)

print "\n#{ui.color("Waiting for sshd", :magenta)}"

Expand Down
2 changes: 1 addition & 1 deletion lib/knife-rackspace/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Knife
module Rackspace
VERSION = "0.6.3"
VERSION = "0.6.4"
MAJOR, MINOR, TINY = VERSION.split('.')
end
end