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

miscelanea

This commit is contained in:
Rodrigo Estebanez 2013-06-18 20:51:12 +02:00
parent 9204be2209
commit fe8b99b544
5 changed files with 15 additions and 9 deletions

View file

@ -51,6 +51,8 @@ module Fog
collection :catalogs
model :catalog_item
collection :catalog_items
model :vdc
collection :vdcs
request_path 'fog/vcloudng/requests/compute'
request :get_organizations

View file

@ -15,7 +15,8 @@ module Fog
attribute :is_published, :aliases => 'IsPublished'
def catalog_items
requires :id
service.catalog_items(:catalog => self)
end
end

View file

@ -10,11 +10,11 @@ module Fog
attribute :organization
def all
data = service.get_organization(organization.id).body
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" }
catalogs.each {|catalog| catalog['id'] =catalog['href'].split('/').last }
load(catalogs)
catalog_ids = catalogs.map {|catalog| catalog['href'].split('/').last }
catalog_ids.map{ |catalog_id| get(catalog_id)}
end
def get(catalog_id)

View file

@ -12,15 +12,14 @@ module Fog
attribute :type
attribute :href
attribute :description, :aliases => 'Description'
attribute :links, :aliases => 'Links'
def vdc
def vdcs
requires :id
service.vdcs(:organization => self)
end
def catalogs
requires :id
service.catalogs(:organization => self)
end

View file

@ -25,10 +25,14 @@ module Fog
when 'Entity'
entity_item = extract_attributes(attributes)
entity_item["id"] = entity_item["href"].split('/').last
@response['vapp_template_id'] = entity_item["id"]
@response['Entity'] = entity_item
when 'CatalogItem'
catalog_item = extract_attributes(attributes)
@response['name'] = catalog_item['name']
@response['type'] = catalog_item['type']
@response['href'] = catalog_item['href']
@response['id'] = catalog_item['href'].split('/').last
when "Link"
link = extract_attributes(attributes)
@response["Links"] << link