diff options
author | James Shubin <james@shubin.ca> | 2014-03-11 20:16:12 -0400 |
---|---|---|
committer | James Shubin <james@shubin.ca> | 2014-03-16 22:39:07 -0400 |
commit | 595e33ca69c0224f233b461b4d55cb42c38695f9 (patch) | |
tree | 4a51ec0c784ff04ba225a76f0959877c3b28ecbe /lib/facter/gluster_bricks.rb | |
parent | 170780287dd99191d1ea908c78ce88489366c0e0 (diff) | |
download | puppet-gluster-595e33ca69c0224f233b461b4d55cb42c38695f9.tar.gz puppet-gluster-595e33ca69c0224f233b461b4d55cb42c38695f9.tar.xz puppet-gluster-595e33ca69c0224f233b461b4d55cb42c38695f9.zip |
Remove algorithmic brick layout ordering that happens in the fact.
Since different brick layouts are now implemented, it makes sense to
remove any remaining traces of the algorithmic work from the fact...
Diffstat (limited to 'lib/facter/gluster_bricks.rb')
-rw-r--r-- | lib/facter/gluster_bricks.rb | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/lib/facter/gluster_bricks.rb b/lib/facter/gluster_bricks.rb index 2039144..e258fdd 100644 --- a/lib/facter/gluster_bricks.rb +++ b/lib/facter/gluster_bricks.rb @@ -74,54 +74,10 @@ if not(valid_brickdir.nil?) and File.directory?(valid_brickdir) end end -# sort the bricks in a logical manner... i think this is the optimal algorithm, -# but i'd be happy if someone thinks they can do better! this assumes that the -# bricks and hosts are named in a logical manner. alphanumeric sorting is used -# to determine the default ordering... -# TODO: maybe this should be a puppet function instead of a fact... that way, -# if necessary, the function could also include the replica count, and other -# data as input... is it even needed ? - +# transform to strings found.keys.each do |group| - - collect = {} - found[group].each do |x| - key = x['host'] - val = x['path'] - - if not collect.has_key?(key) - collect[key] = [] # initialize - end - - collect[key].push(val) # save in array - # TODO: ensure this array is always sorted (we could also do this after - # or always insert elements in the correct sorted order too :P) - collect[key] = collect[key].sort - end - - # we also could do this sort here... - collect.keys.each do |x| - collect[x] = collect[x].sort - end - - final = [] # final order... - # TODO: here we can probably detect if this is an asymmetrical configurations, or maybe bad naming... - while collect.size > 0 - collect.keys.sort.each do |x| - - # NOTE: this array should already be sorted! - p = collect[x].shift # assume an array of at least 1 element - final.push( { 'host' => x, 'path' => p } ) # save - - if collect[x].size == 0 # maybe the array is empty now - collect.delete(x) # remove that empty list's key - end - - end - end - # build final result - result[group] = final.collect {|x| x['host']+':'+x['path'] } + result[group] = found[group].collect {|x| x['host']+':'+x['path'] } end # build the correctly sorted brick list... |