2010-10-04 17:02:08 -04:00
|
|
|
require 'fog/core/collection'
|
2010-09-09 20:50:38 -04:00
|
|
|
require 'fog/slicehost/models/compute/server'
|
2010-09-08 18:00:47 -04:00
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Slicehost
|
|
|
|
class Compute
|
|
|
|
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
2010-09-09 20:50:38 -04:00
|
|
|
model Fog::Slicehost::Compute::Server
|
2010-09-08 18:00:47 -04:00
|
|
|
|
|
|
|
def all
|
|
|
|
data = connection.get_slices.body['slices']
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
2010-09-27 23:38:17 -04:00
|
|
|
def bootstrap(new_attributes = {})
|
|
|
|
server = create(new_attributes)
|
|
|
|
server.wait_for { ready? }
|
|
|
|
server.setup(:password => server.password)
|
|
|
|
server
|
|
|
|
end
|
|
|
|
|
2010-09-08 18:00:47 -04:00
|
|
|
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
|
|
|
|
end
|