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 Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from VcloudDirectorParser

#extract_attributes

Methods inherited from Base

#attr_value, #characters, #end_element_namespace, #initialize, #start_element_namespace, #value

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



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

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



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

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

#start_element(name, attributes) ⇒ Object



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

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