2010-04-16 03:20:02 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module Terremark
|
|
|
|
module Shared
|
2013-02-12 07:52:46 -05:00
|
|
|
class InternetService < TerremarkParser
|
2010-04-16 03:20:02 -04:00
|
|
|
def reset
|
|
|
|
@in_public_ip_address = false
|
|
|
|
@response = { 'PublicIpAddress' => {} }
|
|
|
|
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
|
|
|
|
when 'Href'
|
2013-02-12 07:52:46 -05:00
|
|
|
data = extract_attributes(attributes)
|
2010-04-16 03:20:02 -04:00
|
|
|
if @in_public_ip_address
|
|
|
|
@response['PublicIpAddress'][name] = data
|
|
|
|
else
|
|
|
|
@response[name] = data
|
|
|
|
end
|
|
|
|
when 'PublicIpAddress'
|
|
|
|
@in_public_ip_address = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
|
|
|
when 'Description', 'Protocol'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
when 'Enabled'
|
2011-05-12 16:15:13 -04:00
|
|
|
if value == 'false'
|
2010-04-16 03:20:02 -04:00
|
|
|
@response[name] = false
|
|
|
|
else
|
|
|
|
@response[name] = true
|
|
|
|
end
|
|
|
|
when 'Id'
|
|
|
|
if @in_public_ip_address
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['PublicIpAddress'][name] = value.to_i
|
2010-04-16 03:20:02 -04:00
|
|
|
else
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value.to_i
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
|
|
|
when 'Name'
|
|
|
|
if @in_public_ip_address
|
2011-05-12 16:15:13 -04:00
|
|
|
@response['PublicIpAddress'][name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
else
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-04-16 03:20:02 -04:00
|
|
|
end
|
|
|
|
when 'Port', 'Timeout'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value.to_i
|
2010-04-16 03:20:02 -04:00
|
|
|
when 'PublicIpAddress'
|
|
|
|
@in_public_ip_address = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|