1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

CloudStack: images.get always returns nil - fixed

This commit is contained in:
alex 2012-08-08 22:00:34 +03:00
parent 5156e8e4f7
commit 8dc5148658

View file

@ -10,23 +10,32 @@ module Fog
model Fog::Compute::Cloudstack::Image
def all(filters={})
options = {
'templatefilter' => 'self'
}.merge(filters)
options = get_filter_options(filters)
data = connection.list_templates(options)["listtemplatesresponse"]["template"] || []
load(data)
end
def get(template_id)
if template = connection.list_templates('id' => template_id)["listtemplatesresponse"]["template"].first
def get(template_id, filters={})
filter_option = get_filter_options(filters)
options = filter_option.merge('id' => template_id)
if template = connection.list_templates(options)["listtemplatesresponse"]["template"].first
new(template)
end
rescue Fog::Compute::Cloudstack::BadRequest
nil
end
end
private
def get_filter_options(filters)
default_filter = {
'templatefilter' => 'self'
}
default_filter.merge(filters)
end
end
end
end
end