2010-12-12 09:51:52 -05:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
module Zerigo
|
2010-12-12 09:51:52 -05:00
|
|
|
|
|
|
|
class GetZone < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@host = {}
|
2010-12-13 07:38:06 -05:00
|
|
|
@hosts = []
|
2010-12-12 09:51:52 -05:00
|
|
|
@response = {}
|
|
|
|
@in_hosts = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
|
|
|
super(name, attrs)
|
|
|
|
#look out for start of <hosts> section
|
|
|
|
#needed as some of the tags have the same name as the parent <zone> section
|
|
|
|
if name == 'hosts'
|
|
|
|
@in_hosts= true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
if (@in_hosts)
|
|
|
|
#in hosts part of response
|
|
|
|
case name
|
2012-02-10 11:21:34 -05:00
|
|
|
when 'id', 'zone-id'
|
2011-05-12 16:15:13 -04:00
|
|
|
@host[name] = value.to_i
|
2012-02-10 11:21:34 -05:00
|
|
|
when 'priority', 'ttl'
|
|
|
|
@host[name] = value.to_i if value
|
2010-12-12 18:02:02 -05:00
|
|
|
when 'data', 'fqdn', 'host-type', 'hostname', 'notes', 'zone-id', 'created-at', 'updated-at'
|
2011-05-12 16:15:13 -04:00
|
|
|
@host[name] = value
|
2010-12-12 09:51:52 -05:00
|
|
|
when 'host'
|
|
|
|
@hosts << @host
|
|
|
|
@host = {}
|
|
|
|
when 'hosts'
|
2010-12-13 07:38:06 -05:00
|
|
|
@response[name] = @hosts
|
2010-12-12 09:51:52 -05:00
|
|
|
@in_hosts = false
|
|
|
|
end
|
|
|
|
else
|
|
|
|
#in zone part of data
|
|
|
|
case name
|
2010-12-12 18:02:02 -05:00
|
|
|
when 'default-ttl', 'id', 'nx-ttl', 'hosts-count'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value.to_i
|
2010-12-12 18:02:02 -05:00
|
|
|
when 'created-at', 'custom-nameservers', 'custom-ns', 'domain', 'hostmaster', 'notes', 'ns1', 'ns-type', 'slave-nameservers', 'tag-list', 'updated-at', 'hosts', 'axfr-ips', 'restrict-axfr'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-12-12 09:51:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|