1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/terremark/parsers/shared/get_vdc.rb
Edward Muller 7514c996cb Terremark::Shared
minimal support for TMRK eCloud.
Fixed a small issue with ComputeCapacity not working.

WIP: re-factor Ecloud/Vcloud into seperate modules. Add a shared module for anything shared. Putting everything in there for now. Will review vCloud vs. eCloud once this is done.

WIP ... Terremark::Shared

typo

re-lock

forgot to include parser

WIP shared

not sure how I lost Parsers

note that terremark said they're going to remove this in the future

minimal support for TMRK eCloud.
Fixed a small issue with ComputeCapacity not working.

WIP: re-factor Ecloud/Vcloud into seperate modules. Add a shared module for anything shared. Putting everything in there for now. Will review vCloud vs. eCloud once this is done.

WIP ... Terremark::Shared

typo

re-lock

oops

forgot to include parser

WIP shared

ecloud requires a vdc_id

relocked and got a newer net-ssh

ecloud requires a different path

addresses collection for Terremark

ecloud requires a vdc_id

missed the actual models

[terremark]: get_network request and assocaited parser

cut-n-paste error

[terremark] Network/Networks models

[terremark] don't really need these

cleanup
2010-04-24 12:15:47 -07:00

108 lines
3.4 KiB
Ruby

module Fog
module Parsers
module Terremark
module Shared
class GetVdc < Fog::Parsers::Base
def reset
@in_storage_capacity = false
@in_cpu = false
@in_memory = false
@in_instantiated_vms_quota = false
@in_deployed_vms_quota = false
@response = {
'links' => [],
'AvailableNetworks' => [],
'ComputeCapacity' => {
'Cpu' => {},
'DeployedVmsQuota' => {},
'InstantiatedVmsQuota' => {},
'Memory' => {}
},
'StorageCapacity' => {},
'ResourceEntities' => []
}
end
def start_element(name, attributes)
@value = ''
case name
when 'Cpu'
@in_cpu = true
when 'DeployedVmsQuota'
@in_deployed_vms_quota = true
when 'InstantiatedVmsQuota'
@in_instantiated_vms_quota = true
when 'Link'
link = {}
until attributes.empty?
link[attributes.shift] = attributes.shift
end
@response['links'] << link
when 'Memory'
@in_memory = true
when 'Network'
network = {}
until attributes.empty?
network[attributes.shift] = attributes.shift
end
@response['AvailableNetworks'] << network
when 'ResourceEntity'
resource_entity = {}
until attributes.empty?
resource_entity[attributes.shift] = attributes.shift
end
@response['ResourceEntities'] << resource_entity
when 'StorageCapacity'
@in_storage_capacity = true
when 'Vdc'
vdc = {}
until attributes.empty?
if attributes.first.is_a?(Array)
attribute = attributes.shift
vdc[attribute.first] = attribute.last
else
vdc[attributes.shift] = attributes.shift
end
end
@response['href'] = vdc['href']
@response['name'] = vdc['name']
end
end
def end_element(name)
case name
when 'Allocated', 'Limit', 'Units', 'Used'
if @in_cpu
@response['ComputeCapacity']['Cpu'][name] = @value
elsif @in_deployed_vms_quota
@response['ComputeCapacity']['DeployedVmsQuota'][name] = @value
elsif @in_instantiated_vms_quota
@response['ComputeCapacity']['InstantiatedVmsQuota'][name] = @value
elsif @in_memory
@response['ComputeCapacity']['Memory'][name] = @value
elsif @in_storage_capacity
@response['StorageCapacity'][name] = @value
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 'Type'
@response[name] = @value
end
end
end
end
end
end
end