diff options
author | Markus Roberts <Markus@reality.com> | 2009-09-15 13:18:22 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-09-16 07:14:52 +1000 |
commit | cb90528c041b63c1c483ac8650d1d9c67a12d791 (patch) | |
tree | 3e0ce533fa20da9a1847ddc7ac08036caa2364c8 /lib | |
parent | b1554a1a38aa7a4da6c9927e26c9411af4ce1dff (diff) | |
download | puppet-cb90528c041b63c1c483ac8650d1d9c67a12d791.tar.gz puppet-cb90528c041b63c1c483ac8650d1d9c67a12d791.tar.xz puppet-cb90528c041b63c1c483ac8650d1d9c67a12d791.zip |
Merged fix for #2601
This patch rolls up the changeses discussed on the list & the ticket
The fqdn_rand now takes any number of additional arguments of any
type that has a string representation (typically integers or strings)
and concatenats them on to the salt.
The tests have been adjusted to reflect this.
Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/parser/functions/fqdn_rand.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/puppet/parser/functions/fqdn_rand.rb b/lib/puppet/parser/functions/fqdn_rand.rb index 3741d2d32..9297539e3 100644 --- a/lib/puppet/parser/functions/fqdn_rand.rb +++ b/lib/puppet/parser/functions/fqdn_rand.rb @@ -1,15 +1,9 @@ Puppet::Parser::Functions::newfunction(:fqdn_rand, :type => :rvalue, :doc => "Generates random numbers based on the node's fqdn. The first argument - sets the range. The second argument specifies a number to add to the - seed and is optional.") do |args| + sets the range. Additional (optional) arguments may be used to further + distinguish the seed.") do |args| require 'md5' - max = args[0] - if args[1] then - seed = args[1] - else - seed = 1 - end - fqdn_seed = MD5.new(lookupvar('fqdn')).to_s.hex - srand(seed+fqdn_seed) + max = args.shift + srand MD5.new([lookupvar('fqdn'),args].join(':')).to_s.hex rand(max).to_s end |