Commit cf0ee8d2 authored by Jérémie Gaidamour's avatar Jérémie Gaidamour
Browse files

[dev] Enabled the generation of net-links.conf, dom0.conf and laptop.conf.

Also removed description and hostname options.
parent e3ce39a4
......@@ -35,12 +35,12 @@ end
def write_dhcp_file(data)
if data["nodes"].nil?
puts "Error in #{__method__}: no entry for \"#{data['description']}\" at #{data['site_uid']} (#{data['network_interfaces']})."
puts "Error in #{__method__}: no entry for \"#{data['filename']}\" at #{data['site_uid']} (#{data['network_interfaces']})."
return ""
end
erb = ERB.new(File.read("templates/dhcp.erb"))
output_file = "output/puppet-repo/modules/dhcpg5k/files/" + data.fetch("site_uid") + "/dhcpd.conf.d/" + data.fetch('filename') + ".conf"
output_file = "output/puppet-repo/modules/dhcpg5k/files/" + data.fetch("site_uid") + "/dhcpd.conf.d/" + data.fetch('filename')
# Create directory hierarchy
dirname = File.dirname(output_file)
......@@ -58,18 +58,21 @@ global_hash["sites"].each { |site_uid, site_hash|
# On file for each clusters
site_hash.fetch("clusters").each { |cluster_uid, cluster_hash|
write_dhcp_file({
"filename" => "cluster-" + cluster_uid,
"description" => cluster_uid,
"filename" => "cluster-" + cluster_uid + ".conf",
"site_uid" => site_uid,
"nodes" => cluster_hash["nodes"],
"nodes" => cluster_hash.fetch('nodes'),
"network_interfaces" => ["eth", "bmc"],
"hostname" => true
})
}
# Other dhcp files
# write_dhcp_file(site_uid, site_hash["net-links"], "eth", "switchs", "Switchs", false)
# write_dhcp_file(site_uid, site_hash["laptops"], "eth", "laptops", "Admin laptop's")
# write_dhcp_file(site_uid, site_hash["dom0"], "eth", "dom0", "Dom0")
["net-links", "laptops", "dom0"].each { |key|
write_dhcp_file({
"filename" => key + ".conf",
"site_uid" => site_uid,
"nodes" => site_hash['nodes'],
"network_interfaces" => ["eth"],
})
}
}
# INSTALLED BY PUPPET, GENERATED by reference-repo generators
# Module:: dhcpg5k
# File:: puppet:///modules/dhcpg5k/<%= data['site_uid']%>/dhcpd.conf.d/<%= data['filename'] %>.conf
# File:: puppet:///modules/dhcpg5k/<%= data.fetch('site_uid') %>/dhcpd.conf.d/<%= data.fetch('filename') %>
#
<%
site_uid = data['site_uid']
site_uid = data.fetch('site_uid')
data['network_interfaces'].each { |network_interface|
data['nodes'].sort_by { |item| item.to_s.split(/(\d+)/).map { |e| [e.to_i, e] } }.each { |node_uid, node_hash|
data.fetch('network_interfaces').each { |network_interface|
data.fetch('nodes').sort_by { |item| item.to_s.split(/(\d+)/).map { |e| [e.to_i, e] } }.each { |node_uid, node_hash|
network_interface != 'bmc' ? node_uid_net = node_uid : node_uid_net = node_uid + '-bmc'
# Get ip and mac addresses
......@@ -21,8 +21,7 @@
%>
host <%= node_uid_net %>.<%= site_uid %>.grid5000.fr {
hardware ethernet <%= node_mac.upcase %>;
fixed-address <%= node_ip %>;<% if data['hostname'] %>
option host-name <%= node_uid_net %>;<% end %>
fixed-address <%= node_ip %>;
}
<% } %>
<% } %>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment