2010-12-12 18:02:02 -05:00
|
|
|
module Fog
|
2011-06-15 20:25:01 -04:00
|
|
|
module DNS
|
|
|
|
class Zerigo
|
2010-12-12 18:02:02 -05:00
|
|
|
class Real
|
|
|
|
|
2011-08-24 15:40:47 -04:00
|
|
|
require 'fog/zerigo/parsers/dns/find_hosts'
|
2010-12-12 18:02:02 -05:00
|
|
|
|
2010-12-12 21:18:21 -05:00
|
|
|
# Get list of all the host records that match the FQDN. If desired, can limit
|
|
|
|
# search to a specific zone
|
2010-12-12 18:02:02 -05:00
|
|
|
#
|
2010-12-12 21:18:21 -05:00
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * fqdn<~String> - domain to look for
|
|
|
|
# * zone_id<~Integer> - if want to limit search to specific zone
|
2010-12-12 18:02:02 -05:00
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
2010-12-12 21:18:21 -05:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'hosts'<~Hash>
|
|
|
|
# * 'created-at'<~String>
|
|
|
|
# * 'data'<~String>
|
|
|
|
# * 'fqdn'<~String>
|
|
|
|
# * 'host-type'<~String>
|
|
|
|
# * 'hostname'<~String>
|
|
|
|
# * 'id'<~Integer>
|
|
|
|
# * 'notes'<~String>
|
|
|
|
# * 'priority'<~Integer>
|
|
|
|
# * 'ttl'<~Integer>
|
|
|
|
# * 'updated-at'<~String>
|
|
|
|
# * 'zone-id'<~String>
|
2010-12-13 08:51:04 -05:00
|
|
|
# * 'status'<~Integer> - 200 indicated success
|
|
|
|
#
|
2010-12-12 18:02:02 -05:00
|
|
|
def find_hosts( fqdn, zone_id = nil)
|
|
|
|
if zone_id.nil?
|
|
|
|
#look for matching host across all zones
|
|
|
|
request(
|
|
|
|
:expects => 200,
|
|
|
|
:method => 'GET',
|
2011-06-15 20:25:01 -04:00
|
|
|
:parser => Fog::Parsers::DNS::Zerigo::FindHosts.new,
|
2010-12-12 21:18:21 -05:00
|
|
|
:path => "/api/1.1/hosts.xml?fqdn=#{fqdn}"
|
2010-12-12 18:02:02 -05:00
|
|
|
)
|
|
|
|
else
|
|
|
|
#look for hosts in a specific zone
|
|
|
|
request(
|
|
|
|
:expects => 200,
|
|
|
|
:method => 'GET',
|
2011-06-15 20:25:01 -04:00
|
|
|
:parser => Fog::Parsers::DNS::Zerigo::FindHosts.new,
|
2010-12-12 21:18:21 -05:00
|
|
|
:path => "/api/1.1/zones/#{zone_id}/hosts.xml?fqdn=#{fqdn}"
|
2010-12-12 18:02:02 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|