Puppet Function: wmflib::cidr_first_address
- Defined in:
- modules/wmflib/lib/puppet/functions/wmflib/cidr_first_address.rb
- Function type:
- Ruby 4.x API
Summary
eturns the first usable address of a cidr networkOverview
SPDX-License-Identifier: Apache-2.0
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'modules/wmflib/lib/puppet/functions/wmflib/cidr_first_address.rb', line 4 Puppet::Functions.create_function(:'wmflib::cidr_first_address') do # @param ip IPv6 or IPv4 address in CIDR notation # @return IPv6 or IPv4 network/net address # @example calling the function # wmflib::cidr_first_address('2001:DB8::/32') dispatch :cidr_to_network do param 'Variant[Stdlib::IP::Address::V4::CIDR,Stdlib::IP::Address::V6::CIDR]', :ip return_type 'Variant[Stdlib::IP::Address::V4::Nosubnet,Stdlib::IP::Address::V6::Nosubnet]' end def cidr_to_network(ip) IPAddr.new(ip).to_range.first(2)[1].to_s end end |