James Turnbull wrote:
> Signed-off-by: James Turnbull <[EMAIL PROTECTED]>
> ---
>  lib/puppet/parser/functions.rb |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
> index 9399127..8decb82 100644
> --- a/lib/puppet/parser/functions.rb
> +++ b/lib/puppet/parser/functions.rb
> @@ -188,6 +188,22 @@ module Functions
>          result
>      end
>  
> +    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|
> +     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)
> +     rand(max).to_s
> +    end 
> +
>   
Will this cause the return value to be regenerated each run?
>      newfunction(:fail, :doc => "Fail with a parse error.") do |vals|
>          vals = vals.collect { |s| s.to_s }.join(" ") if vals.is_a? Array
>          raise Puppet::ParseError, vals.to_s
>   
Regards,

AJ

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to