summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions/brick_layout_simple.rb
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2014-10-21 14:15:40 -0400
committerJames Shubin <james@shubin.ca>2014-10-21 14:15:40 -0400
commit06af205a562d543bbeb7c4d5c55143ade3bdb4e6 (patch)
treef54817a7c0ec6024c67e0164a95f35306030878f /lib/puppet/parser/functions/brick_layout_simple.rb
parente99afc506680bdb9225fe0473cbf366aad451d23 (diff)
downloadpuppet-gluster-06af205a562d543bbeb7c4d5c55143ade3bdb4e6.tar.gz
puppet-gluster-06af205a562d543bbeb7c4d5c55143ade3bdb4e6.tar.xz
puppet-gluster-06af205a562d543bbeb7c4d5c55143ade3bdb4e6.zip
Split brick_str_to_hash into separate function.
This should work around a regression introduced in a recent version of puppet. (Perhaps 3.7.1?) Allowing custom helper functions in ruby was apparently never "supposed" to work, and was removed silently... :( binford2k: it was an accidental loophole got closed during code cleanup The bug about this issue is: https://tickets.puppetlabs.com/browse/PUP-3404 Thanks to binford2k for tracking down this bug. His URL finding skills are impeccable! Thanks to my puppet-gluster users for finding the issue!
Diffstat (limited to 'lib/puppet/parser/functions/brick_layout_simple.rb')
-rw-r--r--lib/puppet/parser/functions/brick_layout_simple.rb17
1 files changed, 3 insertions, 14 deletions
diff --git a/lib/puppet/parser/functions/brick_layout_simple.rb b/lib/puppet/parser/functions/brick_layout_simple.rb
index d91a472..761b58e 100644
--- a/lib/puppet/parser/functions/brick_layout_simple.rb
+++ b/lib/puppet/parser/functions/brick_layout_simple.rb
@@ -34,6 +34,8 @@ module Puppet::Parser::Functions
ENDHEREDOC
+ Puppet::Parser::Functions.function('brick_str_to_hash') # load function
+
# signature: replica, bricks -> bricks
unless args.length == 2
raise Puppet::ParseError, "brick_layout_simple(): wrong number of arguments (#{args.length}; must be 2)"
@@ -52,22 +54,9 @@ module Puppet::Parser::Functions
# TODO: these functions could be in separate puppet files
# eg: Puppet::Parser::Functions.function('myfunc')
# function_myfunc(...)
- def brick_str_to_hash(bricks)
- # this loop converts brick strings to brick dict's...
- result = []
- bricks.each do |x|
- a = x.split(':')
- #assert a.length == 2 # TODO
- p = a[1]
- p = ((p[-1, 1] == '/') ? p : (p+'/')) # endswith
-
- result.push({'host'=> a[0], 'path'=> p})
- end
- return result
- end
collect = {}
- parsed = brick_str_to_hash(bricks)
+ parsed = function_brick_str_to_hash([bricks])
parsed.each do |x|
key = x['host']
val = x['path']