4 Puppet::Parser::Functions.newfunction(
9 Usage: `seeded_rand(MAX, SEED)`. MAX must be a positive integer; SEED is any string.
11 Generates a random whole number greater than or equal to 0 and less
12 than MAX, using the value of SEED for repeatable randomness. If SEED
13 starts with "$fqdn:", this is behaves the same as `fqdn_rand`.
18 raise(ArgumentError, 'seeded_rand(): first argument must be a positive integer') unless function_is_integer([args[0]]) && args[0].to_i > 0
19 raise(ArgumentError, 'seeded_rand(): second argument must be a string') unless args[1].is_a? String
22 seed = Digest::MD5.hexdigest(args[1]).hex
23 Puppet::Util.deterministic_rand(seed, max)