Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e74ae8fc authored by Jérémie Gaidamour's avatar Jérémie Gaidamour
Browse files

[dev] bindg5k: '-manual.db' + headers

parent 095e6cfd
No related branches found
No related tags found
No related merge requests found
......@@ -86,48 +86,48 @@ refapi["sites"].each { |site_uid, site|
entries = {}
# # ["networks", "laptops", "dom0"].each { |key|
# # entries[key] ||= []
["networks", "laptops", "dom0"].each { |key|
entries[key] ||= []
# # site[key].each { |uid, node|
# # if node['network_adapters'].nil?
# # puts "Warning: no network_adapters for #{uid}"
# # next
# # end
# # eth_net_uid = node['network_adapters'].select{ |u, h| h['mounted'] && /^eth[0-9]$/.match(u) } # eth* interfaces
# # node['network_adapters'].each { |net_uid, net_hash|
# # hostsuffix = nil
# # if ! eth_net_uid.include?(net_uid) && node['network_adapters'].size > 1
# # hostsuffix = "-#{net_uid}"
# # end
site[key].each { |uid, node|
if node['network_adapters'].nil?
puts "Warning: no network_adapters for #{uid}"
next
end
eth_net_uid = node['network_adapters'].select{ |u, h| h['mounted'] && /^eth[0-9]$/.match(u) } # eth* interfaces
node['network_adapters'].each { |net_uid, net_hash|
hostsuffix = nil
if ! eth_net_uid.include?(net_uid) && node['network_adapters'].size > 1
hostsuffix = "-#{net_uid}"
end
# # new_entry = {
# # :uid => uid,
# # :hostsuffix => hostsuffix, # cacahuete vs. cacahuete-eth0
# # :ip => net_hash['ip'],
# # }
new_entry = {
:uid => uid,
:hostsuffix => hostsuffix, # cacahuete vs. cacahuete-eth0
:ip => net_hash['ip'],
}
# # entries[key] << new_entry
# # }
# # }
# # }
entries[key] << new_entry
}
}
}
# # # PDUs
# # entries['pdus'] ||= []
# # site['pdus'].each { |pdu_uid, pdu|
# # if pdu['ip']
# PDUs
entries['pdus'] ||= []
site['pdus'].each { |pdu_uid, pdu|
if pdu['ip']
# # new_entry = {
# # :uid => pdu_uid,
# # :ip => pdu['ip']
# # }
new_entry = {
:uid => pdu_uid,
:ip => pdu['ip']
}
# # entries['pdus'] << new_entry
entries['pdus'] << new_entry
# # end
# # }
end
}
site.fetch("clusters").sort.each { |cluster_uid, cluster|
#next if cluster_uid != 'griffon'
......@@ -228,13 +228,20 @@ refapi["sites"].each { |site_uid, site|
zones_dir = Pathname("#{$output_dir}/modules/bindg5k/files/zones/#{site_uid}")
zones_dir.mkpath()
# DNS (/modules/bindg5k/files/zones/nancy-clusters.db)
output_file = cluster_file = site_uid + '-clusters.db'
File.write(zones_dir + output_file, dns.join("\n"))
# DNS (/modules/bindg5k/files/zones/nancy.db)
manual = site_uid + '-manual.db'
dns.unshift("$INCLUDE #{manual}") if File.exist?(zones_dir + manual) # add include statement
# Reverse DNS (/modules/bindg5k/files/zones/reverse-*db)
output_file = site_uid + '.db'
header = ERB.new(File.read('templates/bind-header.erb')).result(binding)
File.write(zones_dir + output_file, header + dns.join("\n"))
# Reverse DNS (/modules/bindg5k/files/zones/reverse-*db)
reverse.each { |output_file, output|
header = ERB.new(File.read('templates/bind-header.erb')).result(binding) # do not move outside of the loop (it uses the output_file variable)
manual = output_file.sub('.db', '') + '-manual.db'
output.unshift("$INCLUDE #{manual}") if File.exist?(zones_dir + manual) # add include statement
File.write(zones_dir + output_file, header + output.join("\n"))
}
......
......@@ -10,7 +10,7 @@
# List file in the directory instead of using the 'reverse' variable as some files might be set manually
Dir.entries(zones_dir).each { |file|
next unless /.*.db$/.match(file)
next if file == "#{site_uid}-clusters.db" # This file should be included in <site_uid>.db
next if /.*-manual\.db/.match(file) # Those files are included in the generated version of the file
comment = ''
zone = ''
......
......@@ -6,5 +6,7 @@ $TTL 3h
4w ; expire
1h) ; negative caching
@ IN NS dns.grid5000.fr.
@ IN NS dns.grid5000.fr.<%
if output_file == "#{site_uid}.db" %>
@ IN A <%= '172.16.79.101' %><% end %>
@ MX 10 mail.nancy.grid5000.fr.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment