volumes for coccia at ubc
[mirror/dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / onion_balance_service_hostname.rb
1 # This function returns the .onion name for a given service name on the local host's onionbalance instance
2 module Puppet::Parser::Functions
3   newfunction(:onion_balance_service_hostname, :type => :rvalue) do |args|
4     servicename = args.shift()
5
6     onion_balance_service_hostname_fact = lookupvar('onion_balance_service_hostname')
7     return nil if onion_balance_service_hostname_fact.nil?
8
9     require 'json'
10     parsed = JSON.parse(onion_balance_service_hostname_fact)
11     return parsed[servicename]
12   end
13 end
14 # vim:set ts=2:
15 # vim:set et:
16 # vim:set shiftwidth=2: