mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fix missing record data in dynect dns
currently, when fog requests all records: * make a NodeList request returns a list of nodes (domains) * for each domain, make a secondary AnyRecord request for each domain returns a list of records (without data) The resulting Record objects do not contain the data of where the record points (address or cname). 'rdata' is nil I've changed the process to be: * make an AllRecord request returns a list of records (without data) * make a secondary request to *Record (using the type returned from the AllRecord request) this returns a *complete* record object (including data) The number of requests to Dynect API is the same, but the resulting objects contain all of the information. TODO: * Please help me integrate with fog testing * I had to remove (comment) the API Version header, not sure what the correct value for this is ** Dynect documentation is a bit difficult to work through
This commit is contained in:
parent
bf4c376256
commit
caabdff6d4
3 changed files with 25 additions and 17 deletions
|
@ -18,7 +18,7 @@ module Fog
|
|||
request_path 'fog/dynect/requests/dns'
|
||||
request :delete_record
|
||||
request :delete_zone
|
||||
request :get_node_list
|
||||
request :get_all_records
|
||||
request :get_record
|
||||
request :get_zone
|
||||
request :post_record
|
||||
|
@ -85,7 +85,7 @@ module Fog
|
|||
|
||||
params[:headers] ||= {}
|
||||
params[:headers]['Content-Type'] = 'application/json'
|
||||
params[:headers]['API-Version'] = @version
|
||||
#params[:headers]['API-Version'] = @version
|
||||
params[:headers]['Auth-Token'] = auth_token unless params[:path] == 'Session'
|
||||
params[:path] = "#{@path}/#{params[:path]}" unless params[:path] =~ %r{^#{Regexp.escape(@path)}/}
|
||||
|
||||
|
|
|
@ -14,20 +14,28 @@ module Fog
|
|||
def all(options = {})
|
||||
requires :zone
|
||||
data = []
|
||||
service.get_node_list(zone.domain, options).body['data'].each do |fqdn|
|
||||
records = service.get_record('ANY', zone.domain, fqdn).body['data']
|
||||
service.get_all_records(zone.domain, options).body['data'].each do |url|
|
||||
(_, r, t, z, fqdn, id) = url.split('/')
|
||||
type = t.gsub(/Record$/, '')
|
||||
record = service.get_record(type, zone.domain, fqdn, 'record_id' => id).body['data']
|
||||
|
||||
# data in format ['/REST/xRecord/domain/fqdn/identity]
|
||||
records.map! do |record|
|
||||
tokens = record.split('/')
|
||||
{
|
||||
:identity => tokens.last,
|
||||
:fqdn => fqdn,
|
||||
:type => tokens[2][0...-6] # everything before 'Record'
|
||||
}
|
||||
end
|
||||
|
||||
data.concat(records)
|
||||
#records.map! do |record|
|
||||
# tokens = record.split('/')
|
||||
# {
|
||||
# :identity => tokens.last,
|
||||
# :fqdn => fqdn,
|
||||
# :type => tokens[2][0...-6] # everything before 'Record'
|
||||
# }
|
||||
#end
|
||||
#
|
||||
#data.concat(records)
|
||||
data << {
|
||||
:identity => record['record_id'],
|
||||
:fqdn => record['fqdn'],
|
||||
:type => record['record_type'],
|
||||
:rdata => record['rdata']
|
||||
}
|
||||
end
|
||||
|
||||
# leave out the default, read only records
|
||||
|
|
|
@ -10,19 +10,19 @@ module Fog
|
|||
# * options<~Hash>
|
||||
# * fqdn<~String> - fully qualified domain name of node to lookup
|
||||
|
||||
def get_node_list(zone, options = {})
|
||||
def get_all_records(zone, options = {})
|
||||
requested_fqdn = options['fqdn'] || options[:fqdn]
|
||||
request(
|
||||
:expects => 200,
|
||||
:idempotent => true,
|
||||
:method => :get,
|
||||
:path => ['NodeList', zone, requested_fqdn].compact.join('/')
|
||||
:path => ['AllRecord', zone, requested_fqdn].compact.join('/')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def get_node_list(zone, options = {})
|
||||
def get_all_records(zone, options = {})
|
||||
raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
|
||||
|
||||
response = Excon::Response.new
|
Loading…
Add table
Reference in a new issue