Puppet Function: libvirt_generate_mac

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

Overview

libvirt_generate_mac()Any

Returns:

  • (Any)


2
3
4
5
6
7
8
9
10
# File 'lib/puppet/parser/functions/libvirt_generate_mac.rb', line 2

newfunction(:libvirt_generate_mac, :type => :rvalue) do |args|

  # compute sha1 hash of all keys concatenated, only the first 6
  # hex digits will be used
  sha1 = Digest::SHA1.hexdigest(args.join(''))

  # generate address in the QEMU/KVM MAC OID
  '52:54:00:' + "#{sha1[0..1]}:#{sha1[2..3]}:#{sha1[4..5]}"
end