summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Shubin <james@shubin.ca>2014-03-11 20:16:12 -0400
committerJames Shubin <james@shubin.ca>2014-03-16 22:39:07 -0400
commit595e33ca69c0224f233b461b4d55cb42c38695f9 (patch)
tree4a51ec0c784ff04ba225a76f0959877c3b28ecbe
parent170780287dd99191d1ea908c78ce88489366c0e0 (diff)
downloadpuppet-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...
-rw-r--r--lib/facter/gluster_bricks.rb48
-rw-r--r--lib/puppet/parser/functions/brick_layout_simple.rb6
2 files changed, 8 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...
diff --git a/lib/puppet/parser/functions/brick_layout_simple.rb b/lib/puppet/parser/functions/brick_layout_simple.rb
index 7b3a6eb..96ef70d 100644
--- a/lib/puppet/parser/functions/brick_layout_simple.rb
+++ b/lib/puppet/parser/functions/brick_layout_simple.rb
@@ -15,6 +15,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# NOTE:
+# 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...
+
module Puppet::Parser::Functions
newfunction(:brick_layout_simple, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
Return the simple symmetrical brick list