Class: Fog::Generators::Compute::VcloudDirector::VmNetwork

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ VmNetwork

Returns a new instance of VmNetwork.



41
42
43
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 41

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

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



39
40
41
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 39

def attrs
  @attrs
end

Instance Method Details

#body(opts = {}) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 97

def body(opts={})
  body = <<EOF
  <ovf:Info>#{opts[:info]}</ovf:Info>
       <PrimaryNetworkConnectionIndex>#{opts[:primary_network_connection_index]}</PrimaryNetworkConnectionIndex>
       <NetworkConnection
           network="#{opts[:network]}"
           needsCustomization="#{opts[:needs_customization]}">
           <NetworkConnectionIndex>#{opts[:network_connection_index]}</NetworkConnectionIndex>
           <IpAddress>#{opts[:ip_address]}</IpAddress>
           <IsConnected>#{opts[:is_connected]}</IsConnected>
           <MACAddress>#{opts[:mac_address]}</MACAddress>
           <IpAddressAllocationMode>#{opts[:ip_address_allocation_mode]}</IpAddressAllocationMode>
       </NetworkConnection>
EOF
end

#generate_xmlObject



45
46
47
48
49
50
51
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 45

def generate_xml
  output = ""
  output << header
  output << body(@attrs)
  output << tail
  output
end

#headerObject



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 85

def header
    '<NetworkConnectionSection xmlns="http://www.vmware.com/vcloud/v1.5"
       xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
       type="application/vnd.vmware.vcloud.networkConnectionSection+xml"
       ovf:required="false"
       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">'

end

#ip_addressObject



61
62
63
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 61

def ip_address
  @attrs[:ip_address]
end

#ip_address=(new_ip_address) ⇒ Object



65
66
67
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 65

def ip_address=(new_ip_address)
  @attrs[:ip_address] = new_ip_address
end

#ip_address_allocation_modeObject



77
78
79
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 77

def ip_address_allocation_mode
  @attrs[:ip_address_allocation_mode]
end

#ip_address_allocation_mode=(new_ip_address_allocation_mode) ⇒ Object



81
82
83
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 81

def ip_address_allocation_mode=(new_ip_address_allocation_mode)
  @attrs[:ip_address_allocation_mode] = new_ip_address_allocation_mode
end

#is_connectedObject



69
70
71
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 69

def is_connected
  @attrs[:is_connected]
end

#is_connected=(new_is_connected) ⇒ Object



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

def is_connected=(new_is_connected)
  @attrs[:is_connected] = new_is_connected
end

#networkObject



53
54
55
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 53

def network
  @attrs[:network]
end

#network=(new_network_name) ⇒ Object



57
58
59
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 57

def network=(new_network_name)
  @attrs[:network] = new_network_name
end

#tailObject



113
114
115
# File 'lib/fog/vcloud_director/generators/compute/vm_network.rb', line 113

def tail
  '</NetworkConnectionSection>'
end