Sha256: 9037adba8aceeee314e39c9a5f2fad382352244a71afb46c6b6d2459a32e45a1

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

require 'fog'

volume_name = 'my_volume'
connection_opts = {
    :rackspace_username   => ENV['RAX_USERNAME'],
    :rackspace_api_key    => ENV['RAX_API_KEY'],
    :rackspace_region     => ENV['RAX_REGION'].downcase.to_sym,
    :rackspace_auth_url   => "#{ENV['RAX_AUTH_URL']}/v2.0"
}

compute = Fog::Compute.new(connection_opts.merge(:provider => 'rackspace'))

server = compute.servers.create :name => 'Fog Server',
                       :flavor_id => ENV['SERVER1_FLAVOR'],
                       :image_id => ENV['SERVER1_IMAGE']

server.wait_for(600, 5) do
  print "."
  STDOUT.flush
  ready?
end

server = server.reload

cbs_service = Fog::Rackspace::BlockStorage.new(connection_opts)

puts "\nCreating Volume\n"
volume = cbs_service.volumes.create(:size => 100, :display_name => volume_name)
puts "\nAttaching volume\n"
attachment = server.attach_volume volume

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polytrix-0.0.1 sdks/fog/challenges/provision_scalable_webapp.rb