2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 21:16:01 -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
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Rackspace
|
2009-10-15 01:03:16 -04:00
|
|
|
class Servers < Fog::Collection
|
2011-06-16 19:28:54 -04:00
|
|
|
model Fog::Compute::Rackspace::Server
|
2009-10-30 02:35:28 -04:00
|
|
|
|
2009-10-15 01:03:16 -04:00
|
|
|
def all
|
2012-12-22 18:24:03 -05:00
|
|
|
data = service.list_servers_detail.body['servers']
|
2010-03-06 23:02:10 -05:00
|
|
|
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? }
|
2010-09-15 20:31:45 -04:00
|
|
|
server.setup(:password => server.password)
|
2010-06-06 02:05:06 -04:00
|
|
|
server
|
|
|
|
end
|
|
|
|
|
2009-11-15 23:05:59 -05:00
|
|
|
def get(server_id)
|
2012-12-22 18:24:03 -05:00
|
|
|
if server = service.get_server_details(server_id).body['server']
|
2010-01-13 01:00:49 -05:00
|
|
|
new(server)
|
|
|
|
end
|
2011-06-16 19:28:54 -04:00
|
|
|
rescue Fog::Compute::Rackspace::NotFound
|
2009-10-15 01:03:16 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|