2010-03-17 20:51:55 -07:00
|
|
|
require 'fog/collection'
|
|
|
|
require 'fog/slicehost/models/server'
|
|
|
|
|
2010-02-04 00:27:14 -08:00
|
|
|
module Fog
|
2010-03-17 20:51:55 -07:00
|
|
|
module Slicehost
|
2010-02-04 00:27:14 -08:00
|
|
|
|
2010-04-04 21:41:15 -07:00
|
|
|
class Mock
|
|
|
|
def servers
|
|
|
|
Fog::Slicehost::Servers.new(:connection => self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Real
|
|
|
|
def servers
|
|
|
|
Fog::Slicehost::Servers.new(:connection => self)
|
|
|
|
end
|
2010-02-04 00:27:14 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Slicehost::Server
|
|
|
|
|
|
|
|
def all
|
|
|
|
data = connection.get_slices.body['slices']
|
2010-03-06 20:02:10 -08:00
|
|
|
load(data)
|
2010-02-04 00:27:14 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(server_id)
|
|
|
|
if server_id && server = connection.get_slice(server_id).body
|
|
|
|
new(server)
|
|
|
|
elsif !server_id
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
rescue Excon::Errors::Forbidden
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|