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

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.

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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.

  ENDHEREDOC

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

  ifaces.each { |iface|
    if ! iface.has_key?('mac') then
      iface['mac'] = function_libvirt_generate_mac([domain_name, iface['network'], iface['portgroup']])
    end
  }
end