Class: Fog::Generators::Compute::VcloudDirector::MetadataBase

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/vcloud_director/generators/compute/metadata.rb

Overview

{"buenas 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"}

This is what it generates:

<Metadata xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.metadata+xml"  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">
  <MetadataEntry>
    <Key>buenas si</Key>
    <Value>no tanto ya</Value>
  </MetadataEntry>
  <MetadataEntry">
    <Key>hola</Key>
    <Value>adios</Value>
  </MetadataEntry>
</Metadata>

Direct Known Subclasses

MetadataV15, MetadataV51

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ MetadataBase

Returns a new instance of MetadataBase.



30
31
32
# File 'lib/fog/vcloud_director/generators/compute/metadata.rb', line 30

def initialize(attrs={})
  @attrs = attrs
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



28
29
30
# File 'lib/fog/vcloud_director/generators/compute/metadata.rb', line 28

def attrs
  @attrs
end

Instance Method Details

#add_item(k, v) ⇒ Object



44
45
46
# File 'lib/fog/vcloud_director/generators/compute/metadata.rb', line 44

def add_item(k,v)
  @attrs[:metadata].merge!(Hash[k,v])
end

#generate_xmlObject



34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/generators/compute/metadata.rb', line 34

def generate_xml
  output = ""
  output << header
  attrs[:metadata].each_pair do |k,v|
    output << (k,v)
  end
  output << tail
  output
end

#headerObject

1.5



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

def header
  <<-END
  <Metadata
    xmlns="http://www.vmware.com/vcloud/v1.5"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    type="application/vnd.vmware.vcloud.metadata+xml">
  END
end

#metadata_entryObject



58
59
60
# File 'lib/fog/vcloud_director/generators/compute/metadata.rb', line 58

def 
  raise "This is an abstract class. Use the appropriate subclass"
end

#tailObject

5.1 def header

'<Metadata xmlns="http://www.vmware.com/vcloud/v1.5"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  type="application/vnd.vmware.vcloud.metadata+xml"
  href="https://devlab.mdsol.com/api/vApp/vm-345c3619-edcd-4a8c-a8b9-c69ace3f89d1/metadata"
  xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.194.1.65/api/v1.5/schema/master.xsd">'

end



71
72
73
74
75
# File 'lib/fog/vcloud_director/generators/compute/metadata.rb', line 71

def tail
  <<-END
  </Metadata>
  END
end