aboutsummaryrefslogtreecommitdiffstats
path: root/modules/stored_config
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2011-03-22 17:27:07 +0000
committerMichael Scherer <misc@mageia.org>2011-03-22 17:27:07 +0000
commit1efbb7c5845560bc766388c1b113fb7ead193d3f (patch)
treeccc4f89214a2e7ae07e824e90a153150c9756bf5 /modules/stored_config
parent429b96e025018795a65f3a9b952a6609e53c899c (diff)
downloadpuppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar
puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar.gz
puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar.bz2
puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.tar.xz
puppet-1efbb7c5845560bc766388c1b113fb7ead193d3f.zip
- add function get_param_values
Diffstat (limited to 'modules/stored_config')
-rw-r--r--modules/stored_config/lib/puppet/parser/functions/get_param_values.rb25
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