From 2a033995d09fb4ee730a20451fc99f41dcccbd7a Mon Sep 17 00:00:00 2001 From: Matthieu Imbert <matthieu.imbert@inria.fr> Date: Wed, 15 Apr 2020 15:22:36 +0200 Subject: [PATCH] [dhcp] fix: different names for Host entries of multiple ifaces in dhcpd confs --- lib/refrepo/gen/puppet/dhcpg5k.rb | 2 ++ lib/refrepo/gen/puppet/templates/dhcp.erb | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/refrepo/gen/puppet/dhcpg5k.rb b/lib/refrepo/gen/puppet/dhcpg5k.rb index 1117be2c9bc..dd3b38a280e 100644 --- a/lib/refrepo/gen/puppet/dhcpg5k.rb +++ b/lib/refrepo/gen/puppet/dhcpg5k.rb @@ -23,8 +23,10 @@ def get_network_info(node_hash, network_interface) mac = a.fetch('mac') ip = a.fetch('ip', nil) ip6 = a.fetch('ip6', nil) + name = a.fetch('network_address').split('.')[0] rescue node_hash['uid'] if (not ip.nil?) or (not ip6.nil?) network_infos << {'mac' => mac, + 'name' => name, 'ip' => ip, 'ip6' => ip6 } end diff --git a/lib/refrepo/gen/puppet/templates/dhcp.erb b/lib/refrepo/gen/puppet/templates/dhcp.erb index 2db6e119168..89ce12f6aaa 100644 --- a/lib/refrepo/gen/puppet/templates/dhcp.erb +++ b/lib/refrepo/gen/puppet/templates/dhcp.erb @@ -11,17 +11,16 @@ data.fetch('nodes').each_sort_by_node_uid { |node_uid, node| next if node == nil || (node['status'] && node['status'] == 'retired') - case network_interface - when 'bmc', 'adm', 'mic0' - uid_net = node_uid + '-' + network_interface - else - uid_net = node_uid - end - # Get ipv4, ipv6 and mac addresses begin ifinfos = get_network_info(node, network_interface) ifinfos.each do |h| + case network_interface + when 'bmc', 'adm', 'mic0' + uid_net = node_uid + '-' + network_interface + else + uid_net = h['name'] + end if dhcpkind == 'dhcpv6' if h['ip6'] dhcp_entries.push({ 'uid_net' => uid_net, 'ipv6' => h['ip6'], 'mac' => h['mac'] }) -- GitLab