Class: Fog::Parsers::Compute::VcloudDirector::VmNetwork

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

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



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/fog/vcloud_director/parsers/compute/vm_network.rb', line 87

def end_element(name)
  case name
  when 'Info'
    @response[:info] = value
  when 'PrimaryNetworkConnectionIndex'
    @response[:primary_network_connection_index] = value.to_i
  when 'NetworkConnectionIndex'
    @response[:network_connection_index] = value.to_i
  when 'IpAddress'
    @response[:ip_address] = value
  when 'IsConnected'
    @response[:is_connected] = (value == "true")
  when 'MACAddress'
    @response[:mac_address] = value
  when 'IpAddressAllocationMode'
    @response[:ip_address_allocation_mode] = value
  end
end

#resetObject



68
69
70
# File 'lib/fog/vcloud_director/parsers/compute/vm_network.rb', line 68

def reset
  @response = { }
end

#start_element(name, attributes) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fog/vcloud_director/parsers/compute/vm_network.rb', line 72

def start_element(name, attributes)
  super
  case name
  when 'NetworkConnectionSection'
    network_connection_section = extract_attributes(attributes)
    @response[:type] = network_connection_section[:type]
    @response[:href] = network_connection_section[:href]
    @response[:id] = @response[:href].split('/')[-2]
  when 'NetworkConnection'
    network_connection = extract_attributes(attributes)
    @response[:network] = network_connection[:network]
    @response[:needs_customization] = ( network_connection[:needsCustomization] == "true" )
  end
end