lib/fog/rackspace/examples/compute_v2/create_server.rb in fog-1.20.0 vs lib/fog/rackspace/examples/compute_v2/create_server.rb in fog-1.21.0

- old
+ new

@@ -9,11 +9,11 @@ def get_user_input(prompt) print "#{prompt}: " gets.chomp end -# Use username defined in ~/.fog file, if absent prompt for username. +# Use username defined in ~/.fog file, if absent prompt for username. # For more details on ~/.fog refer to http://fog.io/about/getting_started.html def rackspace_username Fog.credentials[:rackspace_username] || get_user_input("Enter Rackspace Username") end @@ -40,48 +40,48 @@ # prompt for server name server_name = get_user_input "\nEnter Server Name" # create server -server = service.servers.create :name => server_name, - :flavor_id => flavor.id, +server = service.servers.create :name => server_name, + :flavor_id => flavor.id, :image_id => image.id, :metadata => { 'fog_sample' => 'true'}, :personality => [{ :path => '/root/fog.txt', :contents => Base64.encode64('Fog was here!') }] # reload flavor in order to retrieve all of its attributes flavor.reload -puts "\nNow creating server '#{server.name}' the following with specifications:\n" +puts "\nNow creating server '#{server.name}' the following with specifications:\n" puts "\t* #{flavor.ram} MB RAM" puts "\t* #{flavor.disk} GB" puts "\t* #{flavor.vcpus} CPU(s)" puts "\t* #{image.name}" puts "\n" begin - # Check every 5 seconds to see if server is in the active state (ready?). + # Check every 5 seconds to see if server is in the active state (ready?). # If the server has not been built in 5 minutes (600 seconds) an exception will be raised. server.wait_for(600, 5) do print "." STDOUT.flush ready? end - + puts "[DONE]\n\n" puts "The server has been successfully created, to login onto the server:\n\n" puts "\t ssh #{server.username}@#{server.public_ip_address}\n\n" - + rescue Fog::Errors::TimeoutError puts "[TIMEOUT]\n\n" - + puts "This server is currently #{server.progress}% into the build process and is taking longer to complete than expected." - puts "You can continute to monitor the build process through the web console at https://mycloud.rackspace.com/\n\n" + puts "You can continute to monitor the build process through the web console at https://mycloud.rackspace.com/\n\n" end puts "The #{server.username} password is #{server.password}\n\n" puts "To delete the server please execute the delete_server.rb script\n\n"