2010-04-16 03:20:02 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module Terremark
|
|
|
|
module Shared
|
|
|
|
|
|
|
|
class GetInternetServices < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@in_public_ip_address = false
|
|
|
|
@internet_service = {}
|
|
|
|
@response = { 'InternetServices' => [] }
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attributes)
|
2010-05-05 16:39:41 -04:00
|
|
|
super
|
2010-04-16 03:20:02 -04:00
|
|
|
case name
|
2010-05-06 11:30:07 -04:00
|
|
|
when 'PublicIpAddress'
|
2010-04-16 03:20:02 -04:00
|
|
|
@in_public_ip_address = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
|
|
|
when 'Description', 'Protocol'
|
2011-05-12 16:15:13 -04:00
|
|
|
@internet_service[name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
when 'Enabled'
|
2011-05-12 16:15:13 -04:00
|
|
|
if value == 'true'
|
2010-04-16 03:20:02 -04:00
|
|
|
@internet_service[name] = true
|
|
|
|
else
|
|
|
|
@internet_service[name] = false
|
|
|
|
end
|
|
|
|
when 'Href', 'Name'
|
|
|
|
if @in_public_ip_address
|
|
|
|
@internet_service['PublicIpAddress'] ||= {}
|
2011-05-12 16:15:13 -04:00
|
|
|
@internet_service['PublicIpAddress'][name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
else
|
2011-05-12 16:15:13 -04:00
|
|
|
@internet_service[name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
|
|
|
when 'Id'
|
|
|
|
if @in_public_ip_address
|
|
|
|
@internet_service['PublicIpAddress'] ||= {}
|
2011-05-12 16:15:13 -04:00
|
|
|
@internet_service['PublicIpAddress'][name] = value.to_i
|
2010-04-16 03:20:02 -04:00
|
|
|
else
|
2011-05-12 16:15:13 -04:00
|
|
|
@internet_service[name] = value.to_i
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
|
|
|
when 'InternetService'
|
|
|
|
@response['InternetServices'] << @internet_service
|
|
|
|
@internet_service = {}
|
|
|
|
when 'Port', 'Timeout'
|
2011-05-12 16:15:13 -04:00
|
|
|
@internet_service[name] = value.to_i
|
2010-05-06 11:30:07 -04:00
|
|
|
when 'PublicIpAddress'
|
2010-04-16 03:20:02 -04:00
|
|
|
@in_public_ip_address = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|