class Dns::CatalogZone::Provider::Nsd

Public Instance Methods

make(catalog_zone) click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 29
def make(catalog_zone)
  @output = ''
  global_config(catalog_zone)
  zones_config(catalog_zone)
end
reconfig() click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 34
def reconfig
  system("#{control} reconfig")
end

Private Instance Methods

control() click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 39
def control
  @setting['control'] || "nsd-control"
end
global_config(catalog_zone) click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 43
def global_config(catalog_zone)
  output "pattern:\n"
  output "\tname: \"CatalogZone\"\n"
  catalog_zone.masters.each_pair do |label, master|
    output output_master(master, "#{label}.masters")
  end
  catalog_zone.notifies.each_pair do |label, notify|
    output output_notify(notify, "#{label}.notifies")
  end
  catalog_zone.allow_transfers.each_pair do |_label, prefixes|
    output output_prefixes(prefixes)
  end
end
output_master(master, label = 'global') click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 57
def output_master(master, label = 'global')
  request_xfr = []
  allow_notify = []
  master.addresses.each do |addr|
    ipa = IPAddr.new(addr)
    plen = ipa.ipv4? ? 32 : 128
    tsig = master.tsig || 'NOKEY'
    request_xfr << "\trequest-xfr: #{addr}@#{master.port} #{tsig}\n"
    allow_notify << "\tallow-notify: #{addr}/#{plen}@#{master.port} #{tsig}\n"
  end
  output = request_xfr.join + allow_notify.join
  return "\t# #{label}\n#{output}" unless output.empty?
end
output_notify(notify, label = 'global') click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 71
def output_notify(notify, label = 'global')
  notifies = []
  provide_xfr = []
  notify.addresses.each do |addr|
    ipa = IPAddr.new(addr)
    plen = ipa.ipv4? ? 32 : 128
    tsig = notify.tsig || 'NOKEY'
    notifies << "\tnotify: #{addr}@#{notify.port} #{tsig}\n"
    provide_xfr << "\tprovide-xfr: #{addr}/#{plen}@#{notify.port} #{tsig}\n"
  end
  output = notifies.join + provide_xfr.join
  return "\t# #{label}\n#{output}" unless output.empty?
end
output_prefixes(_prefixes) click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 85
def output_prefixes(_prefixes)
  ''
end
zones_config(catalog_zone) click to toggle source
# File lib/dns/catalog_zone/provider/nsd.rb, line 89
def zones_config(catalog_zone)
  catalog_zone.zones.each_pair do |_hash, zone|
    output "zone:\n"
    output "\tinclude-pattern: \"CatalogZone\"\n"
    output "\tname: \"#{zone.zonename}\"\n"
    output "\tzonefile: \"#{zonepath(zone)}\"\n"
    zone.masters.each_pair do |label, master|
      output output_master(master, "#{label}.masters")
    end
    zone.notifies.each_pair do |label, notify|
      output output_notify(notify, "#{label}.notifies")
    end
  end
end