2012-07-30 18:22:16 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/rackspace/models/compute_v2/server'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class RackspaceV2
|
2012-11-01 16:24:43 -04:00
|
|
|
|
2012-07-30 18:22:16 -04:00
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Compute::RackspaceV2::Server
|
|
|
|
|
|
|
|
def all
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.list_servers.body['servers']
|
2012-07-30 18:22:16 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
2012-11-01 16:24:43 -04:00
|
|
|
def bootstrap(new_attributes = {})
|
|
|
|
server = create(new_attributes)
|
|
|
|
server.wait_for { ready? }
|
|
|
|
server.setup(:password => server.password)
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
2012-07-30 18:22:16 -04:00
|
|
|
def get(server_id)
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.get_server(server_id).body['server']
|
2012-07-30 18:22:16 -04:00
|
|
|
new(data)
|
|
|
|
rescue Fog::Compute::RackspaceV2::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|