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
|
Rev | Line | |
---|
[30960] | 1 | # Test whether a given class or definition is defined
|
---|
| 2 | require 'puppet/parser/functions'
|
---|
| 3 |
|
---|
| 4 | Puppet::Parser::Functions.newfunction(:getparam,
|
---|
| 5 | :type => :rvalue,
|
---|
| 6 | :doc => <<-'ENDOFDOC'
|
---|
| 7 | Takes a resource reference and name of the parameter and
|
---|
| 8 | returns 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 |
|
---|
| 21 | Would return: param_value
|
---|
| 22 | ENDOFDOC
|
---|
| 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 ''
|
---|
| 35 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.