137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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
|
# File 'lib/chef/knife/rax_cluster_build.rb', line 137
def run
$stdout.sync = true
unless Chef::Config[:knife][: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
node_name = get_node_name(config[:chef_node_name] || config[:server_name])
server = connection.servers.create(
:name => node_name,
:image_id => Chef::Config[:knife][:image],
:flavor_id => locate_config_value(:flavor),
:metadata => Chef::Config[:knife][:rackspace_metadata]
)
msg_pair("Instance ID", server.id)
msg_pair("Host ID", server.host_id)
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)}"
server.wait_for { print "."; ready? }
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)
print "\n#{ui.color("Waiting for sshd", :magenta)}"
bootstrap_ip_address = public_ip(server)
if config[:private_network]
bootstrap_ip_address = private_ip(server)
end
Chef::Log.debug("Bootstrap IP Address #{bootstrap_ip_address}")
if bootstrap_ip_address.nil?
ui.error("No IP address available for bootstrapping.")
exit 1
end
print(".") until tcp_test_ssh(bootstrap_ip_address) {
sleep @initial_sleep_delay ||= 10
puts("done")
}
bootstrap_for_node(server, bootstrap_ip_address).run
puts "\n"
msg_pair("Instance ID", server.id)
msg_pair("Host ID", server.host_id)
msg_pair("Name", server.name)
msg_pair("Flavor", server.flavor.name)
msg_pair("Image", server.image.name)
msg_pair("Metadata", server.metadata)
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("Environment", config[:environment] || '_default')
msg_pair("Run List", config[:run_list].join(', '))
ipaddress = ''
return_hash = {"public_ip" => public_ip(server), "private_ip" => private_ip(server), "server_name" => server.name, "server_id" => server.id}
return return_hash
end
|