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:
parent
fe8b99b544
commit
c0f7973875
3 changed files with 7 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue