2011-01-19 17:07:04 -05:00
|
|
|
require 'fog/core/collection'
|
2011-08-24 21:04:55 -04:00
|
|
|
require 'fog/voxel/models/compute/server'
|
2011-01-19 17:07:04 -05:00
|
|
|
|
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Voxel
|
2011-01-19 17:07:04 -05:00
|
|
|
class Servers < Fog::Collection
|
|
|
|
|
2011-06-16 19:28:54 -04:00
|
|
|
model Fog::Compute::Voxel::Server
|
2011-01-19 17:07:04 -05:00
|
|
|
|
|
|
|
def all
|
2012-12-22 18:22:08 -05:00
|
|
|
data = service.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)
|
2012-12-22 18:22:08 -05:00
|
|
|
if device_id && server = service.devices_list(device_id).body['devices']
|
2011-03-10 19:34:55 -05:00
|
|
|
new(server.first)
|
|
|
|
end
|
|
|
|
rescue Fog::Service::Error => error
|
|
|
|
if error.message == "The device_id passed in can't be matched to a valid device."
|
|
|
|
nil
|
|
|
|
else
|
|
|
|
raise error
|
2011-01-19 17:07:04 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|