diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-11-26 10:07:39 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-11-26 10:07:39 +0000 |
commit | 43574dadf192a1df942898a626a359f60f286a20 (patch) | |
tree | 507c29b6ead12ce4e82b98ae8c0e98bc9827ff09 /lib/puppet/parser/functions/list_to_zookeeper_hash.rb | |
parent | dafdc1f4efde8c57a8c7160ae0162866496089dc (diff) | |
parent | 95c87ea79bee85373c68befb43f46d975dafe241 (diff) |
Merge "MidoNet services manifests"
Diffstat (limited to 'lib/puppet/parser/functions/list_to_zookeeper_hash.rb')
-rw-r--r-- | lib/puppet/parser/functions/list_to_zookeeper_hash.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/list_to_zookeeper_hash.rb b/lib/puppet/parser/functions/list_to_zookeeper_hash.rb new file mode 100644 index 0000000..814326e --- /dev/null +++ b/lib/puppet/parser/functions/list_to_zookeeper_hash.rb @@ -0,0 +1,24 @@ +# Custom function to convert a list of ips to a map +# like {'ip' => xxx.xxx.xxx.xxx }. This function is needed +# because a not-so-good design of the puppet-midonet module +# and we hope to deprecate it soon. + +module Puppet::Parser::Functions + newfunction(:list_to_zookeeper_hash, :type => :rvalue, :doc => <<-EOS + This function returns Zookeper configuration list of hash + EOS + ) do |argv| + zk_list = argv[0] + if zk_list.class != Array + zk_list = [zk_list] + end + result = Array.new + zk_list.each do |zk_ip| + zk_map = Hash.new + zk_map['ip'] = zk_ip + zk_map['port'] = 2181 + result.push(zk_map) + end + return result + end +end |