1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/rackspace/models/servers/servers.rb

52 lines
1.1 KiB
Ruby

module Fog
module Rackspace
class Servers
def servers
Fog::Rackspace::Servers::Servers.new(:connection => self)
end
class Servers < Fog::Collection
def all
data = connection.list_servers_details.body
servers = Fog::Rackspace::Servers::Servers.new({
:connection => connection
})
for server in data['servers']
servers << Fog::Rackspace::Servers::Server.new({
:collection => servers,
:connection => connection
}.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
def new(attributes = {})
Fog::Rackspace::Servers::Server.new({
:collection => self,
:connection => connection
}.merge!(attributes))
end
def reload
all
end
end
end
end
end