dhcp.erb 1.22 KB
Newer Older
1
# INSTALLED BY PUPPET, GENERATED by reference-repo generators
2
# Module:: dhcpg5k
3
# File:: puppet:///modules/dhcpg5k/<%= data.fetch('site_uid') %>/dhcpd.conf.d/<%= data.fetch('filename') %>
4
#
5
<%
6
  site_uid = data.fetch('site_uid')
7

Jérémie Gaidamour's avatar
Jérémie Gaidamour committed
8
  data.fetch('network_adapters').each { |network_interface|
9 10 11
%>
group {
<%
Jérémie Gaidamour's avatar
Jérémie Gaidamour committed
12
    data.fetch('nodes').each_sort_by_node_uid { |node_uid, node_hash| 
13 14 15 16 17 18 19 20
      next if node_hash['status'] && node_hash['status']['retired']

      case network_interface
        when 'bmc', 'adm', 'mic0'
          node_uid_net = node_uid + '-' + network_interface
        else
          node_uid_net = node_uid
        end
21 22 23 24 25

      # Get ip and mac addresses
      begin
        node_ip, node_mac = get_network_info(node_hash, network_interface)
      rescue => e
26 27
        next if data.fetch('optional_network_adapters').include?(network_interface)

28
        # Hash.fetch(key) raise KeyError if the hash[key] does not exist.
29
        puts "Warning: #{site_uid} - #{node_uid}: #{e}. Skip the DHCP entry of the #{network_interface} interface." # (error in #{__method__})
30 31 32
        next
      end
%>
33
  host <%= node_uid_net %> {
34 35 36
    hardware ethernet       <%= node_mac.upcase %>;
    fixed-address           <%= node_ip         %>;
  }
37
<%   } %>
38
}
39
<% }   %>