2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/collection'
|
2010-09-08 17:00:43 -04:00
|
|
|
require 'fog/bluebox/models/compute/server'
|
2010-09-07 19:26:01 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Bluebox
|
2010-09-08 15:07:45 -04:00
|
|
|
class Compute
|
2010-09-07 19:26:01 -04:00
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
2010-09-08 17:00:43 -04:00
|
|
|
model Fog::Bluebox::Compute::Server
|
2010-09-07 19:26:01 -04:00
|
|
|
|
|
|
|
def all
|
|
|
|
data = connection.get_blocks.body
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
2010-09-28 01:12:41 -04:00
|
|
|
def bootstrap(new_attributes = {})
|
|
|
|
server = create(new_attributes)
|
|
|
|
server.wait_for { ready? }
|
|
|
|
server.setup(:key_data => [server.private_key])
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
2010-09-07 19:26:01 -04:00
|
|
|
def get(server_id)
|
|
|
|
if server_id && server = connection.get_block(server_id).body
|
|
|
|
new(server)
|
|
|
|
end
|
2010-09-08 17:00:43 -04:00
|
|
|
rescue Fog::Bluebox::Compute::NotFound
|
2010-09-07 19:26:01 -04:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|