Class: Fog::Parsers::TerremarkEcloud::Compute::GetVdc
- Inherits:
-
Base
- Object
- Nokogiri::XML::SAX::Document
- Base
- Fog::Parsers::TerremarkEcloud::Compute::GetVdc
show all
- Defined in:
- lib/fog/compute/parsers/terremark_ecloud/get_vdc.rb
Instance Attribute Summary
Attributes inherited from Base
#response
Instance Method Summary
collapse
Methods inherited from Base
#attr_value, #characters, #initialize
Instance Method Details
#end_element(name) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/fog/compute/parsers/terremark_ecloud/get_vdc.rb', line 69
def end_element(name)
case name
when 'Description'
@response[name] = @value
when 'Allocated', 'Limit', 'Used'
if @in_cpu
@response['ComputeCapacity']['Cpu'][name] = @value.to_i
elsif @in_deployed_vms_quota
@response['ComputeCapacity']['DeployedVmsQuota'][name] = @value.to_i
elsif @in_instantiated_vms_quota
@response['ComputeCapacity']['InstantiatedVmsQuota'][name] = @value.to_i
elsif @in_memory
@response['ComputeCapacity']['Memory'][name] = @value.to_i
elsif @in_storage_capacity
@response['StorageCapacity'][name] = @value.to_i
end
when 'Cpu'
@in_cpu = false
when 'DeployedVmsQuota'
@in_deployed_vms_quota = false
when 'InstantiatedVmsQuota'
@in_instantiated_vms_quota = false
when 'Memory'
@in_memory = false
when 'StorageCapacity'
@in_storage_capacity = false
when 'Units'
if @in_storage_capacity
@response['StorageCapacity'][name] = @value
elsif @in_cpu
@response['ComputeCapacity']['Cpu'][name] = @value
elsif @in_memory
@response['ComputeCapacity']['Memory'][name] = @value
end
end
end
|
#reset ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/fog/compute/parsers/terremark_ecloud/get_vdc.rb', line 8
def reset
@response = {
'AvailableNetworks' => [],
'ComputeCapacity' => {
'Cpu' => {},
'DeployedVmsQuota' => {},
'InstantiatedVmsQuota' => {},
'Memory' => {}
},
'Link' => [],
'ResourceEntities' => [],
'StorageCapacity' => {}
}
end
|
#start_element(name, attrs = []) ⇒ Object
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/fog/compute/parsers/terremark_ecloud/get_vdc.rb', line 23
def start_element(name, attrs = [])
case name
when 'Cpu'
@in_cpu = true
when 'DeployedVmsQuota'
@in_deployed_vms_quota = true
when 'InstantiatedVmsQuota'
@in_instantiated_vms_quota = true
when 'Link'
link = {}
for attribute in %w{href name rel type}
if value = attr_value(attribute, attrs)
link[attribute] = value
end
end
@response['Link'] << link
when 'Memory'
@in_memory = true
when 'Network'
network = {}
for attribute in %w{href name type}
if value = attr_value(attribute, attrs)
network[attribute] = value
end
end
@response['AvailableNetworks'] << network
when 'StorageCapacity'
@in_storage_capacity = true
when 'ResourceEntity'
resource_entity = {}
for attribute in %w{href name type}
if value = attr_value(attribute, attrs)
resource_entity[attribute] = value
end
end
@response['ResourceEntities'] << resource_entity
when 'Vdc'
for attribute in %w{href name}
if value = attr_value(attribute, attrs)
@response[attribute] = value
end
end
end
super
end
|