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

39 lines
696 B
Ruby

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
load(data)
end
def get(server_id)
if server_id && server = connection.get_block(server_id).body
new(server)
end
rescue Excon::Errors::Forbidden, Excon::Errors::NotFound
nil
end
end
end
end