summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-11 17:32:21 -0600
committerLuke Kanies <luke@madstop.com>2007-12-11 17:32:21 -0600
commit690e2872864a8a46710445ab07c7d9afa33d0afc (patch)
treedb3347ad6403c124b788866946e5106bc269fb97
parentf1169ee7cd05003de67070f193e70255706d95cb (diff)
downloadpuppet-690e2872864a8a46710445ab07c7d9afa33d0afc.tar.gz
puppet-690e2872864a8a46710445ab07c7d9afa33d0afc.tar.xz
puppet-690e2872864a8a46710445ab07c7d9afa33d0afc.zip
This should be the last fix for exported resources.
Hosts were keeping the export bit on all resources, even when they'd collected another host's resources, which caused a duplicate copy that was still exported.
-rw-r--r--lib/puppet/parser/collector.rb2
-rwxr-xr-xspec/unit/parser/collector.rb21
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index 63eb87896..b8165a84f 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -147,6 +147,8 @@ class Puppet::Parser::Collector
end
resource = obj.to_resource(self.scope)
+
+ resource.exported = false
scope.compile.store_resource(scope, resource)
diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb
index 450176f30..9b5eab1f4 100755
--- a/spec/unit/parser/collector.rb
+++ b/spec/unit/parser/collector.rb
@@ -296,6 +296,27 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do
@collector.evaluate.should == [resource]
end
+ # This way one host doesn't store another host's resources as exported.
+ it "should mark resources collected from the database as not exported" do
+ stub_rails()
+ Puppet::Rails::Host.stubs(:find_by_name).returns(nil)
+
+ one = stub 'one', :restype => "Mytype", :title => "one", :virtual? => true, :exported? => true
+ Puppet::Rails::Resource.stubs(:find).returns([one])
+
+ resource = mock 'resource'
+ one.expects(:to_resource).with(@scope).returns(resource)
+ resource.expects(:exported=).with(false)
+ resource.stubs(:virtual=)
+
+ @compile.stubs(:resources).returns([])
+ @scope.stubs(:findresource).returns(nil)
+
+ @compile.stubs(:store_resource)
+
+ @collector.evaluate
+ end
+
it "should fail if an equivalent resource already exists in the compile" do
stub_rails()
Puppet::Rails::Host.stubs(:find_by_name).returns(nil)