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
|
|
|
|
|
|
|
|
def all
|
2009-10-16 13:26:15 -04:00
|
|
|
data = connection.list_servers_details.body
|
2009-10-15 01:03:16 -04:00
|
|
|
servers = Fog::Rackspace::Servers::Servers.new({
|
|
|
|
:connection => connection
|
|
|
|
})
|
|
|
|
for server in data['servers']
|
|
|
|
servers << Fog::Rackspace::Servers::Server.new({
|
2009-10-25 21:24:20 -04:00
|
|
|
:collection => servers,
|
|
|
|
:connection => connection
|
2009-10-15 01:03:16 -04:00
|
|
|
}.merge!(server))
|
|
|
|
end
|
|
|
|
servers
|
|
|
|
end
|
|
|
|
|
|
|
|
def create(attributes = {})
|
|
|
|
server = new(attributes)
|
|
|
|
server.save
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(id)
|
|
|
|
connection.get_server_details(id)
|
|
|
|
rescue Fog::Errors::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2009-10-15 18:38:33 -04:00
|
|
|
def new(attributes = {})
|
|
|
|
Fog::Rackspace::Servers::Server.new({
|
2009-10-25 21:24:20 -04:00
|
|
|
:collection => self,
|
|
|
|
:connection => connection
|
2009-10-15 18:38:33 -04:00
|
|
|
}.merge!(attributes))
|
2009-10-15 01:03:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def reload
|
2009-10-29 01:51:44 -04:00
|
|
|
self.clear.concat(all)
|
2009-10-15 01:03:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|