diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-10 04:17:07 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-07-10 04:17:07 +0000 |
commit | e662c869bf8b2924c12d4ff6f999f0744779257d (patch) | |
tree | b57a7c661f3a6179c0a13b0b155142064062141a | |
parent | 7befe1bc5ac9d4524c4c43514a24f1bb19b74727 (diff) | |
download | puppet-e662c869bf8b2924c12d4ff6f999f0744779257d.tar.gz puppet-e662c869bf8b2924c12d4ff6f999f0744779257d.tar.xz puppet-e662c869bf8b2924c12d4ff6f999f0744779257d.zip |
Fixing #621 -- plugins are now downloaded directly into the $libdir, and autoload looks for them there. You can now easily download any reloadable file to your clients.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2669 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | CHANGELOG | 7 | ||||
-rw-r--r-- | lib/puppet/configuration.rb | 6 | ||||
-rw-r--r-- | lib/puppet/network/client/master.rb | 12 | ||||
-rwxr-xr-x | test/network/client/master.rb | 51 |
4 files changed, 31 insertions, 45 deletions
@@ -1,3 +1,10 @@ + The configuration client now pulls libraries down to $libdir, + and all autoloading is done from there with full support + for any reloadable file, such as types and providers. (#621) + Note that this is not backward compatible -- if you're using + pluginsync right now, you'll need to disable it on your clients + until you can upgrade them. + The Rails log level can now be set via (shockingly!) the 'rails_loglevel' parameter (#710). Note that this isn't exactly the feature asked for, but I could not find a diff --git a/lib/puppet/configuration.rb b/lib/puppet/configuration.rb index 1589fc01b..79ada647b 100644 --- a/lib/puppet/configuration.rb +++ b/lib/puppet/configuration.rb @@ -436,8 +436,10 @@ module Puppet self.setdefaults(:main, :pluginpath => ["$vardir/plugins", "Where Puppet should look for plugins. Multiple directories should - be colon-separated, like normal PATH variables."], - :plugindest => ["$vardir/plugins", + be colon-separated, like normal PATH variables. As of 0.23.1, this + option is deprecated; download your custom libraries to the $libdir + instead."], + :plugindest => ["$libdir", "Where Puppet should store plugins that it pulls down from the central server."], :pluginsource => ["puppet://$server/plugins", diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 8d141f33f..0ac81c055 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -454,18 +454,20 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # Retrieve the plugins from the central server. We only have to load the # changed plugins, because Puppet::Type loads plugins on demand. def self.getplugins - path = Puppet[:pluginpath].split(":") download(:dest => Puppet[:plugindest], :source => Puppet[:pluginsource], :ignore => Puppet[:pluginsignore], :name => "plugin") do |object| - next unless path.include?(::File.dirname(object[:path])) + next if FileTest.directory?(object[:path]) + path = object[:path].sub(Puppet[:plugindest], '').sub(/^\/+/, '') + unless Puppet::Util::Autoload.loaded?(path) + next + end begin - Puppet.info "Reloading plugin %s" % - ::File.basename(::File.basename(object[:path])).sub(".rb",'') + Puppet.info "Reloading downloaded file %s" % path load object[:path] rescue => detail - Puppet.warning "Could not reload plugin %s: %s" % + Puppet.warning "Could not reload downloaded file %s: %s" % [object[:path], detail] end end diff --git a/test/network/client/master.rb b/test/network/client/master.rb index 89de171db..78a1a0a11 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -264,63 +264,38 @@ class TestMasterClient < Test::Unit::TestCase Puppet[:filetimeout] = -1 Puppet[:pluginsource] = tempfile() Dir.mkdir(Puppet[:pluginsource]) + Dir.mkdir(File.join(Puppet[:pluginsource], "testing")) - myplugin = File.join(Puppet[:pluginsource], "myplugin.rb") + $loaded = [] + loader = Puppet::Util::Autoload.new(self, "testing") + + myplugin = File.join(Puppet[:pluginsource], "testing", "myplugin.rb") File.open(myplugin, "w") do |f| - f.puts %{Puppet::Type.newtype(:myplugin) do - newparam(:argument) do - isnamevar - end -end -} + f.puts %{$loaded << :myplugin} end - assert_nothing_raised { + assert_nothing_raised("Could not get plugins") { Puppet::Network::Client.master.getplugins } - destfile = File.join(Puppet[:plugindest], "myplugin.rb") + destfile = File.join(Puppet[:plugindest], "testing", "myplugin.rb") assert(File.exists?(destfile), "Did not get plugin") - obj = Puppet::Type.type(:myplugin) + assert(loader.load(:myplugin), "Did not load downloaded plugin") - assert(obj, "Did not define type") - - assert(obj.validattr?(:argument), - "Did not get namevar") + assert($loaded.include?(:myplugin), "Downloaded code was not evaluated") # Now modify the file and make sure the type is replaced File.open(myplugin, "w") do |f| - f.puts %{Puppet::Type.newtype(:myplugin) do - newparam(:yayness) do - isnamevar - end - - newparam(:rahness) do - end -end -} + f.puts %{$loaded << :changed} end - assert_nothing_raised { + assert_nothing_raised("Could not get plugin changes") { Puppet::Network::Client.master.getplugins } - destfile = File.join(Puppet[:pluginpath], "myplugin.rb") - - obj = Puppet::Type.type(:myplugin) - - assert(obj, "Did not define type") - - assert(obj.validattr?(:yayness), - "Did not get namevar") - - assert(obj.validattr?(:rahness), - "Did not get other var") - - assert(! obj.validattr?(:argument), - "Old namevar is still valid") + assert($loaded.include?(:changed), "Changed code was not evaluated") # Now try it again, to make sure we don't have any objects lying around assert_nothing_raised { |