2009-10-15 01:03:16 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
class Servers
|
|
|
|
|
|
|
|
def servers
|
|
|
|
Fog::Rackspace::Servers::Servers.new(:connection => self)
|
|
|
|
end
|
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
2009-10-30 03:11:50 -04:00
|
|
|
model Fog::Rackspace::Servers::Server
|
2009-10-30 02:35:28 -04:00
|
|
|
|
2009-10-15 01:03:16 -04:00
|
|
|
def all
|
2010-01-05 01:03:24 -05:00
|
|
|
if @loaded
|
|
|
|
clear
|
|
|
|
end
|
|
|
|
@loaded = true
|
2009-11-04 00:46:27 -05:00
|
|
|
data = connection.list_servers_detail.body
|
2009-10-15 01:03:16 -04:00
|
|
|
for server in data['servers']
|
2010-01-05 01:03:24 -05:00
|
|
|
self << new(server)
|
2009-10-15 01:03:16 -04:00
|
|
|
end
|
2010-01-05 01:03:24 -05:00
|
|
|
self
|
2009-10-15 01:03:16 -04:00
|
|
|
end
|
|
|
|
|
2009-11-15 23:05:59 -05:00
|
|
|
def get(server_id)
|
|
|
|
connection.get_server_details(server_id)
|
2009-11-08 15:16:52 -05:00
|
|
|
rescue Excon::Errors::NotFound
|
2009-10-15 01:03:16 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|