2010-03-19 21:29:42 -04:00
|
|
|
require 'fog/collection'
|
2010-09-08 17:00:43 -04:00
|
|
|
require 'fog/rackspace/models/compute/server'
|
2010-03-19 21:29:42 -04:00
|
|
|
|
2009-10-15 01:03:16 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2010-09-08 16:50:23 -04:00
|
|
|
class Compute
|
2009-10-15 01:03:16 -04:00
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
2010-09-08 16:50:23 -04:00
|
|
|
model Fog::Rackspace::Compute::Server
|
2009-10-30 02:35:28 -04:00
|
|
|
|
2009-10-15 01:03:16 -04:00
|
|
|
def all
|
2010-03-06 23:02:10 -05:00
|
|
|
data = connection.list_servers_detail.body['servers']
|
|
|
|
load(data)
|
2009-10-15 01:03:16 -04:00
|
|
|
end
|
|
|
|
|
2010-06-06 02:05:06 -04:00
|
|
|
def bootstrap(new_attributes = {})
|
|
|
|
server = create(new_attributes)
|
|
|
|
server.wait_for { ready? }
|
|
|
|
server.setup
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
2009-11-15 23:05:59 -05:00
|
|
|
def get(server_id)
|
2010-01-13 01:00:49 -05:00
|
|
|
if server = connection.get_server_details(server_id).body['server']
|
|
|
|
new(server)
|
|
|
|
end
|
2010-09-08 16:50:23 -04:00
|
|
|
rescue Fog::Rackspace::Compute::NotFound
|
2009-10-15 01:03:16 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|