summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions/extract_id.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/extract_id.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/extract_id.rb')
-rw-r--r--lib/puppet/parser/functions/extract_id.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/extract_id.rb b/lib/puppet/parser/functions/extract_id.rb
new file mode 100644
index 0000000..61734ab
--- /dev/null
+++ b/lib/puppet/parser/functions/extract_id.rb
@@ -0,0 +1,14 @@
+# Custom function to extract the index from a list.
+# The list are a list of hostname, and the index is the n'th
+# position of the host in list
+module Puppet::Parser::Functions
+ newfunction(:extract_id, :type => :rvalue) do |argv|
+ hosts = argv[0]
+ if hosts.class != Array
+ hosts = [hosts]
+ end
+ hostname = argv[1]
+ hash = Hash[hosts.map.with_index.to_a]
+ return hash[hostname].to_i + 1
+ end
+end