Puppet Function: netmask2cidr

Defined in:
lib/puppet/functions/netmask2cidr.rb
Function type:
Ruby 4.x API

Overview

netmask2cidr(Stdlib::IP::Address $netmask)Any

Parameters:

  • netmask (Stdlib::IP::Address)

Returns:

  • (Any)


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

Puppet::Functions.create_function(:netmask2cidr, Puppet::Functions::InternalFunction) do
  dispatch :single do
    param 'Stdlib::IP::Address', :netmask
  end
  def single(netmask)
    result = IPAddr.new(netmask).to_i.to_s(2).count("1")
  end
end