Puppet Function: wmflib::cidr2mask
- Defined in:
-
modules/wmflib/lib/puppet/functions/wmflib/cidr2mask.rb
- Function type:
- Ruby 4.x API
Summary
Convert a CIDR value to its associated netmask
Overview
wmflib::cidr2mask(String $cidr) ⇒ str
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'modules/wmflib/lib/puppet/functions/wmflib/cidr2mask.rb', line 6
Puppet::Functions.create_function(:'wmflib::cidr2mask') do
dispatch :cidr2mask do
param 'String', :cidr
end
def cidr2mask(cidr_s)
cidr = IPAddr.new(cidr_s)
IPAddr.new(cidr.instance_variable_get(:@mask_addr), cidr.family).to_s
end
end
|