Puppet Function: wmflib::mask2cidr
- Defined in:
-
modules/wmflib/lib/puppet/functions/wmflib/mask2cidr.rb
- Function type:
- Ruby 4.x API
Summary
Convert an Subnetmask to the cidr value
Overview
wmflib::mask2cidr(Stdlib::IP::Address $mask) ⇒ Any
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'modules/wmflib/lib/puppet/functions/wmflib/mask2cidr.rb', line 10
Puppet::Functions.create_function(:'wmflib::mask2cidr') do
dispatch :mask2cidr do
param 'Stdlib::IP::Address', :mask
end
def mask2cidr(mask)
IPAddr.new(mask).to_i.to_s(2).count("1")
end
end
|