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/bluebox/models/servers.rb

40 lines
706 B
Ruby
Raw Normal View History

require 'fog/collection'
require 'fog/bluebox/models/server'
module Fog
module Bluebox
class Mock
def servers
Fog::Bluebox::Servers.new(:connection => self)
end
end
class Real
def servers
Fog::Bluebox::Servers.new(:connection => self)
end
end
class Servers < Fog::Collection
model Fog::Bluebox::Server
def all
data = connection.get_blocks.body['blocks']
load(data)
end
def get(server_id)
if server_id && server = connection.get_block(server_id).body
new(server)
end
2010-06-02 01:01:10 -04:00
rescue Excon::Errors::Forbidden, Excon::Errors::NotFound
nil
end
end
end
end