diff --git a/deployment_scripts/puppet/modules/plugin_purestorage_cinder/lib/puppet/parser/functions/get_random_id.rb b/deployment_scripts/puppet/modules/plugin_purestorage_cinder/lib/puppet/parser/functions/get_random_id.rb index 856b92d..4177d15 100644 --- a/deployment_scripts/puppet/modules/plugin_purestorage_cinder/lib/puppet/parser/functions/get_random_id.rb +++ b/deployment_scripts/puppet/modules/plugin_purestorage_cinder/lib/puppet/parser/functions/get_random_id.rb @@ -1,15 +1,15 @@ -# Customm function to generate a random hex string of length arg[0]. +# Custom function to generate a random hex string of length arg[0]. # # This is used to ensure we get unique tenant and user IDs that # are required for the glance image-cache for cinder module Puppet::Parser::Functions - newfunction(:get_random_id, :type => :rvalue, :doc => "returns a random 32 character hex string") do |args| + newfunction(:get_random_id, :type => :rvalue, :doc => "returns a random hex string of length args[0]") do |args| raise(Puppet::ParseError, "get_random_id(): Wrong number of arguments " + "given (#{args.size} for 1)") if args.size != 1 numbers = (0..9).to_a alpha = ('a'..'z').to_a - length = args[0] + length = args[0].to_i CHARS = (alpha + numbers) id = CHARS.sort_by { rand }.join[0...length] return id