diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-11-05 20:20:35 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-11-07 08:32:28 +1100 |
commit | cb3e5e10d76a4a0f44e16c5bf36c69b65ae18fbb (patch) | |
tree | 869867dd7b98a36a08e30cac9c941fa59b9a6c77 | |
parent | ff23b5762532ef9bec84f0ad5cb32c807e048b90 (diff) | |
download | puppet-cb3e5e10d76a4a0f44e16c5bf36c69b65ae18fbb.tar.gz puppet-cb3e5e10d76a4a0f44e16c5bf36c69b65ae18fbb.tar.xz puppet-cb3e5e10d76a4a0f44e16c5bf36c69b65ae18fbb.zip |
Fix #2787 - Storeconfig doesn't store/update node ip and environment anymore
Since the storeconfig refactoring (ie moving the catalog storeconfig
system under the indirector) in 0.25 we lost the capability to
store the node ip and node environment name.
This patch restores this feature.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
-rw-r--r-- | lib/puppet/indirector/catalog/active_record.rb | 5 | ||||
-rwxr-xr-x | spec/unit/indirector/catalog/active_record.rb | 21 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/puppet/indirector/catalog/active_record.rb b/lib/puppet/indirector/catalog/active_record.rb index e3b56ece6..575ce72fb 100644 --- a/lib/puppet/indirector/catalog/active_record.rb +++ b/lib/puppet/indirector/catalog/active_record.rb @@ -30,6 +30,11 @@ class Puppet::Resource::Catalog::ActiveRecord < Puppet::Indirector::ActiveRecord host.merge_resources(catalog.vertices) host.last_compile = Time.now + if node = Puppet::Node.find(catalog.name) + host.ip = node.parameters["ipaddress"] + host.environment = node.environment + end + host.save end end diff --git a/spec/unit/indirector/catalog/active_record.rb b/spec/unit/indirector/catalog/active_record.rb index 463552f55..8678dd6b3 100755 --- a/spec/unit/indirector/catalog/active_record.rb +++ b/spec/unit/indirector/catalog/active_record.rb @@ -76,9 +76,12 @@ describe "Puppet::Resource::Catalog::ActiveRecord" do describe "when saving an instance" do before do - @host = stub 'host', :name => "foo", :save => nil, :merge_resources => nil, :last_compile= => nil + @host = stub 'host', :name => "foo", :save => nil, :merge_resources => nil, :last_compile= => nil, :ip= => nil, :environment= => nil @host.stubs(:railsmark).yields + @node = stub_everything 'node', :parameters => {} + Puppet::Node.stubs(:find).returns(@node) + Puppet::Rails::Host.stubs(:find_by_name).returns @host @catalog = Puppet::Resource::Catalog.new("foo") @request = stub 'request', :key => "foo", :instance => @catalog @@ -105,6 +108,22 @@ describe "Puppet::Resource::Catalog::ActiveRecord" do @terminus.save(@request) end + it "should set host ip if we could find a matching node" do + @node.stubs(:parameters).returns({"ipaddress" => "192.168.0.1"}) + + @host.expects(:ip=).with '192.168.0.1' + + @terminus.save(@request) + end + + it "should set host environment if we could find a matching node" do + @node.stubs(:environment).returns("myenv") + + @host.expects(:environment=).with 'myenv' + + @terminus.save(@request) + end + it "should set the last compile time on the host" do now = Time.now Time.expects(:now).returns now |