mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
3e240474ac
vCloud has also the concept of links in the responses. So we should make use of them to navigate through the tree of resources in the vCloud. Furthermore, we can make various calls a bit easier by directly returning the specific resource object than the plain xml response. Adjust tests to work with the new changes, and also test the added parts.
38 lines
913 B
Ruby
38 lines
913 B
Ruby
require 'fog/vcloud/models/compute/catalog'
|
|
|
|
module Fog
|
|
module Vcloud
|
|
class Compute
|
|
class Catalogs < Fog::Vcloud::Collection
|
|
|
|
model Fog::Vcloud::Compute::Catalog
|
|
|
|
attribute :organization_uri
|
|
|
|
def all
|
|
org_uri = self.organization_uri || connection.default_organization_uri
|
|
data = connection.get_organization(org_uri).links.select { |link| link[:type] == "application/vnd.vmware.vcloud.catalog+xml" }
|
|
load(data)
|
|
end
|
|
|
|
def get(uri)
|
|
connection.get_catalog(uri)
|
|
rescue Fog::Errors::NotFound
|
|
nil
|
|
end
|
|
|
|
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
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|