8d889af7d4
With the release of 5.5.7, some of the legacy function definitions no longer pass in unit tests. This change updates the functions that are failing in the tests to the modern style (4.x) for function declarations. Additionally we're removing teh lookup_hiera_hash function which is failing but not actually consumed by our code base. There will be a followup patch to migrate the rest of the parser functions to the new format, but this patch should unblock the gates. NOTE: git thinks some of these files have been added/deleted rather than git move due to the large amount of changes between the two versions of the file. Change-Id: Ie7316fd422bd4a5eb91f94016977e5d8d76c27bc Closes-Bug: #1799786
30 lines
682 B
Ruby
30 lines
682 B
Ruby
require 'ipaddr'
|
|
|
|
# Custom function to verify if the parameter is a string representing an ip address
|
|
# or an array of strings representing an ip address
|
|
# Returns true if all elements are proper ip addresses and false otherwise
|
|
Puppet::Functions.create_function(:is_ip_addresses) do
|
|
dispatch :is_ip_addresses do
|
|
param 'Variant[Array, String, Undef]', :ip_addr
|
|
end
|
|
|
|
def is_ip_addresses(ip_addr)
|
|
if not ip_addr
|
|
return false
|
|
end
|
|
if ip_addr.class == String
|
|
ips = [ip_addr]
|
|
else
|
|
ips = ip_addr
|
|
end
|
|
ips.each do |ip|
|
|
begin
|
|
tmpip = IPAddr.new ip
|
|
rescue
|
|
return false
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
end
|