summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-07-28 18:10:16 +0100
committerKen Barber <ken@bob.sh>2011-07-28 18:10:16 +0100
commit635ed82e5cae38b0ba82098c340cbeed70d483c3 (patch)
tree6da1b936dd267452c8f89711a518a3b5d6500f50 /lib/puppet/parser/functions
parent7efd6ec5819775226d669c15b58649d375f72959 (diff)
downloadpuppet-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.rb13
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