Class: Fog::Parsers::Compute::VcloudDirector::Metadata

Inherits:
VcloudDirectorParser show all
Defined in:
lib/fog/vcloud_director/parsers/compute/metadata.rb

Overview

<Metadata xmlns=“www.vmware.com/vcloud/v1.5” type=“application/vnd.vmware.vcloud.metadata+xml” href=“example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata” xmlns:xsi=“www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“www.vmware.com/vcloud/v1.5 10.194.1.65/api/v1.5/schema/master.xsd”>

<Link rel="up" type="application/vnd.vmware.vcloud.vm+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112"/>
<Link rel="add" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata"/>
<MetadataEntry type="application/vnd.vmware.vcloud.metadata.value+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata/buenas%20si">
    <Link rel="up" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata"/>
    <Link rel="edit" type="application/vnd.vmware.vcloud.metadata.value+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata/buenas%20si"/>
    <Link rel="remove" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata/buenas%20si"/>
    <Key>buenas si</Key>
    <Value>no tanto ya</Value>
</MetadataEntry>
<MetadataEntry type="application/vnd.vmware.vcloud.metadata.value+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata/hola">
    <Link rel="up" type="application/vnd.vmware.vcloud.metadata+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata"/>
    <Link rel="edit" type="application/vnd.vmware.vcloud.metadata.value+xml" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata/hola"/>
    <Link rel="remove" href="https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata/hola"/>
    <Key>hola</Key>
    <Value>adios</Value>
</MetadataEntry>

</Metadata>

si”=>“no tanto ya”, “hola”=>“adios”,

:type=>"application/vnd.vmware.vcloud.metadata+xml",
:href=>
 "https://example.com/api/vApp/vm-18545e82-d919-4071-ae7e-d1300d9d8112/metadata",
:id=>"vm-18545e82-d919-4071-ae7e-d1300d9d8112"}

Instance Method Summary collapse

Methods inherited from VcloudDirectorParser

#extract_attributes

Instance Method Details

#end_element(name) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/vcloud_director/parsers/compute/metadata.rb', line 47

def end_element(name)
  case name
  when 'Key'
    @key = value
  when 'Value'
    @val = value
  when 'MetadataEntry'
    @response[:metadata].merge!(Hash[@key, @val])
  end
end

#resetObject



32
33
34
# File 'lib/fog/vcloud_director/parsers/compute/metadata.rb', line 32

def reset
  @response = { :metadata => {} }
end

#start_element(name, attributes) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/vcloud_director/parsers/compute/metadata.rb', line 36

def start_element(name, attributes)
  super
  case name
  when 'Metadata'
     = extract_attributes(attributes)
    @response[:type] = [:type]
    @response[:href] = [:href]
    @response[:id] = @response[:href].split('/')[-2]
  end
end