diff options
author | Luke Kanies <luke@madstop.com> | 2009-04-06 19:12:04 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-04-22 14:39:35 +1000 |
commit | 863c50b1273a7fa48d74fb74948938214b45967c (patch) | |
tree | 34252abdb4e5378740b69967f983f70a7e28d2ee | |
parent | a137146562fecc909afe7fc81f0033fccbb36393 (diff) | |
download | puppet-863c50b1273a7fa48d74fb74948938214b45967c.tar.gz puppet-863c50b1273a7fa48d74fb74948938214b45967c.tar.xz puppet-863c50b1273a7fa48d74fb74948938214b45967c.zip |
Switching to Indirected ActiveRecord
This is mostly a configuration change, with some
code getting removed.
Also adding an extra require in Format;
Puppet::Provider requires Puppet::Provider::Confiner,
so the constant lookup is weird.
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r-- | lib/puppet/defaults.rb | 22 | ||||
-rw-r--r-- | lib/puppet/network/format.rb | 1 | ||||
-rw-r--r-- | lib/puppet/parser/compiler.rb | 37 | ||||
-rw-r--r-- | lib/puppet/resource/catalog.rb | 1 | ||||
-rwxr-xr-x | spec/unit/parser/compiler.rb | 21 |
5 files changed, 20 insertions, 62 deletions
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 9ec26edf3..ac7281356 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -515,10 +515,7 @@ module Puppet :graph => [false, "Whether to create dot graph files for the different configuration graphs. These dot files can be interpreted by tools like OmniGraffle or dot (which is part of ImageMagick)."], - :graphdir => ["$statedir/graphs", "Where to store dot-outputted graphs."], - :storeconfigs => [false, - "Whether to store each client's configuration. This - requires ActiveRecord from Ruby on Rails."] + :graphdir => ["$statedir/graphs", "Where to store dot-outputted graphs."] ) # Plugin information. @@ -680,6 +677,23 @@ module Puppet branch under your main directory."] ) + setdefaults(:puppetmasterd, + :storeconfigs => {:default => false, :desc => "Whether to store each client's configuration. This + requires ActiveRecord from Ruby on Rails.", + :call_on_define => true, # Call our hook with the default value, so we always get the libdir set. + :hook => proc do |value| + require 'puppet/node' + require 'puppet/node/facts' + require 'puppet/resource/catalog' + if value + Puppet::Node::Catalog.cache_class = :active_record + Puppet::Node::Facts.cache_class = :active_record + Puppet::Node.cache_class = :active_record + end + end + } + ) + # This doesn't actually work right now. setdefaults(:parser, :lexical => [false, "Whether to use lexical scoping (vs. dynamic)."], diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb index 21aead7cc..db9458ee3 100644 --- a/lib/puppet/network/format.rb +++ b/lib/puppet/network/format.rb @@ -1,3 +1,4 @@ +require 'puppet/provider' require 'puppet/provider/confiner' # A simple class for modeling encoding formats for moving diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 7dcd50270..968e0b979 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -97,10 +97,6 @@ class Puppet::Parser::Compiler fail_on_unevaluated() - if Puppet[:storeconfigs] - store() - end - return @catalog end @@ -424,39 +420,6 @@ class Puppet::Parser::Compiler end end - # Store the catalog into the database. - def store - unless Puppet.features.rails? - raise Puppet::Error, - "storeconfigs is enabled but rails is unavailable" - end - - unless ActiveRecord::Base.connected? - Puppet::Rails.connect - end - - # We used to have hooks here for forking and saving, but I don't - # think it's worth retaining at this point. - store_to_active_record(@node, resources) - end - - # Do the actual storage. - def store_to_active_record(node, resources) - begin - # We store all of the objects, even the collectable ones - benchmark(:info, "Stored catalog for #{node.name}") do - Puppet::Rails::Host.transaction do - Puppet::Rails::Host.store(node, resources) - end - end - rescue => detail - if Puppet[:trace] - puts detail.backtrace - end - Puppet.err "Could not store configs: %s" % detail.to_s - end - end - # Return an array of all of the unevaluated resources. These will be definitions, # which need to get evaluated into native resources. def unevaluated_resources diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index cb0ce0333..32fbc38d6 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -1,3 +1,4 @@ +require 'puppet/node' require 'puppet/indirector' require 'puppet/simple_graph' require 'puppet/transaction' diff --git a/spec/unit/parser/compiler.rb b/spec/unit/parser/compiler.rb index 855a8c723..cf5ad086a 100755 --- a/spec/unit/parser/compiler.rb +++ b/spec/unit/parser/compiler.rb @@ -502,27 +502,6 @@ describe Puppet::Parser::Compiler do end end - describe Puppet::Parser::Compiler, "when storing compiled resources" do - confine "Cannot test Rails integration without ActiveRecord" => Puppet.features.rails? - - it "should store the resources" do - Puppet.features.expects(:rails?).returns(true) - Puppet::Rails.expects(:connect) - - @compiler.expects(:resources).returns(:resources) - - @compiler.expects(:store_to_active_record).with(@node, :resources) - @compiler.send(:store) - end - - it "should store to active_record" do - @node.expects(:name).returns("myname") - Puppet::Rails::Host.stubs(:transaction).yields - Puppet::Rails::Host.expects(:store).with(@node, :resources) - @compiler.send(:store_to_active_record, @node, :resources) - end - end - describe Puppet::Parser::Compiler, "when managing resource overrides" do before do |