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
ggoodale 2a9224cfa7 [bbg] flesh out bbg support
Added basic spec framework; changed class names to match the template fog seems to prefer

Servers tests pass; create and delete implemented.

Added an example script

Properly handle a 409 response from the API

Fixed BBG code to work with the new api endpoint changes; tweaks to the (currently nonexistent) reboot api call

Implement the reboot command for blocks
2010-06-03 14:48:53 -07:00

44 lines
808 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['blocks']
load(data)
end
def get(server_id)
if server_id && server = connection.get_block(server_id).body
new(server)
elsif !server_id
nil
end
rescue Excon::Errors::NotFound
# No server found with that id
nil
rescue Excon::Errors::Forbidden
nil
end
end
end
end