Class: Fog::Parsers::Compute::VcloudDirector::Disks

Inherits:
VcloudDirectorParser show all
Defined in:
lib/fog/vcloud_director/parsers/compute/disks.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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/vcloud_director/parsers/compute/disks.rb', line 22

def end_element(name)
  case name
  when 'Address'
    @disk[:address] = value.to_i
  when 'AddressOnParent'
    @disk[:address_on_parent] = value.to_i
  when 'Description'
    @disk[:description] = value
  when 'ElementName'
    @disk[:name] = value
  when 'InstanceID'
    @disk[:id] = value.to_i
  when 'ResourceSubType'
    @disk[:resource_sub_type] = value
  when 'Parent'
    @disk[:parent] = value.to_i
  when 'ResourceType'
    @disk[:resource_type] = value.to_i
  when 'Item'
    if @host_resource
      @disk[:capacity] = @host_resource[:capacity].to_i
      @disk[:bus_sub_type] = @host_resource[:busSubType]
      @disk[:bus_type] = @host_resource[:busType].to_i
    end
    @response[:disks] << @disk
    @host_resource = nil
    @disk = {}
  end
end

#resetObject



8
9
10
11
12
# File 'lib/fog/vcloud_director/parsers/compute/disks.rb', line 8

def reset
  @disk = {}
  @response = { :disks => [] }
  @host_resource = nil
end

#start_element(name, attributes) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/parsers/compute/disks.rb', line 14

def start_element(name, attributes)
  super
  case name
  when 'HostResource'
    @host_resource = extract_attributes(attributes)
  end
end