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

removing all parsers

This commit is contained in:
Rodrigo Estebanez 2013-06-19 17:09:15 +02:00
parent c2f3a4b315
commit 71fe702a56
8 changed files with 0 additions and 831 deletions

View file

@ -1,63 +0,0 @@
#
#<?xml version="1.0" encoding="UTF-8"?>
#<Catalog xmlns="http://www.vmware.com/vcloud/v1.5" name="prueba" id="urn:vcloud:catalog:ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33" type="application/vnd.vmware.vcloud.catalog+xml" href="https://example.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33" 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.org+xml" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/metadata"/>
# <Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://example.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/catalogItems"/>
# <Description>this is a description</Description>
# <CatalogItems>
# <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="sprintdemo" href="https://example.com/api/catalogItem/05211623-f94b-470e-a3ac-825d5752081c"/>
# <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="sinred" href="https://example.com/api/catalogItem/971f5364-304f-499a-a5ff-e89f629fc503"/>
# <CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="sprintdemocopy" href="https://example.com/api/catalogItem/c4173ea2-90ca-4d1e-b6a3-7d3a7a3fba86"/>
# </CatalogItems>
# <IsPublished>false</IsPublished>
#</Catalog>
module Fog
module Parsers
module Compute
module Vcloudng
class GetCatalog < VcloudngParser
def reset
@response = { 'CatalogItems' => [], 'Links' => [] }
end
def start_element(name, attributes)
super
case name
when 'CatalogItem'
catalog_item = extract_attributes(attributes)
catalog_item["id"] = catalog_item["href"].split('/').last
@response['CatalogItems'] << catalog_item
when 'Catalog'
catalog = extract_attributes(attributes)
@response['name'] = catalog['name']
@response['type'] = catalog['type']
@response['href'] = catalog['href']
@response['id'] = catalog['href'].split('/').last
when "Link"
link = extract_attributes(attributes)
@response["Links"] << link
end
end
def end_element(name)
case name
when 'Description'
@response[name] = value
when 'IsPublished'
value_boolean = value == 'false' ? false : true
@response[name] = value_boolean
end
end
end
end
end
end
end

View file

@ -1,54 +0,0 @@
#
# <?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 Compute
module Vcloudng
class GetCatalogItem < VcloudngParser
def reset
@response = { 'Entity' => {}, 'Links' => [] }
end
def start_element(name, attributes)
super
case name
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
end
end
def end_element(name)
if name == 'Description'
@response[name] = value
end
end
end
end
end
end
end

View file

@ -1,72 +0,0 @@
#
# <?xml version="1.0" encoding="UTF-8"?>
# <OrgNetwork xmlns="http://www.vmware.com/vcloud/v1.5" name="DevOps - Dev Network Connection" id="urn:vcloud:network:d5f47bbf-de27-4cf5-aaaa-56772f2ccd17" type="application/vnd.vmware.vcloud.orgNetwork+xml" href="https://example.com/api/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17" 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.org+xml" name="DevOps" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17/metadata"/>
# <Description/>
# <Configuration>
# <IpScope>
# <IsInherited>true</IsInherited>
# <Gateway>10.192.0.1</Gateway>
# <Netmask>255.255.252.0</Netmask>
# <Dns1>10.192.0.11</Dns1>
# <Dns2>10.192.0.12</Dns2>
# <DnsSuffix>dev.ad.mdsol.com</DnsSuffix>
# <IpRanges>
# <IpRange>
# <StartAddress>10.192.0.100</StartAddress>
# <EndAddress>10.192.3.254</EndAddress>
# </IpRange>
# </IpRanges>
# </IpScope>
# <FenceMode>bridged</FenceMode>
# <RetainNetInfoAcrossDeployments>false</RetainNetInfoAcrossDeployments>
# </Configuration>
# </OrgNetwork>
module Fog
module Parsers
module Compute
module Vcloudng
class GetNetwork < VcloudngParser
def reset
@response = {
"Links" => [], "IpRanges" => []
}
@ip_range = {}
end
def start_element(name,attributes=[])
super
case name
when "Link"
link = extract_attributes(attributes)
@response["Links"] << link
end
end
def end_element(name)
case name
when "Gateway", "Netmask", "Dns1", "Dns2", "DnsSuffix", "FenceMode"
@response[name] = value
when "IsInherited", "RetainNetInfoAcrossDeployments"
@response[name] = value.to_bool
when "StartAddress", "EndAddress"
@ip_range[name] = value
if @ip_range.keys.size == 2
@response["IpRanges"] << @ip_range
@ip_range = {}
end
end
end
end
end
end
end
end

View file

@ -1,131 +0,0 @@
#
#<?xml version="1.0" encoding="UTF-8"?>
#<Org xmlns="http://www.vmware.com/vcloud/v1.5" name="DevOps" id="urn:vcloud:org:c6a4c623-c158-41cf-a87a-dbc1637ad55a" type="application/vnd.vmware.vcloud.org+xml" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a" 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="down" type="application/vnd.vmware.vcloud.vdc+xml" name="DevOps - VDC" href="https://example.com/api/vdc/9a06a16b-12c6-44dc-aee1-06aa52262ea3"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.tasksList+xml" href="https://example.com/api/tasksList/c6a4c623-c158-41cf-a87a-dbc1637ad55a"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.catalog+xml" name="Public VM Templates" href="https://example.com/api/catalog/4ee720e5-173a-41ac-824b-6f4908bac975"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalog/4ee720e5-173a-41ac-824b-6f4908bac975/controlAccess/"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.catalog+xml" name="prueba" href="https://example.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/controlAccess/"/>
# <Link rel="controlAccess" type="application/vnd.vmware.vcloud.controlAccess+xml" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/action/controlAccess"/>
# <Link rel="add" type="application/vnd.vmware.admin.catalog+xml" href="https://example.com/api/admin/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalogs"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.orgNetwork+xml" name="DevOps - Dev Network Connection" href="https://example.com/api/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/metadata"/>
# <Description/>
# <FullName>DevOps</FullName>
#</Org>
#
# parsed
#
#{"OrgList"=>
# [{"type"=>"application/vnd.vmware.vcloud.org+xml",
# "name"=>"DevOps",
# "href"=>
# "https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a",
# "id"=>"c6a4c623-c158-41cf-a87a-dbc1637ad55a"}]}
#{"OrgList"=>[{"type"=>"application/vnd.vmware.vcloud.org+xml", "name"=>"DevOps", "href"=>"https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a", "id"=>"c6a4c623-c158-41cf-a87a-dbc1637ad55a"}]}
#>> pp vcloud.get_organization("c6a4c623-c158-41cf-a87a-dbc1637ad55a").body
#{"Links"=>
# [{"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.vdc+xml",
# "name"=>"DevOps - VDC",
# "href"=>
# "https://example.com/api/vdc/9a06a16b-12c6-44dc-aee1-06aa52262ea3"},
# {"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.tasksList+xml",
# "href"=>
# "https://example.com/api/tasksList/c6a4c623-c158-41cf-a87a-dbc1637ad55a"},
# {"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.catalog+xml",
# "name"=>"Public VM Templates",
# "href"=>
# "https://example.com/api/catalog/4ee720e5-173a-41ac-824b-6f4908bac975"},
# {"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.controlAccess+xml",
# "href"=>
# "https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalog/4ee720e5-173a-41ac-824b-6f4908bac975/controlAccess/"},
# {"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.catalog+xml",
# "name"=>"prueba",
# "href"=>
# "https://example.com/api/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33"},
# {"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.controlAccess+xml",
# "href"=>
# "https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/controlAccess/"},
# {"rel"=>"controlAccess",
# "type"=>"application/vnd.vmware.vcloud.controlAccess+xml",
# "href"=>
# "https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalog/ea0c6acf-c9c0-46b7-b19f-4b2d3bf8aa33/action/controlAccess"},
# {"rel"=>"add",
# "type"=>"application/vnd.vmware.admin.catalog+xml",
# "href"=>
# "https://example.com/api/admin/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/catalogs"},
# {"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.orgNetwork+xml",
# "name"=>"DevOps - Dev Network Connection",
# "href"=>
# "https://example.com/api/network/d5f47bbf-de27-4cf5-aaaa-56772f2ccd17"},
# {"rel"=>"down",
# "type"=>"application/vnd.vmware.vcloud.metadata+xml",
# "href"=>
# "https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a/metadata"}],
# "href"=>
# "https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a",
# "name"=>"DevOps",
# "Description"=>nil}
module Fog
module Parsers
module Compute
module Vcloudng
class GetOrganization < VcloudngParser
def reset
@response = { 'Links' => [] }
end
def start_element(name, attributes)
super
case name
when 'Link'
link = extract_attributes(attributes)
until attributes.empty?
if attributes.first.is_a?(Array)
attribute = attributes.shift
link[attribute.first] = attribute.last
else
link[attributes.shift] = attributes.shift
end
end
@response['Links'] << link
when 'Org'
org = extract_attributes(attributes)
until attributes.empty?
if attributes.first.is_a?(Array)
attribute = attributes.shift
org[attribute.first] = attribute.last
else
org[attributes.shift] = attributes.shift
end
end
@response['href'] = org['href']
@response['id'] = org['href'].split('/').last
@response['name'] = org['name']
end
end
def end_element(name)
if name == 'Description'
@response[name] = value
end
end
end
end
end
end
end

View file

@ -1,41 +0,0 @@
#
# <?xml version="1.0" encoding="UTF-8"?>
# <OrgList xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.orgList+xml" href="https://example.com/api/org/" 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">
# <Org type="application/vnd.vmware.vcloud.org+xml" name="DevOps" href="https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a"/>
# </OrgList>
#
# parsed:
# {"OrgList"=>
# [{"type"=>"application/vnd.vmware.vcloud.org+xml",
# "name"=>"DevOps",
# "href"=>
# "https://example.com/api/org/c6a4c623-c158-41cf-a87a-dbc1637ad55a",
# "id"=>"c6a4c623-c158-41cf-a87a-dbc1637ad55a"}]}
#
module Fog
module Parsers
module Compute
module Vcloudng
class GetOrganizations < VcloudngParser
def reset
@response = { 'OrgList' => [] }
end
def start_element(name, attributes)
super
if name == 'Org'
organization = extract_attributes(attributes)
organization['id'] = organization['href'].split('/').last
@response['OrgList'] << organization
end
end
end
end
end
end
end

View file

@ -1,68 +0,0 @@
module Fog
module Parsers
module Compute
module Vcloudng
class GetVapp < VcloudngParser
def reset
@response = { 'Links' => [], 'VirtualHardware' => {}, 'OperatingSystem' => {} }
@in_operating_system = false
@resource_type = nil
end
def start_element(name, attributes)
super
case name
when 'Link'
link = extract_attributes(attributes)
@response['Links'] << link
when 'OperatingSystemSection'
@in_operating_system = true
when 'VApp'
vapp = extract_attributes(attributes)
@response.merge!(vapp.reject {|key,value| !['href', 'name', 'size', 'status', 'type'].include?(key)})
end
end
def end_element(name)
case name
when 'IpAddress'
@response['IpAddress'] = value
when 'Description'
if @in_operating_system
@response['OperatingSystem'][name] = value
@in_operating_system = false
end
when 'ResourceType'
@resource_type = value
case value
when '3'
@get_cpu = true # cpu
when '4' # memory
@get_ram = true
when '17' # disks
@get_disks = true
end
when 'VirtualQuantity'
case @resource_type
when '3'
@response['VirtualHardware']['cpu'] = value
when '4'
@response['VirtualHardware']['ram'] = value
when '17'
@response['VirtualHardware']['disks'] ||= []
@response['VirtualHardware']['disks'] << value
end
end
end
end
end
end
end
end

View file

@ -1,308 +0,0 @@
#
# <?xml version="1.0" encoding="UTF-8"?>
# <VAppTemplate xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" ovfDescriptorUploaded="true" goldMaster="false" status="8" name="DEVWEB" id="urn:vcloud:vapptemplate:ed2b234f-c03f-460b-b877-bedd2255dfb3" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1.5 http://10.194.1.65/api/v1.5/schema/master.xsd">
# <Link rel="catalogItem" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://example.com/api/catalogItem/5b3f97f1-13bf-450e-a632-126aac3bb3d9"/>
# <Link rel="enable" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/action/enableDownload"/>
# <Link rel="disable" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/action/disableDownload"/>
# <Link rel="ovf" type="text/xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/ovf"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.owner+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/owner"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/metadata"/>
# <Description>Windows Server 2008 R2 Web Edition</Description>
# <Owner type="application/vnd.vmware.vcloud.owner+xml">
# <User type="application/vnd.vmware.admin.user+xml" name="cthayer" href="https://example.com/api/admin/user/66b8c149-15e1-42f5-b391-2d0e6573a960"/>
# </Owner>
# <Children>
# <Vm goldMaster="false" name="DEVWEB" id="urn:vcloud:vm:12af4ee1-04ad-4ae5-bab2-2d5db4296c85" type="application/vnd.vmware.vcloud.vm+xml" href="https://example.com/api/vAppTemplate/vm-12af4ee1-04ad-4ae5-bab2-2d5db4296c85">
# <Link rel="up" type="application/vnd.vmware.vcloud.vAppTemplate+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3"/>
# <Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/vAppTemplate/vm-12af4ee1-04ad-4ae5-bab2-2d5db4296c85/metadata"/>
# <Description>Windows Server 2008 R2 Web Edition</Description>
# <NetworkConnectionSection type="application/vnd.vmware.vcloud.networkConnectionSection+xml" href="https://example.com/api/vAppTemplate/vm-12af4ee1-04ad-4ae5-bab2-2d5db4296c85/networkConnectionSection/" ovf:required="false">
# <ovf:Info>Specifies the available VM network connections</ovf:Info>
# <PrimaryNetworkConnectionIndex>0</PrimaryNetworkConnectionIndex>
# <NetworkConnection network="none" needsCustomization="true">
# <NetworkConnectionIndex>0</NetworkConnectionIndex>
# <IsConnected>false</IsConnected>
# <MACAddress>00:50:56:98:77:23</MACAddress>
# <IpAddressAllocationMode>NONE</IpAddressAllocationMode>
# </NetworkConnection>
# </NetworkConnectionSection>
# <GuestCustomizationSection type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://example.com/api/vAppTemplate/vm-12af4ee1-04ad-4ae5-bab2-2d5db4296c85/guestCustomizationSection/" ovf:required="false">
# <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
# <Enabled>true</Enabled>
# <ChangeSid>false</ChangeSid>
# <VirtualMachineId>12af4ee1-04ad-4ae5-bab2-2d5db4296c85</VirtualMachineId>
# <JoinDomainEnabled>false</JoinDomainEnabled>
# <UseOrgSettings>false</UseOrgSettings>
# <AdminPasswordEnabled>false</AdminPasswordEnabled>
# <AdminPasswordAuto>true</AdminPasswordAuto>
# <ResetPasswordRequired>false</ResetPasswordRequired>
# <ComputerName>DEVWEB-001</ComputerName>
# </GuestCustomizationSection>
# <VAppScopedLocalId>DEVWEB</VAppScopedLocalId>
# </Vm>
# </Children>
# <ovf:NetworkSection xmlns:ns12="http://www.vmware.com/vcloud/v1.5" ns12:href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/networkSection/" ns12:type="application/vnd.vmware.vcloud.networkSection+xml">
# <ovf:Info>The list of logical networks</ovf:Info>
# <ovf:Network ovf:name="none">
# <ovf:Description>This is a special place-holder used for disconnected network interfaces.</ovf:Description>
# </ovf:Network>
# </ovf:NetworkSection>
# <NetworkConfigSection type="application/vnd.vmware.vcloud.networkConfigSection+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/networkConfigSection/" ovf:required="false">
# <ovf:Info>The configuration parameters for logical networks</ovf:Info>
# <NetworkConfig networkName="none">
# <Description>This is a special place-holder used for disconnected network interfaces.</Description>
# <Configuration>
# <FenceMode>isolated</FenceMode>
# </Configuration>
# <IsDeployed>false</IsDeployed>
# </NetworkConfig>
# </NetworkConfigSection>
# <LeaseSettingsSection type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/leaseSettingsSection/" ovf:required="false">
# <ovf:Info>Lease settings section</ovf:Info>
# <Link rel="edit" type="application/vnd.vmware.vcloud.leaseSettingsSection+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/leaseSettingsSection/"/>
# <StorageLeaseInSeconds>7776000</StorageLeaseInSeconds>
# <StorageLeaseExpiration>2013-09-11T15:53:20.900Z</StorageLeaseExpiration>
# </LeaseSettingsSection>
# <CustomizationSection type="application/vnd.vmware.vcloud.customizationSection+xml" href="https://example.com/api/vAppTemplate/vappTemplate-ed2b234f-c03f-460b-b877-bedd2255dfb3/customizationSection/" goldMaster="false" ovf:required="false">
# <ovf:Info>VApp template customization section</ovf:Info>
# <CustomizeOnInstantiate>true</CustomizeOnInstantiate>
# </CustomizationSection>
# </VAppTemplate>
#module Boolean; end
#class TrueClass; include Boolean; end
#class FalseClass; include Boolean; end
#
#module Fog
# module Parsers
# module Compute
# module Vcloudng
#
#
#
# class GetVappTemplate < VcloudngParser
#
#
#
# def customization_section
#
# end
#
# def lease_settings_section
#
# end
#
#
# def network_section
#
# end
#
#
# def vm
#
# end
#
# def children
# {
# 'elements' => { 'Vm' => vm }
# }
# end
#
# def link
# {
# 'attributes' => { 'rel' => String,
# 'type' => String,
# 'href' => String
# }
# }
# end
#
#
#
# def owner
# {
# 'attributes' => { 'type' => String },
# 'elements' => { 'user' => user }
# }
# end
#
# def user
# {
# 'elements' => { 'type' => String,
# 'name' => String,
# 'href' => String
# }
# }
# end
#
# def vapp_template
# {
# 'attributes' => { 'goldMaster' => Boolean,
# 'status' => Integer,
# 'name' => String,
# 'type' => String,
# 'href' => String
# },
# 'elements' => { 'Link' => link,
# 'Description' => String,
# 'Owner' => owner,
# 'Children' => children,
# 'NetworkSection' => network_section,
# 'LeaseSettingsSection' => lease_settings_section,
# 'CustomizationSection' => customization_section
# }
#
# }
# end
#
# @schema = { 'VAppTemplate' => vapp_template }
#
# def reset
# @response = { 'Links' => [], 'Children' => [] }
# @current_path = []
# end
#
# def start_element(name, attributes)
# super
# if is_an_attribute?(name)
# @last_element = name
# current = extract_attributes(attributes)
# else
# @current_path << name if @current_path.last != name
#
# end
# end
#
# def end_element(name)
# case name
# when @schema['elements'].keys?
# @schema['attributes'][name] ==
# end
# end
#
# end
#
# end
# end
# end
#end
module Fog
module Parsers
module Compute
module Vcloudng
class GetVappTemplate < VcloudngParser
def reset
@response = { 'Links' => [], 'Children' => [] }
@in_children = false
@in_network_connection_section = false
@in_guest_customization_section = false
@in_network_config = false
@vm = {}
@guest_customization_section = {}
@network_connection_section = {}
@network_connection = {}
end
def start_element(name, attributes)
super
case name
when 'Link'
link = extract_attributes(attributes)
@response['Links'] << link
when 'User'
@response['Owner'] = extract_attributes(attributes)
when 'VAppTemplate'
vapp_template = extract_attributes(attributes)
@response['name'] = vapp_template['name']
when 'Children'
@in_children = true
when 'vm'
vm_item = extract_attributes(attributes)
@vm['name'] = vm_item['name']
@vm['goldMaster'] = vm_item['goldMaster'].to_bool
@vm['href'] = vm_item['href']
@vm['id'] = vm_item['href'].split('/').last
when 'NetworkConnectionSection'
@in_network_connection_section = true
when 'NetworkConnection'
@in_network_connection = true
network_connection_items = extract_attributes(attributes)
@network_connection['network'] = network_connection_items['network']
@network_connection['needsCustomization'] = network_connection_items['needsCustomization'].to_bool
when 'NetworkConfig'
@in_network_config = true
when 'GuestCustomizationSection'
guest_customization_item = extract_attributes(attributes)
@guest_customization_section["href"] = guest_customization_item["href"]
@guest_customization_section["required"] = guest_customization_item["required"].to_bool
@guest_customization_section["type"] = guest_customization_item["type"]
@in_guest_customization_section = true
end
end
def end_element(name)
if @in_children
case name
when 'Description'
@vm['Description'] = value
when 'NetworkConnection'
@vm['NetworkConnectionSection'] ||= {}
@vm['NetworkConnectionSection']['NetworkConnection'] = @network_connection
@network_connection = {}
@in_network_connection = false
when 'NetworkConnectionSection'
@vm['NetworkConnectionSection'].merge!(@network_connection_section)
@network_connection_section = {}
@in_network_connection_section = false
when 'GuestCustomizationSection'
@vm['GuestCustomizationSection'] = @guest_customization_section
@guest_customization_section = {}
@in_guest_customization_section = false
when 'Vm'
@response['Children'] << @vm
@vm = {}
when 'Children'
@in_children = false
end
if @in_network_connection_section
case name
when 'PrimaryNetworkConnectionIndex'
@network_connection_section['PrimaryNetworkConnectionIndex'] = value.to_i
when
@network_connection['NetworkConnectionIndex'] = value.to_i
when 'IsConnected'
@network_connection['IsConnected'] = value.to_bool
when 'MACAddress', 'IpAddressAllocationMode'
@network_connection[name] = value
end
end
if @in_guest_customization_section
case name
when 'Enabled', 'ChangeSid', 'JoinDomainEnabled', 'UseOrgSettings', 'AdminPasswordEnabled', 'AdminPasswordAuto', 'ResetPasswordRequired'
@guest_customization_section[name] = value.to_bool
when 'ComputerName', 'VirtualMachineId'
@guest_customization_section[name] = value
end
end
else
case name
when 'Description'
@response['Description'] = value
end
end
end
end
end
end
end
end

View file

@ -1,94 +0,0 @@
module Fog
module Parsers
module Compute
module Vcloudng
class GetVdc < VcloudngParser
def reset
@in_storage_capacity = false
@in_cpu = false
@in_memory = false
@in_instantiated_vms_quota = false
@in_deployed_vms_quota = false
@response = {
'links' => [],
'AvailableNetworks' => [],
'ComputeCapacity' => {
'Cpu' => {},
'DeployedVmsQuota' => {},
'InstantiatedVmsQuota' => {},
'Memory' => {}
},
'StorageCapacity' => {},
'ResourceEntities' => []
}
end
def start_element(name, attributes)
super
case name
when 'Cpu'
@in_cpu = true
when 'DeployedVmsQuota'
@in_deployed_vms_quota = true
when 'InstantiatedVmsQuota'
@in_instantiated_vms_quota = true
when 'Link'
link = extract_attributes(attributes)
@response['links'] << link
when 'Memory'
@in_memory = true
when 'Network'
network = extract_attributes(attributes)
@response['AvailableNetworks'] << network
when 'ResourceEntity'
resource_entity = extract_attributes(attributes)
@response['ResourceEntities'] << resource_entity
when 'StorageCapacity'
@in_storage_capacity = true
when 'Vdc'
vdc = extract_attributes(attributes)
@response['href'] = vdc['href']
@response['id'] = vdc['href'].split('/').last
@response['name'] = vdc['name']
@response['type'] = vdc['type']
end
end
def end_element(name)
case name
when 'Allocated', 'Limit', 'Units', 'Used'
if @in_cpu
@response['ComputeCapacity']['Cpu'][name] = value
elsif @in_deployed_vms_quota
@response['ComputeCapacity']['DeployedVmsQuota'][name] = value
elsif @in_instantiated_vms_quota
@response['ComputeCapacity']['InstantiatedVmsQuota'][name] = value
elsif @in_memory
@response['ComputeCapacity']['Memory'][name] = value
elsif @in_storage_capacity
@response['StorageCapacity'][name] = value
end
when 'Cpu'
@in_cpu = false
when 'DeployedVmsQuota'
@in_deployed_vms_quota = false
when 'InstantiatedVmsQuota'
@in_instantiated_vms_quota = false
when 'Memory'
@in_memory = false
when 'StorageCapacity'
@in_storage_capacity = false
when 'Type'
@response[name] = value
end
end
end
end
end
end
end