2012-04-28 13:05:06 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/terremark/models/shared/image'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Terremark
|
|
|
|
module Shared
|
|
|
|
|
|
|
|
|
|
|
|
module Mock
|
|
|
|
def images(options = {})
|
2012-12-22 18:23:10 -05:00
|
|
|
Fog::Terremark::Shared::Images.new(options.merge(:service => self))
|
2012-04-28 13:05:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Real
|
|
|
|
def images(options = {})
|
2012-12-22 18:23:10 -05:00
|
|
|
Fog::Terremark::Shared::Images.new(options.merge(:service => self))
|
2012-04-28 13:05:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Images < Fog::Collection
|
|
|
|
|
|
|
|
|
2012-12-22 18:23:10 -05:00
|
|
|
model Fog::Terremark::Shared::Image
|
2012-04-28 13:05:06 -04:00
|
|
|
|
|
|
|
def all
|
2012-12-22 18:23:10 -05:00
|
|
|
data = service.get_catalog(vdc_id).body['CatalogItems'].select do |entity|
|
2012-04-28 13:05:06 -04:00
|
|
|
entity['type'] == "application/vnd.vmware.vcloud.catalogItem+xml"
|
|
|
|
end
|
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def vdc_id
|
2012-12-22 18:23:10 -05:00
|
|
|
@vdc_id ||= service.default_vdc_id
|
2012-04-28 13:05:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def vdc_id=(new_vdc_id)
|
|
|
|
@vdc_id = new_vdc_id
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|