aboutsummaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions/list_to_zookeeper_hash.rb
diff options
context:
space:
mode:
authorJaume Devesa <devvesa@gmail.com>2015-11-10 21:13:43 +0100
committerJaume Devesa <devvesa@gmail.com>2015-11-23 11:53:07 +0100
commit95c87ea79bee85373c68befb43f46d975dafe241 (patch)
treecf3fd8349936f50bfeb73c6ab03add553ddfd997 /lib/puppet/parser/functions/list_to_zookeeper_hash.rb
parent37b58bef9e51d6a39cbd9f71e2df9f70148ccbb5 (diff)
MidoNet services manifests
Provide TripleO overcloud manifests to deploy MidoNet and the cluster services that needs to run. Change-Id: I24f852e74fc4652d4609e1a71897e813448055fe
Diffstat (limited to 'lib/puppet/parser/functions/list_to_zookeeper_hash.rb')
-rw-r--r--lib/puppet/parser/functions/list_to_zookeeper_hash.rb24
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