Class: Fog::Parsers::Vcloud::Terremark::Ecloud::GetVdc

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb

Instance Attribute Summary

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

#characters, #initialize

Constructor Details

This class inherits a constructor from Fog::Parsers::Base

Instance Method Details

#end_element(name) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb', line 40

def end_element(name)
  case name
  when 'Allocated', 'Limit', 'Used'
    @response[@target][name.downcase] = @value.to_i
  when 'Units'
    @response[@target][name.downcase] = @value
  when 'Cpu', 'DeployedVmsQuota', 'InstantiatedVmsQuota', 'Memory', 'StorageCapacity'
    @target = nil
  when 'Description'
    @response.description = @value
  end
end

#resetObject



9
10
11
12
13
14
# File 'lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb', line 9

def reset
  @target = nil
  @response = Struct::TmrkEcloudVdc.new([],[],[],Struct::VcloudXCapacity.new,Struct::VcloudXCapacity.new,
                                                 Struct::VcloudXCapacity.new,Struct::VcloudXCapacity.new,
                                                 Struct::VcloudXCapacity.new)
end

#start_element(name, attributes) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb', line 16

def start_element(name, attributes)
  @value = ''
  case name
  when 'Cpu'
    @target = :cpu_capacity
  when 'DeployedVmsQuota'
    @target = :deployed_vm_quota
  when 'InstantiatedVmsQuota'
    @target = :instantiated_vm_quota
  when 'Memory'
    @target = :memory_capacity
  when 'StorageCapacity'
    @target = :storage_capacity
  when 'Link'
    @response.links << generate_link(attributes)
  when 'Network'
    @response.networks << generate_link(attributes)
  when 'ResourceEntity'
    @response.resource_entities << generate_link(attributes)
  when 'Vdc'
    handle_root(attributes)
  end
end