Fixing #1242 -- lack of storeconfigs only produces warning, not exception.
Exporting or collecting resources no longer raises an exception when no storeconfigs is enabled, it just produces a warning.
This commit is contained in:
Родитель
3d51a287e8
Коммит
65c1889f09
|
@ -1,3 +1,6 @@
|
|||
Exporting or collecting resources no longer raises an exception
|
||||
when no storeconfigs is enabled, it just produces a warning.
|
||||
|
||||
Always using the cert name to store yaml files, which fixes #1178.
|
||||
The Master handler previously provided the support for the :node_name
|
||||
setting, and that functionality has now been moved into the Node
|
||||
|
|
|
@ -6,6 +6,12 @@ class Puppet::Parser::Collector
|
|||
# Call the collection method, mark all of the returned objects as non-virtual,
|
||||
# and then delete this object from the list of collections to evaluate.
|
||||
def evaluate
|
||||
# Shortcut if we're not using storeconfigs and they're trying to collect
|
||||
# exported resources.
|
||||
if form == :exported and Puppet[:storeconfigs] != true
|
||||
Puppet.warning "Not collecting exported resources without storeconfigs"
|
||||
return false
|
||||
end
|
||||
if self.resources
|
||||
if objects = collect_resources and ! objects.empty?
|
||||
return objects
|
||||
|
|
|
@ -152,7 +152,7 @@ virtualresource: at resource {
|
|||
type = val[0]
|
||||
|
||||
if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly]
|
||||
error "You cannot collect without storeconfigs being set"
|
||||
Puppet.warning addcontext("You cannot collect without storeconfigs being set")
|
||||
end
|
||||
|
||||
if val[1].is_a? AST::ResourceDefaults
|
||||
|
@ -193,7 +193,7 @@ collection: classref collectrhand {
|
|||
args[:form] = val[1]
|
||||
end
|
||||
if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly]
|
||||
error "You cannot collect exported resources without storeconfigs being set"
|
||||
Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored")
|
||||
end
|
||||
result = ast AST::Collection, args
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ module Puppet
|
|||
|
||||
class Parser < Racc::Parser
|
||||
|
||||
module_eval <<'..end grammar.ra modeval..idfef5d70c9f', 'grammar.ra', 638
|
||||
module_eval <<'..end grammar.ra modeval..id9145566289', 'grammar.ra', 638
|
||||
|
||||
# It got too annoying having code in a file that needs to be compiled.
|
||||
require 'puppet/parser/parser_support'
|
||||
|
@ -41,7 +41,7 @@ require 'puppet/parser/parser_support'
|
|||
|
||||
# $Id$
|
||||
|
||||
..end grammar.ra modeval..idfef5d70c9f
|
||||
..end grammar.ra modeval..id9145566289
|
||||
|
||||
##### racc 1.4.5 generates ###
|
||||
|
||||
|
@ -958,7 +958,7 @@ module_eval <<'.,.,', 'grammar.ra', 174
|
|||
type = val[0]
|
||||
|
||||
if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly]
|
||||
error "You cannot collect without storeconfigs being set"
|
||||
Puppet.warning addcontext("You cannot collect without storeconfigs being set")
|
||||
end
|
||||
|
||||
if val[1].is_a? AST::ResourceDefaults
|
||||
|
@ -1011,7 +1011,7 @@ module_eval <<'.,.,', 'grammar.ra', 199
|
|||
args[:form] = val[1]
|
||||
end
|
||||
if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly]
|
||||
error "You cannot collect exported resources without storeconfigs being set"
|
||||
Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored")
|
||||
end
|
||||
result = ast AST::Collection, args
|
||||
result
|
||||
|
|
|
@ -204,6 +204,8 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
|
|||
@equery = "test = true"
|
||||
@vquery = proc { |r| true }
|
||||
|
||||
Puppet.settings.stubs(:value).with(:storeconfigs).returns true
|
||||
|
||||
@collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported)
|
||||
end
|
||||
|
||||
|
@ -217,6 +219,11 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
|
|||
end
|
||||
end
|
||||
|
||||
it "should just return false if :storeconfigs is not enabled" do
|
||||
Puppet.settings.expects(:value).with(:storeconfigs).returns false
|
||||
@collector.evaluate.should be_false
|
||||
end
|
||||
|
||||
it "should use initialize the Rails support if ActiveRecord is not connected" do
|
||||
@compiler.stubs(:resources).returns([])
|
||||
ActiveRecord::Base.expects(:connected?).returns(false)
|
||||
|
@ -375,6 +382,8 @@ describe Puppet::Parser::Collector, "when building its ActiveRecord query for co
|
|||
Puppet::Rails.stubs(:init)
|
||||
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
|
||||
Puppet::Rails::Resource.stubs(:find).returns([])
|
||||
|
||||
Puppet.settings.stubs(:value).with(:storeconfigs).returns true
|
||||
end
|
||||
|
||||
it "should exclude all resources from the host if ActiveRecord contains information for this host" do
|
||||
|
|
Загрузка…
Ссылка в новой задаче