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

adapting catalog to the new parser

This commit is contained in:
Rodrigo Estebanez 2013-06-19 17:06:24 +02:00
parent fe8b99b544
commit c0f7973875
3 changed files with 7 additions and 6 deletions

View file

@ -11,8 +11,8 @@ module Fog
attribute :name
attribute :type
attribute :href
attribute :description, :aliases => 'Description'
attribute :is_published, :aliases => 'IsPublished'
attribute :description, :aliases => :Description
attribute :is_published, :aliases => :IsPublished
def catalog_items
requires :id

View file

@ -12,14 +12,15 @@ module Fog
def all(organization_id = organization.id)
data = service.get_organization(organization_id).body
catalogs = data["Links"].select { |link| link["type"] == "application/vnd.vmware.vcloud.catalog+xml" }
catalog_ids = catalogs.map {|catalog| catalog['href'].split('/').last }
catalogs = data[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.catalog+xml" }
catalog_ids = catalogs.map {|catalog| catalog[:href].split('/').last }
catalog_ids.map{ |catalog_id| get(catalog_id)}
end
def get(catalog_id)
data = service.get_catalog(catalog_id).body
%w(CatalogItems Links).each {|key_to_delete| data.delete(key_to_delete) }
%w(:CatalogItems :Link).each {|key_to_delete| data.delete(key_to_delete) }
data[:id] = data[:href].split('/').last
new(data)
end
end

View file

@ -32,7 +32,7 @@ module Fog
:expects => 200,
:headers => { 'Accept' => 'application/*+xml;version=1.5' },
:method => 'GET',
:parser => Fog::Parsers::Compute::Vcloudng::GetCatalog.new,
:parser => Fog::ToHashDocument.new,
:path => "catalog/#{catalog_uuid}"
)
end