diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-05-12 11:46:17 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-05-12 11:46:17 -0700 |
| commit | 1f438da968e1583d900903407c2e5b17648fa937 (patch) | |
| tree | 8d402af900458792a0cb516b2c903578fb592b7d /lib | |
| parent | e059539a0d7bfc33f80b003894a1a2d807e85851 (diff) | |
| parent | 8f907f21c05295a4e04a55e2d0b287454eea4773 (diff) | |
| download | puppet-1f438da968e1583d900903407c2e5b17648fa937.tar.gz puppet-1f438da968e1583d900903407c2e5b17648fa937.tar.xz puppet-1f438da968e1583d900903407c2e5b17648fa937.zip | |
Merge branch '2.6.next' into 2.6.x
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/application/agent.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/file_serving/fileset.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/indirector/queue.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/parser/compiler.rb | 19 | ||||
| -rw-r--r-- | lib/puppet/parser/resource.rb | 19 | ||||
| -rw-r--r-- | lib/puppet/parser/scope.rb | 4 | ||||
| -rwxr-xr-x | lib/puppet/provider/mount/parsed.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/provider/naginator.rb | 10 | ||||
| -rw-r--r-- | lib/puppet/provider/nameservice/directoryservice.rb | 19 | ||||
| -rwxr-xr-x | lib/puppet/provider/package/aptitude.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/rails/host.rb | 7 | ||||
| -rw-r--r-- | lib/puppet/util/queue.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/util/queue/stomp.rb | 4 |
14 files changed, 65 insertions, 33 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index a9ed2898c..f97d28642 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -59,8 +59,7 @@ module Puppet # configuration parameter access and stuff def self.[](param) - case param - when :debug + if param == :debug return Puppet::Util::Log.level == :debug else return @@settings[param] diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index 9f5921de1..0d67c1a88 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -168,8 +168,8 @@ class Puppet::Application::Agent < Puppet::Application end def setup_listen - unless FileTest.exists?(Puppet[:authconfig]) - Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" + unless FileTest.exists?(Puppet[:rest_authconfig]) + Puppet.err "Will not start without authorization file #{Puppet[:rest_authconfig]}" exit(14) end diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index c020f036d..f29f70a53 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -59,7 +59,7 @@ class Puppet::FileServing::Fileset end def initialize(path, options = {}) - path = path.chomp(File::SEPARATOR) + path = path.chomp(File::SEPARATOR) unless path == File::SEPARATOR raise ArgumentError.new("Fileset paths must be fully qualified") unless File.expand_path(path) == path @path = path diff --git a/lib/puppet/indirector/queue.rb b/lib/puppet/indirector/queue.rb index fd089f431..85ffacacc 100644 --- a/lib/puppet/indirector/queue.rb +++ b/lib/puppet/indirector/queue.rb @@ -36,7 +36,7 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus def save(request) result = nil benchmark :info, "Queued #{indirection.name} for #{request.key}" do - result = client.send_message(queue, request.instance.render(:pson)) + result = client.publish_message(queue, request.instance.render(:pson)) end result rescue => detail diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 6e8e3d26b..98bf3b574 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -56,23 +56,20 @@ class Puppet::Parser::Compiler # Note that this will fail if the resource is not unique. @catalog.add_resource(resource) + if resource.type.to_s.downcase != "class" && resource[:stage] + raise ArgumentError, "Only classes can set 'stage'; normal resources like #{resource} cannot change run stage" + end - # Add our container edge. If we're a class, then we get treated specially - we can - # control the stage that the class is applied in. Otherwise, we just - # get added to our parent container. + # Stages should not be inside of classes. They are always a + # top-level container, regardless of where they appear in the + # manifest. return if resource.type.to_s.downcase == "stage" + # This adds a resource to the class it lexically appears in in the + # manifest. if resource.type.to_s.downcase != "class" - raise ArgumentError, "Only classes can set 'stage'; normal resources like #{resource} cannot change run stage" if resource[:stage] return @catalog.add_edge(scope.resource, resource) end - - unless stage = @catalog.resource(:stage, resource[:stage] || (scope && scope.resource && scope.resource[:stage]) || :main) - raise ArgumentError, "Could not find stage #{resource[:stage] || :main} specified by #{resource}" - end - - resource[:stage] ||= stage.title unless stage.title == :main - @catalog.add_edge(stage, resource) end # Do we use nodes found in the code, vs. the external node sources? diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index c007d4dbe..e4f913013 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -62,13 +62,30 @@ class Puppet::Parser::Resource < Puppet::Resource scope.environment end + # Process the stage metaparameter for a class. A containment edge + # is drawn from the class to the stage. The stage for containment + # defaults to main, if none is specified. + def add_edge_to_stage + return unless self.type.to_s.downcase == "class" + + unless stage = catalog.resource(:stage, self[:stage] || (scope && scope.resource && scope.resource[:stage]) || :main) + raise ArgumentError, "Could not find stage #{self[:stage] || :main} specified by #{self}" + end + + self[:stage] ||= stage.title unless stage.title == :main + catalog.add_edge(stage, self) + end + # Retrieve the associated definition and evaluate it. def evaluate return if evaluated? @evaluated = true if klass = resource_type and ! builtin_type? finish - return klass.evaluate_code(self) + evaluated_code = klass.evaluate_code(self) + add_edge_to_stage + + return evaluated_code elsif builtin? devfail "Cannot evaluate a builtin type (#{type})" else diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 24f1d01f7..c369f129a 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -101,7 +101,7 @@ class Puppet::Parser::Scope # Remove this when rebasing def environment - compiler.environment + compiler ? compiler.environment : nil end # Are we the top scope? @@ -513,6 +513,6 @@ class Puppet::Parser::Scope def extend_with_functions_module extend Puppet::Parser::Functions.environment_module(Puppet::Node::Environment.root) - extend Puppet::Parser::Functions.environment_module(compiler ? environment : nil) + extend Puppet::Parser::Functions.environment_module(environment) end end diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb index 11c5e21a9..7c3f41bbd 100755 --- a/lib/puppet/provider/mount/parsed.rb +++ b/lib/puppet/provider/mount/parsed.rb @@ -18,7 +18,7 @@ Puppet::Type.type(:mount).provide( commands :mountcmd => "mount", :umount => "umount" - case Facter["operatingsystem"] + case Facter.value(:operatingsystem) when "Solaris" @fields = [:device, :blockdevice, :name, :fstype, :pass, :atboot, :options] else diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 5c610fb31..17cc24086 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -30,7 +30,15 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile end def self.to_file(records) - header + records.collect { |record| record.to_s }.join("\n").gsub("_naginator_name", NAME_STRING) + header + records.collect { |record| + # Remap the TYPE_name or _naginator_name params to the + # name if the record is a template (register == 0) + if record.to_s =~ /register\s+0/ + record.to_s.sub("_naginator_name", "name").sub(record.type.to_s + "_name", "name") + else + record.to_s.sub("_naginator_name", NAME_STRING) + end + }.join("\n") end def self.skip_record?(record) diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index b01880360..aab491122 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -235,11 +235,12 @@ class DirectoryService < Puppet::Provider::NameService # have a lot of choice. Ultimately this should all be done using Ruby # to access the DirectoryService APIs directly, but that's simply not # feasible for a while yet. - case self.get_macosx_version_major - when "10.4" - dscl_plist = self.parse_dscl_url_data(dscl_output) - when "10.5", "10.6" + if self.get_macosx_version_major > "10.4" dscl_plist = self.parse_dscl_plist_data(dscl_output) + elsif self.get_macosx_version_major == "10.4" + dscl_plist = self.parse_dscl_url_data(dscl_output) + else + fail("Puppet does not support OS X versions < 10.4") end self.generate_attribute_hash(dscl_plist, *type_properties) @@ -257,12 +258,14 @@ class DirectoryService < Puppet::Provider::NameService # different format for the -url output with objects with spaces in # their values. *sigh*. Use -url for 10.4 in the hope this can be # deprecated one day, and use -plist for 10.5 and higher. - case self.get_macosx_version_major - when "10.4" - command_vector = [ command(:dscl), "-url", "." ] - when "10.5", "10.6" + if self.get_macosx_version_major > "10.4" command_vector = [ command(:dscl), "-plist", "." ] + elsif self.get_macosx_version_major == "10.4" + command_vector = [ command(:dscl), "-url", "." ] + else + fail("Puppet does not support OS X versions < 10.4") end + # JJM: The actual action to perform. See "man dscl" # Common actiosn: -create, -delete, -merge, -append, -passwd command_vector << ds_action diff --git a/lib/puppet/provider/package/aptitude.rb b/lib/puppet/provider/package/aptitude.rb index 8bdf984e6..2eafd3ef8 100755 --- a/lib/puppet/provider/package/aptitude.rb +++ b/lib/puppet/provider/package/aptitude.rb @@ -12,6 +12,7 @@ Puppet::Type.type(:package).provide :aptitude, :parent => :apt, :source => :dpkg args.flatten! # Apparently aptitude hasn't always supported a -q flag. args.delete("-q") if args.include?("-q") + args.delete("--force-yes") if args.include?("--force-yes") output = aptitude(*args) # Yay, stupid aptitude doesn't throw an error when the package is missing. diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb index b9dea2a3d..e5360217c 100644 --- a/lib/puppet/rails/host.rb +++ b/lib/puppet/rails/host.rb @@ -1,3 +1,4 @@ +require 'puppet/node/environment' require 'puppet/rails' require 'puppet/rails/resource' require 'puppet/rails/fact_name' @@ -28,6 +29,12 @@ class Puppet::Rails::Host < ActiveRecord::Base host end + # Override the setter for environment to force it to be a string, lest it + # be YAML encoded. See #4487. + def environment=(value) + super value.to_s + end + # returns a hash of fact_names.name => [ fact_values ] for this host. # Note that 'fact_values' is actually a list of the value instances, not # just actual values. diff --git a/lib/puppet/util/queue.rb b/lib/puppet/util/queue.rb index 02357742a..636bdcf2e 100644 --- a/lib/puppet/util/queue.rb +++ b/lib/puppet/util/queue.rb @@ -30,7 +30,7 @@ require 'puppet/util/instance_loader' # # The client plugins are expected to implement an interface similar to that of Stomp::Client: # * <tt>new</tt> should return a connected, ready-to-go client instance. Note that no arguments are passed in. -# * <tt>send_message(queue, message)</tt> should send the _message_ to the specified _queue_. +# * <tt>publish_message(queue, message)</tt> should publish the _message_ to the specified _queue_. # * <tt>subscribe(queue)</tt> _block_ subscribes to _queue_ and executes _block_ upon receiving a message. # * _queue_ names are simple names independent of the message broker or client library. No "/queue/" prefixes like in Stomp::Client. module Puppet::Util::Queue diff --git a/lib/puppet/util/queue/stomp.rb b/lib/puppet/util/queue/stomp.rb index c18edae6a..cabc56627 100644 --- a/lib/puppet/util/queue/stomp.rb +++ b/lib/puppet/util/queue/stomp.rb @@ -28,8 +28,8 @@ class Puppet::Util::Queue::Stomp end end - def send_message(target, msg) - stomp_client.send(stompify_target(target), msg, :persistent => true) + def publish_message(target, msg) + stomp_client.publish(stompify_target(target), msg, :persistent => true) end def subscribe(target) |
