aboutsummaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions/lookup_hiera_hash.rb
blob: d96d65fa9fe0341ff2be8fc20761b5c79af86848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Puppet::Parser::Functions
  newfunction(:lookup_hiera_hash, :arity => 2, :type => :rvalue,
              :doc => "Lookup a key->value from a Hiera hash") do |args|
    hash_name = args[0]
    key_name = args[1]
    unless hash_name.is_a?(String) and key_name.is_a?(String)
      raise Puppet::ParseError, "The hash name and the key name must be given as strings."
    end
    if defined? call_function
      hash = call_function('hiera', [hash_name])
    else
      hash = function_hiera([hash_name])
    end
    unless hash.is_a?(Hash)
      raise Puppet::ParseError, "The value Hiera returned for #{hash_name} is not a Hash."
    end
    unless hash.key?(key_name)
      raise Puppet::ParseError, "The Hiera hash #{hash_name} does not contain key #{key_name}."
    end
    return hash[key_name]
  end
end
39;, 'write', 'IOPS') fio_w_vm_index = get_index(fio_dict, 'fio_vm', fio_w_vm_ref, 'details', 'job_0', 'write', 'io_ps') fio_vm_index = (fio_r_vm_index + fio_w_vm_index) / 2 fio_index = (fio_bm_index + fio_vm_index) / 2 print fio_index fio_dict_i = {} fio_dict_i['index'] = fio_index fio_dict_i['results'] = fio_dict return fio_dict_i