mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
49 lines
953 B
Ruby
49 lines
953 B
Ruby
![]() |
require 'fog/core/collection'
|
||
|
require 'fog/terremark/models/shared/image'
|
||
|
|
||
|
module Fog
|
||
|
module Terremark
|
||
|
module Shared
|
||
|
|
||
|
|
||
|
module Mock
|
||
|
def images(options = {})
|
||
|
Fog::Terremark::Shared::Images.new(options.merge(:connection => self))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
module Real
|
||
|
def images(options = {})
|
||
|
Fog::Terremark::Shared::Images.new(options.merge(:connection => self))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class Images < Fog::Collection
|
||
|
|
||
|
|
||
|
model Fog::Terremark::Shared::Image
|
||
|
|
||
|
def all
|
||
|
data = connection.get_catalog(vdc_id).body['CatalogItems'].select do |entity|
|
||
|
entity['type'] == "application/vnd.vmware.vcloud.catalogItem+xml"
|
||
|
end
|
||
|
load(data)
|
||
|
end
|
||
|
|
||
|
|
||
|
def vdc_id
|
||
|
@vdc_id ||= connection.default_vdc_id
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def vdc_id=(new_vdc_id)
|
||
|
@vdc_id = new_vdc_id
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|
||
|
end
|