diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-18 17:32:46 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-18 17:32:46 +0000 |
| commit | 53a469c0000eb1f487eab456c0986d427d714bd7 (patch) | |
| tree | dd0f8c72a73f18371f50fa5559bb43d10b7301b5 /lib/puppet/parser | |
| parent | d5569bcf30ad40b1780c1550368455127114cdd2 (diff) | |
| download | puppet-53a469c0000eb1f487eab456c0986d427d714bd7.tar.gz puppet-53a469c0000eb1f487eab456c0986d427d714bd7.tar.xz puppet-53a469c0000eb1f487eab456c0986d427d714bd7.zip | |
Fixing #703, mostly. You still cannot do multi-condition queries, but you can at least query against any parameter, and matching any value is sufficient for a match, so the tags work fine.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2705 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser')
| -rw-r--r-- | lib/puppet/parser/ast/collexpr.rb | 16 | ||||
| -rw-r--r-- | lib/puppet/parser/collector.rb | 10 |
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/puppet/parser/ast/collexpr.rb b/lib/puppet/parser/ast/collexpr.rb index f69b2e92e..e9f2e63e0 100644 --- a/lib/puppet/parser/ast/collexpr.rb +++ b/lib/puppet/parser/ast/collexpr.rb @@ -43,7 +43,9 @@ class CollExpr < AST::Branch end case @oper - when "and", "or": oper = @oper.upcase + when "and", "or": + raise Puppet::ParseError, "Puppet does not currently support collecting exported resources with more than one condition" + #oper = @oper.upcase when "==": oper = "=" else oper = @oper @@ -54,17 +56,13 @@ class CollExpr < AST::Branch if str1 == "title" str = "title #{oper} '#{str2}'" else - unless self.form == :virtual or str1 == "title" - parsefail "Collection from the database only supports " + - "title matching currently" - end - str = "rails_parameters.name = '#{str1}' and " + - "rails_parameters.value #{oper} '#{str2}'" + str = "param_values.value #{oper} '#{str2}' and " + + "param_names.name = '#{str1}'" end else - str = [str1, oper, str2].join(" ") + str = "(%s) %s (%s)" % [str1, oper, str2] end - + return str, code end diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index 868946c8c..62eafdd65 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -22,9 +22,13 @@ class Puppet::Parser::Collector end host = Puppet::Rails::Host.find_by_name(@scope.host) - args = {} + args = {:include => {:param_values => :param_name}} + args[:conditions] = "restype = '%s'" % [@type] + if @equery + args[:conditions] += " AND (%s)" % [@equery] + end if host - args[:conditions] = "host_id != #{host.id}" + args[:conditions] = "host_id != %s AND %s" % [host.id, args[:conditions]] else #Puppet.info "Host %s is uninitialized" % @scope.host end @@ -33,7 +37,7 @@ class Puppet::Parser::Collector # and such, we'll need to vary the conditions, but this works with no # attributes, anyway. time = Puppet::Util.thinmark do - Puppet::Rails::Resource.find_all_by_restype_and_exported(@type, true, + Puppet::Rails::Resource.find(:all, @type, true, args ).each do |obj| if resource = export_resource(obj) |
