Puppet Function: libvirt_generate_mac_addresses

Defined in:
lib/puppet/parser/functions/libvirt_generate_mac_addresses.rb
Function type:
Ruby 3.x API

Overview

libvirt_generate_mac_addresses(Any $hash)Any

Generates MAC addresses for all interfaces in the array which do not yet have an address specified. The MAC addresses are based on the domain name, network and portgroup.

Parameters:

  • hash (Any)

    of interfaces

Returns:

  • (Any)

    the interfacess with mac address



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppet/parser/functions/libvirt_generate_mac_addresses.rb', line 2

newfunction(:libvirt_generate_mac_addresses, type: :rvalue, doc: <<-'ENDHEREDOC') do |args|

  Puppet::Parser::Functions.function('generate_mac')
  Generates MAC addresses for all interfaces in the array which do not yet have an
  address specified. The MAC addresses are based on the domain name, network and
  portgroup.
  @param
     hash of interfaces
  @return the interfacess with mac address

  ENDHEREDOC

  ifaces = args[0]
  domain_name = args[1]

  ifaces.each do |iface|
    unless iface.key?('mac')
      iface['mac'] = function_libvirt_generate_mac([domain_name, iface['network'], iface['portgroup']])
    end
  end
end