2011-01-19 17:07:04 -05:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/compute/models/voxel/server'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Voxel
|
|
|
|
class Compute
|
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
|
|
|
model Fog::Voxel::Compute::Server
|
|
|
|
|
|
|
|
def all
|
2011-02-23 18:00:56 -05:00
|
|
|
data = connection.devices_list.body['devices'].select {|device| device['type']['id'] == '3'}
|
2011-01-19 17:07:04 -05:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(device_id)
|
2011-02-23 18:00:56 -05:00
|
|
|
if device_id && server = connection.devices_list(device_id).body['devices']
|
2011-01-19 19:17:23 -05:00
|
|
|
|
2011-02-23 18:00:56 -05:00
|
|
|
if server.empty?
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
new(server.first)
|
|
|
|
end
|
2011-01-19 17:07:04 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|