2011-01-19 15:47:35 -05:00
|
|
|
module Fog
|
|
|
|
module Voxel
|
|
|
|
class Compute
|
|
|
|
class Real
|
|
|
|
def images_list( image_id = nil )
|
|
|
|
options = { :verbosity => 'compact' }
|
|
|
|
|
|
|
|
unless image_id.nil?
|
|
|
|
options[:verbosity] = 'extended'
|
|
|
|
options[:image_id] = image_id
|
|
|
|
end
|
|
|
|
|
|
|
|
data = request("voxel.images.list", options)
|
2011-02-09 11:04:31 -05:00
|
|
|
|
|
|
|
if data['stat'] == "ok"
|
|
|
|
images = data['images']['image']
|
|
|
|
images = [ images ] if images.is_a?(Hash)
|
|
|
|
|
|
|
|
images.map { |i| { :id => i['id'], :name => i['summary'] } }
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
2011-01-19 15:47:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
2011-02-09 11:04:31 -05:00
|
|
|
def images_list( image_id = nil )
|
|
|
|
images = [ { :id => 1, :name => "CentOS 5 x64" }, { :id => 2, :name => "Ubuntu 10.04 LTS x64" } ]
|
|
|
|
|
|
|
|
if image_id.nil?
|
|
|
|
images
|
|
|
|
else
|
|
|
|
images.select { |i| i[:id] == image_id }
|
|
|
|
end
|
2011-01-19 15:47:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|