Module: Fog::Parsers::Compute::VcloudDirector::VmParserHelper

Included in:
Vm, Vms
Defined in:
lib/fog/vcloud_director/parsers/compute/vm_parser_helper.rb

Instance Method Summary collapse

Instance Method Details

#parse_end_element(name, vm) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/vcloud_director/parsers/compute/vm_parser_helper.rb', line 7

def parse_end_element(name, vm)
  case name
  when 'IpAddress'
    vm[:ip_address] = value
  when 'Description'
    if @in_operating_system
      vm[:operating_system] = value
      @in_operating_system = false
    end
  when 'ResourceType'
    @resource_type = value
  when 'VirtualQuantity'
    case @resource_type
    when '3'
      vm[:cpu] = value
    when '4'
      vm[:memory] = value
    end
  when 'ElementName'
    @element_name = value
  when 'Item'
    if @resource_type == '17' # disk
      vm[:disks] ||= []
      vm[:disks] << { @element_name => @current_host_resource[:capacity].to_i }
    end
  when 'Connection'
    vm[:network_adapters] ||= []
    vm[:network_adapters] << {
      :ip_address => @current_network_connection[:ipAddress],
      :primary => (@current_network_connection[:primaryNetworkConnection] == 'true'),
      :ip_allocation_mode => @current_network_connection[:ipAddressingMode],
      :network => value
    }
  when 'Link'
    vm[:links] = @links
  end
end

#parse_start_element(name, attributes, vm) ⇒ Object



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

def parse_start_element(name, attributes, vm)
  case name
  when 'OperatingSystemSection'
    @in_operating_system = true
  when 'HostResource'
    @current_host_resource = extract_attributes(attributes)
  when 'Connection'
    @current_network_connection = extract_attributes(attributes)
  when 'Link'
    @links << extract_attributes(attributes)
  end
end