mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
parse description and links, remove non existing attar property
This commit is contained in:
parent
a40c4c20a6
commit
a732a303d5
1 changed files with 23 additions and 9 deletions
|
|
@ -1,3 +1,13 @@
|
|||
#
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <CatalogItem xmlns="http://www.vmware.com/vcloud/v1.5" name="DEVRHL" id="urn:vcloud:catalogitem:5437aa3f-e369-40b2-b985-2e63e1bc9f2e" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://example.com/api/catalogItem/5437aa3f-e369-40b2-b985-2e63e1bc9f2e" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.194.1.65/api/v1.5/schema/master.xsd">
|
||||
# <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://example.com/api/catalog/4ee720e5-173a-41ac-824b-6f4908bac975"/>
|
||||
# <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/catalogItem/5437aa3f-e369-40b2-b985-2e63e1bc9f2e/metadata"/>
|
||||
# <Description>Red Hat Enterprise Linux 6</Description>
|
||||
# <Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="DEVRHL" href="https://example.com/api/vAppTemplate/vappTemplate-165f7321-968e-4f60-93ab-ceea2044200f"/>
|
||||
# </CatalogItem>
|
||||
|
||||
|
||||
module Fog
|
||||
module Parsers
|
||||
module Vcloudng
|
||||
|
|
@ -6,27 +16,31 @@ module Fog
|
|||
class GetCatalogItem < VcloudngParser
|
||||
|
||||
def reset
|
||||
@response = { 'Entity' => {}, 'Properties' => {} }
|
||||
@response = { 'Entity' => {}, 'Links' => [] }
|
||||
end
|
||||
|
||||
def start_element(name, attributes)
|
||||
super
|
||||
case name
|
||||
when 'Entity'
|
||||
@response['Entity'] = extract_attributes(attributes)
|
||||
entity_item = extract_attributes(attributes)
|
||||
entity_item["id"] = entity_item["href"].split('/').last
|
||||
@response['Entity'] = entity_item
|
||||
when 'CatalogItem'
|
||||
catalog_item = extract_attributes(attributes)
|
||||
@response['name'] = catalog_item['name']
|
||||
when 'Property'
|
||||
@property_key = attributes.value
|
||||
when "Link"
|
||||
link = extract_attributes(attributes)
|
||||
@response["Links"] << link
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if name == 'Description'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
if name == 'Property'
|
||||
@response['Properties'][@property_key] = value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue