diff options
author | Michael Scherer <misc@mageia.org> | 2011-03-22 17:27:07 +0000 |
---|---|---|
committer | Michael Scherer <misc@mageia.org> | 2011-03-22 17:27:07 +0000 |
commit | 1efbb7c5845560bc766388c1b113fb7ead193d3f (patch) | |
tree | ccc4f89214a2e7ae07e824e90a153150c9756bf5 | |
parent | 429b96e025018795a65f3a9b952a6609e53c899c (diff) | |
download | puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar.gz puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar.bz2 puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar.xz puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.zip |
- add function get_param_values
-rw-r--r-- | modules/stored_config/lib/puppet/parser/functions/get_param_values.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/stored_config/lib/puppet/parser/functions/get_param_values.rb b/modules/stored_config/lib/puppet/parser/functions/get_param_values.rb new file mode 100644 index 00000000..ee0c3440 --- /dev/null +++ b/modules/stored_config/lib/puppet/parser/functions/get_param_values.rb @@ -0,0 +1,25 @@ +require 'puppet/rails' + +# function : +# get_param_values($name, $type, $param_name) +# -> return the value corresponding to $param_name for the $name object of type $type + +module Puppet::Parser::Functions + newfunction(:get_param_values, :type => :rvalue) do |args| + resource_name = args[0] + exported_type = args[1] + param_name = args[2] + Puppet::Rails.connect() + # TODO use find_each + # TODO fail more gracefully when nothing match + # using a default value, maybe ? + return Puppet::Rails::ParamValue.find(:first, + :joins => [ :resource, :param_name ], + :conditions => { :param_names => {:name => param_name }, + :resources => { :exported => true, + :restype => exported_type, + :title => resource_name, + } } + ).value + end +end |