class Dns::CatalogZone::Provider::Yadifa
Public Class Methods
new(setting)
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 27 def initialize(setting) @setting = setting end
Public Instance Methods
make(catalog_zone)
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 31 def make(catalog_zone) @output = '' @type = 'master' @templates = [] @acls = [] @remotes = [] @zones = [] @masters = [] @notifies = [] global_config(catalog_zone) zones_config(catalog_zone) end
reconfig()
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 44 def reconfig system("#{control} cfgreload") end
Private Instance Methods
add_master(master, masters)
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 79 def add_master(master, masters) return if master.addresses.empty? @type = 'slave' masters.push(master.addresses) end
add_notify(notify, notifies)
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 85 def add_notify(notify, notifies) return if notify.addresses.empty? notifies.push(notify.addresses) end
add_prefixes(prefixes, allow_transfers)
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 90 def add_prefixes(prefixes, allow_transfers) prefixes.prefixes.each do |prefix| allow_transfers.push("#{prefix.address}/#{prefix.prefix_length}") end end
control()
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 49 def control @setting['control'] || "yadifa" end
global_config(catalog_zone)
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 53 def global_config(catalog_zone) allow_transfers = [] catalog_zone.masters.each_pair do |_label, master| add_master(master, @masters) end catalog_zone.notifies.each_pair do |_label, notify| add_notify(notify, @notifies) end catalog_zone.allow_transfers.each_pair do |_label, prefixes| add_prefixes(prefixes, allow_transfers) end output_r '<main>' # for master unless @masters.empty? output_r "\tallow-notify\t#{@masters.join(';')}" end # for allow-transfer unless allow_transfers.empty? output_r "\tallow-transfer\t#{allow_transfers.join(';')}" end output_r '</main>' end
zones_config(catalog_zone)
click to toggle source
# File lib/dns/catalog_zone/provider/yadifa.rb, line 96 def zones_config(catalog_zone) catalog_zone.zones.each_pair do |_hash, zone| masters = @masters.clone notifies = @notifies.clone allow_transfers = [] zone.masters.each_pair do |_label, master| add_master(master, masters) end zone.notifies.each_pair do |_label, notify| add_notify(notify, notifies) end zone.allow_transfers.each_pair do |_label, prefixes| add_prefixes(prefixes, allow_transfers) end output_r '<zone>' output_r "\ttype\t#{@type}" output_r "\tdomain\t#{zone.zonename}" output_r "\tfile\t#{zonepath(zone)}" # for master unless masters.empty? output_r "\tallow-notify\t#{masters.join(';')}" output_r "\tmasters\t#{masters.join(',')}" output_r "\ttrue-multimaster\tyes" if masters.count > 1 end # for notify unless notifies.empty? output_r "\talso-notify\t#{notifies.join(',')}" allow_transfers = notifies end # for allow-transfer unless allow_transfers.empty? output_r "\tallow-transfer\t#{allow_transfers.join(';')}" end output_r '</zone>' end end