source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/getparam.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 8 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 965 bytes
Line 
1# Test whether a given class or definition is defined
2require 'puppet/parser/functions'
3
4Puppet::Parser::Functions.newfunction(:getparam,
5 :type => :rvalue,
6 :doc => <<-'ENDOFDOC'
7Takes a resource reference and name of the parameter and
8returns value of resource's parameter.
9
10*Examples:*
11
12 define example_resource($param) {
13 }
14
15 example_resource { "example_resource_instance":
16 param => "param_value"
17 }
18
19 getparam(Example_resource["example_resource_instance"], "param")
20
21Would return: param_value
22ENDOFDOC
23) do |vals|
24 reference, param = vals
25 raise(ArgumentError, 'Must specify a reference') unless reference
26 raise(ArgumentError, 'Must specify name of a parameter') unless param and param.instance_of? String
27
28 return '' if param.empty?
29
30 if resource = findresource(reference.to_s)
31 return resource[param] unless resource[param].nil?
32 end
33
34 return ''
35end
Note: See TracBrowser for help on using the repository browser.