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
|
# File 'lib/chef/knife/clodo_server_create.rb', line 141
def run
$stdout.sync = true
unless locate_config_value(: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
options = {
:vps_type => locate_config_value(:server_type),
:vps_memory => locate_config_value(:server_memory),
:vps_memory_max => locate_config_value(:server_memory_max),
:vps_hdd => locate_config_value(:server_disk),
:vps_admin => locate_config_value(:server_support_level),
:vps_os => locate_config_value(:image),
:vps_autoupdate => locate_config_value(:autoupdate)
}
options[:vps_title] = config[:server_name] if config[:server_name]
server = connection.servers.create(options)
puts "#{ui.color("ID", :cyan)}: #{server.id}"
puts "#{ui.color("Name", :cyan)}: #{server.name}"
puts "#{ui.color("Image", :cyan)}: #{server.image}"
puts "#{ui.color("IP", :cyan)}: #{server.public_ip_address}"
puts "#{ui.color("root password", :red)}: #{server.password}"
print "\n#{ui.color("Waiting server", :magenta)}"
server.wait_for(600, 10) do print "."; ready? end
puts("\n")
puts "#{ui.color("Public IP Address", :cyan)}: #{server.public_ip_address}"
puts "#{ui.color("Password", :cyan)}: #{server.password}"
print "\n#{ui.color("Waiting for sshd", :magenta)}"
print(".") until tcp_test_ssh(server.public_ip_address) { sleep @initial_sleep_delay ||= config[:bootstrap_delay].to_i; true; }
if File::exists? "#{ENV['HOME']}/.ssh/id_rsa.pub"
server.public_key_path = "#{ENV['HOME']}/.ssh/id_rsa.pub"
server.setup({:password => server.password})
end
bootstrap_for_node(server).run if locate_config_value(:distro) || locate_config_value(:template_file)
puts "\n"
puts "#{ui.color("Instance ID", :cyan)}: #{server.id}"
puts "#{ui.color("Name", :cyan)}: #{server.name}"
puts "#{ui.color("Image", :cyan)}: #{server.image}"
puts "#{ui.color("Public IP Address", :cyan)}: #{server.public_ip_address}"
puts "#{ui.color("Password", :cyan)}: #{server.password}"
puts "#{ui.color("Environment", :cyan)}: #{config[:environment] || '_default'}"
puts "#{ui.color("Run List", :cyan)}: #{config[:run_list].join(', ')}"
end
|