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/voxel/models/compute/servers.rb

33 lines
750 B
Ruby
Raw Normal View History

2011-01-19 17:07:04 -05:00
require 'fog/core/collection'
require 'fog/voxel/models/compute/server'
2011-01-19 17:07:04 -05:00
module Fog
module Compute
class Voxel
2011-01-19 17:07:04 -05:00
class Servers < Fog::Collection
model Fog::Compute::Voxel::Server
2011-01-19 17:07:04 -05:00
def all
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)
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