164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/chef/knife/brightbox_server_create.rb', line 164
def run
$stdout.sync = true
unless config[:image]
ui.error("You have not provided a valid image value. Please note the short option for this value recently changed from '-i' to '-I'.")
exit 1
end
print "#{ui.color("Creating server... ", :magenta)}"
server = connection.servers.create(
:name => config[:server_name] || config[:chef_node_name],
:image_id => config[:image],
:zone_id => zone_id,
:flavor_id => config[:flavor]
)
puts " done \n"
puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
puts "#{ui.color("Name", :cyan)}: #{server.name}"
puts "#{ui.color("Flavor", :cyan)}: #{server.flavor_id}"
puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
puts "#{ui.color("Zone", :cyan)}: #{server.zone['handle']}"
print "\n#{ui.color("Waiting server", :magenta)}"
server.wait_for { print "."; service.servers.get(server.id).ready? }
puts("\n")
print "#{ui.color("Creating cloud ip ", :magenta)}"
ip = connection.create_cloud_ip
cip = connection.cloud_ips.get ip['id']
destination_id = server.interfaces.last['id']
cip.map destination_id
server.wait_for { print "."; service.cloud_ips.get(ip['id']).mapped? }
puts " done\n"
server = connection.servers.get(server.id)
puts "#{ui.color("Public IP Address", :cyan)}: #{server.public_ip_address}"
puts "#{ui.color("Private IP Address", :cyan)}: #{server.private_ip_address}"
config[:server_groups].each do |server_group|
connection.add_servers_server_group(server_group,
:servers => [{ :server => server.id }])
end
print "\n#{ui.color("Bootstrapping server ", :magenta)}"
print "\n#{ui.color("Waiting for sshd ", :magenta)}"
print(".") until tcp_test_ssh(server.public_ip_address) { sleep @initial_sleep_delay ||= 10; puts(" done") }
bootstrap_for_node(server).run
puts "\n"
puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
puts "#{ui.color("Name", :cyan)}: #{server.name}"
puts "#{ui.color("Flavor", :cyan)}: #{server.flavor_id}"
puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
puts "#{ui.color("Public IP Address", :cyan)}: #{server.public_ip_address}"
puts "#{ui.color("Private IP Address", :cyan)}: #{server.private_ip_address}"
puts "#{ui.color("Environment", :cyan)}: #{config[:environment] || '_default'}"
puts "#{ui.color("Run List", :cyan)}: #{config[:run_list].join(', ')}"
end
|