diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-08-12 13:53:13 -0700 |
---|---|---|
committer | Jesse Wolfe <jes5199@gmail.com> | 2010-08-12 13:53:29 -0700 |
commit | 1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac (patch) | |
tree | 3c6495838d1b876528cb4522de3484c44749140d /lib/puppet/util | |
parent | d5db8db116aff58215ab0feebd7ec02086040f51 (diff) | |
parent | 0f56c1b02d40f1f8552d933dd78b24745937b137 (diff) | |
download | puppet-1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac.tar.gz puppet-1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac.tar.xz puppet-1f3070c4bc77b38e3dd6170cf6a58bee7ec337ac.zip |
Merge branch 'next'
This synchronizes the 2.7 master branch with 2.6.1RC2
Diffstat (limited to 'lib/puppet/util')
-rw-r--r-- | lib/puppet/util/autoload.rb | 22 | ||||
-rwxr-xr-x | lib/puppet/util/command_line/puppetdoc | 10 | ||||
-rwxr-xr-x | lib/puppet/util/command_line/puppetrun | 2 | ||||
-rwxr-xr-x | lib/puppet/util/command_line/ralsh | 26 | ||||
-rw-r--r-- | lib/puppet/util/docs.rb | 17 | ||||
-rw-r--r-- | lib/puppet/util/monkey_patches.rb | 2 | ||||
-rw-r--r-- | lib/puppet/util/nagios_maker.rb | 9 | ||||
-rw-r--r-- | lib/puppet/util/provider_features.rb | 4 | ||||
-rw-r--r-- | lib/puppet/util/reference.rb | 55 |
9 files changed, 50 insertions, 97 deletions
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index c293ac14a..f0dd0a5c5 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -131,11 +131,23 @@ class Puppet::Util::Autoload # We have to require this late in the process because otherwise we might have # load order issues. require 'puppet/node/environment' - Puppet::Node::Environment.new(env).modulepath.collect do |dir| - Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| File.join(dir, f) } - end.flatten.collect { |d| [File.join(d, "plugins"), File.join(d, "lib")] }.flatten.find_all do |d| - FileTest.directory?(d) - end + + real_env = Puppet::Node::Environment.new(env) + + # We're using a per-thread cache of said module directories, so that + # we don't scan the filesystem each time we try to load something with + # this autoload instance. But since we don't want to cache for the eternity + # this env_module_directories gets reset after the compilation on the master. + # This is also reset after an agent ran. + # One of the side effect of this change is that this module directories list will be + # shared among all autoload that we have running at a time. But that won't be an issue + # as by definition those directories are shared by all autoload. + Thread.current[:env_module_directories] ||= {} + Thread.current[:env_module_directories][real_env] ||= real_env.modulepath.collect do |dir| + Dir.entries(dir).reject { |f| f =~ /^\./ }.collect { |f| File.join(dir, f) } + end.flatten.collect { |d| [File.join(d, "plugins"), File.join(d, "lib")] }.flatten.find_all do |d| + FileTest.directory?(d) + end end def search_directories(env=nil) diff --git a/lib/puppet/util/command_line/puppetdoc b/lib/puppet/util/command_line/puppetdoc index d9bbbec33..0fa1830d6 100755 --- a/lib/puppet/util/command_line/puppetdoc +++ b/lib/puppet/util/command_line/puppetdoc @@ -8,15 +8,15 @@ # # = Usage # -# puppet doc [-a|--all] [-h|--help] [-o|--outputdir <rdoc outputdir>] [-m|--mode <text|pdf|markdown|trac|rdoc>] +# puppet doc [-a|--all] [-h|--help] [-o|--outputdir <rdoc outputdir>] [-m|--mode <text|pdf|rdoc>] # [-r|--reference <[type]|configuration|..>] [--charset CHARSET] [manifest-file] # # = Description # -# If mode is not 'rdoc', then this command generates a restructured-text document describing all installed +# If mode is not 'rdoc', then this command generates a Markdown document describing all installed # Puppet types or all allowable arguments to puppet executables. It is largely # meant for internal use and is used to generate the reference document -# available on the Reductive Labs web site. +# available on the Puppet Labs web site. # # In 'rdoc' mode, this command generates an html RDoc hierarchy describing the manifests that # are in 'manifestdir' and 'modulepath' configuration directives. @@ -37,7 +37,7 @@ # Specifies the directory where to output the rdoc documentation in 'rdoc' mode. # # mode:: -# Determine the output mode. Valid modes are 'text', 'trac', 'pdf', 'markdown' and 'rdoc'. The 'pdf' and 'markdown' modes create PDF or Markdown formatted files in the /tmp directory. Note that 'trac' mode only works on Reductive Labs servers. The default mode is 'text'. In 'rdoc' mode you must provide 'manifests-path' +# Determine the output mode. Valid modes are 'text', 'trac', 'pdf' and 'rdoc'. The 'pdf' mode creates PDF formatted files in the /tmp directory. The default mode is 'text'. In 'rdoc' mode you must provide 'manifests-path' # # reference:: # Build a particular reference. Get a list of references by running +puppet doc --list+. @@ -53,7 +53,7 @@ # or # $ puppet doc /etc/puppet/manifests/site.pp # or -# $ puppet doc -m markdown -r configuration +# $ puppet doc -m pdf -r configuration # # = Author # diff --git a/lib/puppet/util/command_line/puppetrun b/lib/puppet/util/command_line/puppetrun index ee95c47eb..27cd775b9 100755 --- a/lib/puppet/util/command_line/puppetrun +++ b/lib/puppet/util/command_line/puppetrun @@ -54,8 +54,6 @@ # This is what you would install on your Puppet master; non-master hosts could # leave off the 'fileserver' and 'puppetmaster' namespaces. # -# Expect more documentation on this eventually. -# # = Options # # Note that any configuration parameter that's valid in the configuration file diff --git a/lib/puppet/util/command_line/ralsh b/lib/puppet/util/command_line/ralsh index 68ad92d84..83338fcbc 100755 --- a/lib/puppet/util/command_line/ralsh +++ b/lib/puppet/util/command_line/ralsh @@ -59,23 +59,23 @@ # types: # List all available types. # -# verbose:: +# verbose: # Print extra information. # # = Example # -# This example uses ``puppet resource`` to return Puppet configuration for the user ``luke``:: -# -# $ puppet resource user luke -# user { 'luke': -# home => '/home/luke', -# uid => '100', -# ensure => 'present', -# comment => 'Luke Kanies,,,', -# gid => '1000', -# shell => '/bin/bash', -# groups => ['sysadmin','audio','video','puppet'] -# } +# This example uses `puppet resource` to return Puppet configuration for the user `luke`: +# +# $ puppet resource user luke +# user { 'luke': +# home => '/home/luke', +# uid => '100', +# ensure => 'present', +# comment => 'Luke Kanies,,,', +# gid => '1000', +# shell => '/bin/bash', +# groups => ['sysadmin','audio','video','puppet'] +# } # # = Author # diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb index efd054d85..4344d67ab 100644 --- a/lib/puppet/util/docs.rb +++ b/lib/puppet/util/docs.rb @@ -47,25 +47,19 @@ module Puppet::Util::Docs lengths[i] = value.to_s.length if value.to_s.length > lengths[i] end - # Add the top header row - str += lengths.collect { |num| "=" * num }.join(" ") + "\n" + # Add the header names + str += headers.zip(lengths).collect { |value, num| pad(value, num) }.join(" | ") + " |" + "\n" - # And the header names - str += headers.zip(lengths).collect { |value, num| pad(value, num) }.join(" ") + "\n" - - # And the second header row - str += lengths.collect { |num| "=" * num }.join(" ") + "\n" + # And the header row + str += lengths.collect { |num| "-" * num }.join(" | ") + " |" + "\n" # Now each data row data.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |name, rows| str += [name, rows].flatten.zip(lengths).collect do |value, length| pad(value, length) - end.join(" ") + "\n" + end.join(" | ") + " |" + "\n" end - # And the bottom line row - str += lengths.collect { |num| "=" * num }.join(" ") + "\n" - str + "\n" end @@ -111,4 +105,3 @@ module Puppet::Util::Docs module_function :scrub end - diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb index 9664ff310..6b5af8350 100644 --- a/lib/puppet/util/monkey_patches.rb +++ b/lib/puppet/util/monkey_patches.rb @@ -25,7 +25,7 @@ end [Object, Exception, Integer, Struct, Date, Time, Range, Regexp, Hash, Array, Float, String, FalseClass, TrueClass, Symbol, NilClass, Class].each { |cls| cls.class_eval do - def to_yaml + def to_yaml(ignored=nil) ZAML.dump(self) end end diff --git a/lib/puppet/util/nagios_maker.rb b/lib/puppet/util/nagios_maker.rb index 59ed820f9..863fe24fa 100644 --- a/lib/puppet/util/nagios_maker.rb +++ b/lib/puppet/util/nagios_maker.rb @@ -45,17 +45,16 @@ module Puppet::Util::NagiosMaker provider.nagios_type type.desc "The Nagios type #{name.to_s}. This resource type is autogenerated using the - model developed in Naginator_, and all of the Nagios types are generated using the + model developed in Naginator, and all of the Nagios types are generated using the same code and the same library. This type generates Nagios configuration statements in Nagios-parseable configuration - files. By default, the statements will be added to ``#{target}``, but - you can send them to a different file by setting their ``target`` attribute. + files. By default, the statements will be added to `#{target}`, but + you can send them to a different file by setting their `target` attribute. - You can purge Nagios resources using the ``resources`` type, but *only* + You can purge Nagios resources using the `resources` type, but *only* in the default file locations. This is an architectural limitation. - .. _naginator: http://projects.reductivelabs.com/projects/naginator " end end diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb index ac294d20d..30e8dcb39 100644 --- a/lib/puppet/util/provider_features.rb +++ b/lib/puppet/util/provider_features.rb @@ -72,7 +72,7 @@ module Puppet::Util::ProviderFeatures names = @features.keys.sort { |a,b| a.to_s <=> b.to_s } names.each do |name| doc = @features[name].docs.gsub(/\n\s+/, " ") - str += "- **#{name}**: #{doc}\n" + str += "- *#{name}*: #{doc}\n" end if providers.length > 0 @@ -83,7 +83,7 @@ module Puppet::Util::ProviderFeatures prov = provider(provname) names.each do |name| if prov.feature?(name) - data[provname] << "**X**" + data[provname] << "*X*" else data[provname] << "" end diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb index 62bab643e..4f2058e69 100644 --- a/lib/puppet/util/reference.rb +++ b/lib/puppet/util/reference.rb @@ -15,7 +15,7 @@ class Puppet::Util::Reference end def self.modes - %w{pdf trac text markdown} + %w{pdf text} end def self.newreference(name, options = {}, &block) @@ -32,7 +32,7 @@ class Puppet::Util::Reference section = reference(name) or raise "Could not find section #{name}" depth = section.depth if section.depth < depth end - text = ".. contents:: :depth: 2\n\n" + text = "{:toc}\n\n" end def self.pdf(text) @@ -67,32 +67,6 @@ class Puppet::Util::Reference end - def self.markdown(name, text) - puts "Creating markdown for #{name} reference." - dir = "/tmp/#{Puppet::PUPPETVERSION}" - FileUtils.mkdir(dir) unless File.directory?(dir) - Puppet::Util.secure_open(dir + "/#{name}.rst", "w") do |f| - f.puts text - end - pandoc = %x{which pandoc} - if $CHILD_STATUS != 0 or pandoc =~ /no / - pandoc = %x{which pandoc} - end - if $CHILD_STATUS != 0 or pandoc =~ /no / - raise "Could not find pandoc" - end - pandoc.chomp! - cmd = %{#{pandoc} -s -r rst -w markdown #{dir}/#{name}.rst -o #{dir}/#{name}.mdwn} - output = %x{#{cmd}} - unless $CHILD_STATUS == 0 - $stderr.puts "Pandoc failed to create #{name} reference." - $stderr.puts output - exit(1) - end - - File.unlink(dir + "/#{name}.rst") - end - def self.references instance_loader(:reference).loadall loaded_instances(:reference).sort { |a,b| a.to_s <=> b.to_s } @@ -167,7 +141,7 @@ class Puppet::Util::Reference # First the header text = h(@title, 1) text += "\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on #{Time.now.to_s})*\n\n" - text += ".. contents:: :depth: #{@depth}\n\n" if withcontents + text += "{:toc}\n\n" if withcontents text += @header @@ -181,27 +155,4 @@ class Puppet::Util::Reference def to_text(withcontents = true) strip_trac(to_rest(withcontents)) end - - def to_trac(with_contents = true) - "{{{\n#!rst\n#{self.to_rest(with_contents)}\n}}}" - end - - def trac - Puppet::Util.secure_open("/tmp/puppetdoc.txt", "w") do |f| - f.puts self.to_trac - end - - puts "Writing #{@name} reference to trac as #{@page}" - cmd = %{sudo trac-admin /opt/rl/trac/puppet wiki import %s /tmp/puppetdoc.txt} % self.page - output = %x{#{cmd}} - unless $CHILD_STATUS == 0 - $stderr.puts "trac-admin failed" - $stderr.puts output - exit(1) - end - unless output =~ /^\s+/ - $stderr.puts output - end - end end - |