diff options
author | Ken Barber <ken@bob.sh> | 2011-07-28 18:10:16 +0100 |
---|---|---|
committer | Ken Barber <ken@bob.sh> | 2011-07-28 18:10:16 +0100 |
commit | 635ed82e5cae38b0ba82098c340cbeed70d483c3 (patch) | |
tree | 6da1b936dd267452c8f89711a518a3b5d6500f50 /lib/puppet/parser/functions | |
parent | 7efd6ec5819775226d669c15b58649d375f72959 (diff) | |
download | puppet-stdlib-635ed82e5cae38b0ba82098c340cbeed70d483c3.tar.gz puppet-stdlib-635ed82e5cae38b0ba82098c340cbeed70d483c3.tar.bz2 |
(#2) - unstubbed is_valid_ip_address
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r-- | lib/puppet/parser/functions/is_valid_ip_address.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/is_valid_ip_address.rb b/lib/puppet/parser/functions/is_valid_ip_address.rb index e91dda8..4f45890 100644 --- a/lib/puppet/parser/functions/is_valid_ip_address.rb +++ b/lib/puppet/parser/functions/is_valid_ip_address.rb @@ -7,11 +7,24 @@ module Puppet::Parser::Functions EOS ) do |arguments| + require 'ipaddr' + if (arguments.size != 1) then raise(Puppet::ParseError, "is_valid_ip_address(): Wrong number of arguments "+ "given #{arguments.size} for 1") end + begin + ip = IPAddr.new(arguments[0]) + rescue ArgumentError + return false + end + + if ip.ipv4? or ip.ipv6? then + return true + else + return false + end end end |