2011-08-24 21:11:42 -04:00
|
|
|
require 'fog/vcloud/models/compute/catalog'
|
|
|
|
|
2011-05-24 02:25:28 -04:00
|
|
|
module Fog
|
|
|
|
module Vcloud
|
|
|
|
class Compute
|
|
|
|
class Catalogs < Fog::Vcloud::Collection
|
|
|
|
|
|
|
|
model Fog::Vcloud::Compute::Catalog
|
|
|
|
|
2011-09-26 08:13:10 -04:00
|
|
|
attribute :organization_uri
|
|
|
|
|
2011-05-24 02:25:28 -04:00
|
|
|
def all
|
2011-09-26 08:13:10 -04:00
|
|
|
org_uri = self.organization_uri || connection.default_organization_uri
|
2012-01-30 09:24:14 -05:00
|
|
|
data = connection.get_organization(org_uri).links.select { |link| link[:type] == "application/vnd.vmware.vcloud.catalog+xml" }
|
2011-05-24 02:25:28 -04:00
|
|
|
load(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(uri)
|
2012-01-30 09:24:14 -05:00
|
|
|
connection.get_catalog(uri)
|
2011-05-24 02:25:28 -04:00
|
|
|
rescue Fog::Errors::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2011-06-15 21:28:30 -04:00
|
|
|
def item_by_name(name)
|
|
|
|
res = nil
|
|
|
|
items = all.collect { |catalog| catalog.catalog_items }
|
|
|
|
items.each do |i|
|
|
|
|
i.collect do |ii|
|
|
|
|
res = ii if ii.name == name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
res
|
|
|
|
end
|
|
|
|
|
2011-05-24 02:25:28 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|