Puppet Function: haproxy::sort_bind
- Defined in:
-
lib/puppet/functions/haproxy/sort_bind.rb
- Function type:
- Ruby 4.x API
Overview
haproxy::sort_bind(Hash $bind) ⇒ Array
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/puppet/functions/haproxy/sort_bind.rb', line 3
Puppet::Functions.create_function(:'haproxy::sort_bind') do
dispatch :sort_bind do
param 'Hash', :bind
return_type 'Array'
end
def sort_bind(bind)
bind.sort_by do |address_port|
md = %r{^((\d+)\.(\d+)\.(\d+)\.(\d+))?(.*)}.match(address_port[0])
[(md[1] ? md[2..5].inject(0) { |addr, octet| (addr << 8) + octet.to_i } : -1), md[6]]
end
end
end
|