Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account
List archives

PATCH/puppet 1/1] [#4247] storeconfigs was calling Puppet::Parser::Resource.new with the wrong arguments

Re: plugins with connection pool needs
(63 lines)
PATCH/puppet 1/1] Minimal fix for #4243 -- import isn't thread safe
(13 lines)
Jul 15, 2010
Jesse Wolfe
Jesse Wolfe
When the interface to Puppet::Resource changed, its subclass
Puppet::Parser::Resource was also affected. One case of initializing
those objects did not get updated when the code changed, causing
storeconfigs to break.

Also, this patch adds a error message that would have made it easier to
catch this problem (as puppet could consume all memory and die trying to
print the old error message)

Signed-off-by: Jesse Wolfe <jes5### @gmail.com>
---
 lib/puppet/rails/resource.rb     |    6 +++---
 lib/puppet/resource.rb           |    3 +++
 spec/unit/rails/resource_spec.rb |   16 ++++++++++++++++
 spec/unit/resource_spec.rb       |    6 ++++++
 4 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb
index a5cdd0c..cac9de2 100644
--- a/lib/puppet/rails/resource.rb
+++ b/lib/puppet/rails/resource.rb
@@ -212,16 +212,16 @@ class Puppet::Rails::Resource <
ActiveRecord::Base
     end
     hash[:scope] = scope
     hash[:source] = scope.source
-    hash[:params] = []
+    hash[:parameters] = []
     names = []
     self.param_names.each do |pname|
       # We can get the same name multiple times because of how the
       # db layout works.
       next if names.include?(pname.name)
       names << pname.name
-      hash[:params] << pname.to_resourceparam(self, scope.source)
+      hash[:parameters] << pname.to_resourceparam(self,
scope.source)
     end
-    obj = Puppet::Parser::Resource.new(hash)
+    obj = Puppet::Parser::Resource.new(hash["type"], hash["title"], hash)
 
     # Store the ID, so we can check if we're re-collecting the same
resource.
     obj.rails_id = self.id
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 31237e3..d68e0ee 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -409,6 +409,9 @@ class Puppet::Resource
     if    (argtitle || argtype) =~ /^([^\[\]]+)\[(.+)\]$/m then [ $1,    
            $2            ]
     elsif argtitle                                         then [
argtype,            argtitle      ]
     elsif argtype.is_a?(Puppet::Type)                      then [
argtype.class.name, argtype.title ]
+    elsif argtype.is_a?(Hash)                              then
+      raise ArgumentError, "Puppet::Resource.new does not take a hash as
the first argument. "+
+        "Did you mean (#{(argtype[:type] || argtype["type"]).inspect},
#{(argtype[:title] || argtype["title"]).inspect }) ?"
     else raise ArgumentError, "No title provided and #{argtype.inspect}
is not a valid resource reference"
     end
   end
diff --git a/spec/unit/rails/resource_spec.rb
b/spec/unit/rails/resource_spec.rb
index ac74693..08deda6 100755
--- a/spec/unit/rails/resource_spec.rb
+++ b/spec/unit/rails/resource_spec.rb
@@ -104,4 +104,20 @@ describe "Puppet::Rails::Resource" do
       @resource.merge_parameters(merge_resource)
     end
   end
+
+  describe "#to_resource" do
+    it "should instantiate a Puppet::Parser::Resource" do
+      scope = stub "scope", :source => nil
+
+      @resource = Puppet::Rails::Resource.new
+      @resource.stubs(:attributes).returns({
+        "restype" => 'notify',
+        "title"   => 'hello'
+      })
+      @resource.stubs(:param_names).returns([])
+
+      @resource.to_resource(scope).should be_a(Puppet::Parser::Resource)
+
+    end
+  end
 end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 95f0dd0..204a2b0 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -98,6 +98,12 @@ describe Puppet::Resource do
     lambda { Puppet::Resource.new("foo") }.should
raise_error(ArgumentError)
   end
 
+  it "should fail if the title is a hash and the type is not a valid
resource reference string" do
+    lambda { Puppet::Resource.new({:type => "foo", :title =>
"bar"}) }.should raise_error(ArgumentError,
+      'Puppet::Resource.new does not take a hash as the first argument.
Did you mean ("foo", "bar") ?'
+    )
+  end
+
   it "should be able to produce a backward-compatible reference array" do
     Puppet::Resource.new("foobar", "/f").to_trans_ref.should == %w{Foobar
/f}
   end






Reply
Tags: changedaddspatchbreak
Similar Threads
PATCH/puppet 1/1] Fixed #4275 - Added parser call to extlookup for 2.6.x
Signed-off-by: James Turnbull <jam### @lovedthanlost.net>
---
 ext/extlookup.rb |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/ext/extlookup.rb b/ext/extlookup.rb
index d87583b..81e6a4b 100644
--- a/ext/extlookup.rb
+++ b/ext/extlookup.rb
@@ -125,6 +125,8 @@ module Puppet::Parser::Functions
 
     desired = "_ExtUNSET_"
 
+    parser = Puppet::Parser::Parser.new(environment)
+
     datafiles.each do |file|
       parser.watch_file(file) if File.exists?(file)
 






PATCH/puppet 1/1] [#4149] Don't create two Resource::TypeCollections
By asking the environment for known resources instead of creating a type
collection ourselves, we avoid accidentally creating two
Resource::TypeCollection objects.

Signed-off-by: Jesse Wolfe <jes5### @gmail.com>
---
 lib/puppet/application/apply.rb  |    2 +-
 lib/puppet/application/master.rb |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/puppet/application/apply.rb
b/lib/puppet/application/apply.rb
index 8909939..1814858 100644
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@ -67,7 +67,7 @@ class Puppet::Application::Apply <
Puppet::Application
             Puppet[:manifest] = command_line.args.shift
         end
         begin
-           
Puppet::Resource::TypeCollection.new(Puppet[:environment]).perform_initial_import
+           
Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types
         rescue => detail
             Puppet.err detail
             exit 1
diff --git a/lib/puppet/application/master.rb
b/lib/puppet/application/master.rb
index fdcd7d3..484ec08 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -67,7 +67,7 @@ class Puppet::Application::Master <
Puppet::Application
 
     def parseonly
         begin
-           
Puppet::Resource::TypeCollection.new(Puppet[:environment]).perform_initial_import
+           
Puppet::Node::Environment.new(Puppet[:environment]).known_resource_types
         rescue => detail
             Puppet.err detail
             exit 1






PATCH/puppet 2/2] Update RDoc parser to reflect change of custom plugin and fact locations
Signed-off-by: James Turnbull <jam### @lovedthanlost.net>
---
 lib/puppet/util/rdoc/parser.rb     |    2 +-
 spec/unit/util/rdoc/parser_spec.rb |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/puppet/util/rdoc/parser.rb
b/lib/puppet/util/rdoc/parser.rb
index 0693c44..9c86ec3 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -82,7 +82,7 @@ class Parser
         # find a module
         fullpath = File.expand_path(path)
         Puppet.debug "rdoc: testing %s" % fullpath
-        if fullpath =~
/(.*)\/([^\/]+)\/(?:manifests|plugins)\/.+\.(pp|rb)$/
+        if fullpath =~
/(.*)\/([^\/]+)\/(?:manifests|plugins|lib)\/.+\.(pp|rb)$/
             modpath = $1
             name = $2
             Puppet.debug "rdoc: module %s into %s ?" % [name, modpath]
diff --git a/spec/unit/util/rdoc/parser_spec.rb
b/spec/unit/util/rdoc/parser_spec.rb
index 7113b95..d30c0c1 100755
--- a/spec/unit/util/rdoc/parser_spec.rb
+++ b/spec/unit/util/rdoc/parser_spec.rb
@@ -109,7 +109,7 @@ describe RDoc::Parser do
         end
 
         it "should defer plugins parsing to parse_plugins for this
module" do
-            @parser.input_file_name =
"module/plugins/puppet/parser/function.rb"
+            @parser.input_file_name =
"module/lib/puppet/parser/function.rb"
 
             @parser.expects(:parse_plugins).with(@module)
 
@@ -462,14 +462,14 @@ describe RDoc::Parser do
         end
 
         it "should delegate parsing custom facts to parse_facts" do
-            @parser = RDoc::Parser.new(@top_level,
"module/manifests/plugins/puppet/facter/test.rb", nil, Options.instance,
RDoc::Stats.new)
+            @parser = RDoc::Parser.new(@top_level,
"module/manifests/lib/puppet/facter/test.rb", nil, Options.instance,
RDoc::Stats.new)
 
             @parser.expects(:parse_fact).with(@container)
             @parser.parse_plugins(@container)
         end
 
         it "should delegate parsing plugins to parse_plugins" do
-            @parser = RDoc::Parser.new(@top_level,
"module/manifests/plugins/puppet/functions/test.rb", nil, Options.instance,
RDoc::Stats.new)
+            @parser = RDoc::Parser.new(@top_level,
"module/manifests/lib/puppet/functions/test.rb", nil, Options.instance,
RDoc::Stats.new)
 
             @parser.expects(:parse_puppet_plugin).with(@container)
             @parser.parse_plugins(@container)






PATCH/puppet 1/1] [#4233] Ruby regexps are not multiline by default, but Resource titles can be mul
Puppet allows resource titles to contain newlines. We recently
introduced several regexps that were failing on resources with multiline
titles.

Signed-off-by: Jesse Wolfe <jes### @gmail.com>
---
 lib/puppet/resource/catalog.rb     |    2 +-
 lib/puppet/type.rb                 |    2 +-
 lib/puppet/type/file.rb            |    2 +-
 spec/unit/resource/catalog_spec.rb |    9 +++++++++
 spec/unit/type/file_spec.rb        |   14 ++++++++++++++
 spec/unit/type_spec.rb             |   21 +++++++++++++++++++++
 6 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/resource/catalog.rb
b/lib/puppet/resource/catalog.rb
index d163fc1..4ac99ee 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -57,7 +57,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
   end
 
   def title_key_for_ref( ref )
-    ref =~ /^(.+)\[(.*)\]/
+    ref =~ /^(.+)\[(.*)\]/m
     [$1, $2]
   end
 
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index d0fea97..627271f 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -193,7 +193,7 @@ class Type
     when 0; []
     when 1;
       identity = lambda {|x| x}
-      [ [ /(.*)/, [ [key_attributes.first, identity ] ] ] ]
+      [ [ /(.*)/m, [ [key_attributes.first, identity ] ] ] ]
     else
       raise Puppet::DevError,"you must specify title patterns when there
are two or more key attributes"
     end
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 195e8c8..71f2756 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -25,7 +25,7 @@ Puppet::Type.newtype(:file) do
     native resource to support what you are doing."
 
   def self.title_patterns
-    [ [ /^(.*?)\/?$/, [ [ :path, lambda{|x| x} ] ] ] ]
+    [ [ /^(.*?)\/*\Z/m, [ [ :path, lambda{|x| x} ] ] ] ]
   end
 
   newparam(:path) do
diff --git a/spec/unit/resource/catalog_spec.rb
b/spec/unit/resource/catalog_spec.rb
index b6f96f0..10cff91 100755
--- a/spec/unit/resource/catalog_spec.rb
+++ b/spec/unit/resource/catalog_spec.rb
@@ -1066,4 +1066,13 @@ describe Puppet::Resource::Catalog, "when
converting from pson" do
 
     lambda { PSON.parse @pson.to_pson }.should raise_error(ArgumentError)
   end
+
+  describe "#title_key_for_ref" do
+    it "should parse a resource ref string into a pair" do
+      @catalog.title_key_for_ref("Title[name]").should == ["Title",
"name"]
+    end
+    it "should parse a resource ref string into a pair, even if there's a
newline inside the name" do
+      @catalog.title_key_for_ref("Title[na\nme]").should == ["Title",
"na\nme"]
+    end
+  end
 end
diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb
index 845bf3d..7d93dfd 100755
--- a/spec/unit/type/file_spec.rb
+++ b/spec/unit/type/file_spec.rb
@@ -1053,4 +1053,18 @@ describe Puppet::Type.type(:file) do
       file.retrieve
     end
   end
+
+  describe ".title_patterns" do
+    before do
+      @type_class = Puppet::Type.type(:file)
+    end
+    
+    it "should have a regexp that captures the entire string, except for
a terminating slash" do
+      patterns = @type_class.title_patterns
+      string = "abc/\n\tdef/"
+      patterns[0][0] =~ string
+      $1.should == "abc/\n\tdef"
+    end
+  end
+
 end
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index 683529d..71d415d 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -406,6 +406,27 @@ describe Puppet::Type do
     end
   end
 
+  describe ".title_patterns" do
+    describe "when there's one namevar" do
+      before do
+        @type_class = Puppet::Type.type(:notify)
+        @type_class.stubs(:key_attributes).returns([:one])
+      end
+
+      it "should have a default pattern for when there's one namevar" do
+        patterns = @type_class.title_patterns
+        patterns.length.should == 1
+        patterns[0].length.should == 2
+      end
+      
+      it "should have a regexp that captures the entire string" do
+        patterns = @type_class.title_patterns
+        string = "abc\n\tdef"
+        patterns[0][0] =~ string
+        $1.should == "abc\n\tdef"
+      end
+    end
+  end
 
   describe "when in a catalog" do
     before do






PATCH/puppet 1/1] [#4264] Fix failing specs run as root due to missing puppet group
These specs 'use' some settings which create directories belonging
to the 'service' user/group. If the default service group doesn't
exist, these fail. This patch explicitly sets the service group to
the gid of the process, which is known to be accessible by the user.

Signed-off-by: Nick Lewis <ni### @puppetlabs.com>
---
 .../indirector/bucket_file/rest_spec.rb            |    1 +
 .../indirector/certificate/rest_spec.rb            |    1 +
 .../indirector/certificate_request/rest_spec.rb    |    1 +
 .../certificate_revocation_list/rest_spec.rb       |    1 +
 spec/integration/indirector/report/rest_spec.rb    |    1 +
 spec/integration/indirector/rest_spec.rb           |    1 +
 spec/integration/network/server/webrick_spec.rb    |    1 +
 spec/integration/ssl/certificate_authority_spec.rb |    1 +
 spec/integration/ssl/certificate_request_spec.rb   |    1 +
 .../ssl/certificate_revocation_list_spec.rb        |    1 +
 spec/integration/ssl/host_spec.rb                  |    1 +
 11 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/spec/integration/indirector/bucket_file/rest_spec.rb
b/spec/integration/indirector/bucket_file/rest_spec.rb
index 4d90a8c..dc10faa 100644
--- a/spec/integration/indirector/bucket_file/rest_spec.rb
+++ b/spec/integration/indirector/bucket_file/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Filebucket REST Terminus" do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
     Puppet.settings[:server] = "127.0.0.1"
     Puppet.settings[:masterport] = "34343"
 
diff --git a/spec/integration/indirector/certificate/rest_spec.rb
b/spec/integration/indirector/certificate/rest_spec.rb
index 356a7d3..58aa96c 100755
--- a/spec/integration/indirector/certificate/rest_spec.rb
+++ b/spec/integration/indirector/certificate/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Certificate REST Terminus" do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
     Puppet.settings[:server] = "127.0.0.1"
     Puppet.settings[:masterport] = "34343"
 
diff --git a/spec/integration/indirector/certificate_request/rest_spec.rb
b/spec/integration/indirector/certificate_request/rest_spec.rb
index 2c98ef6..c718b78 100755
--- a/spec/integration/indirector/certificate_request/rest_spec.rb
+++ b/spec/integration/indirector/certificate_request/rest_spec.rb
@@ -19,6 +19,7 @@ describe "Certificate Request REST Terminus" do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
     Puppet.settings[:server] = "127.0.0.1"
     Puppet.settings[:masterport] = "34343"
 
diff --git
a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
index 62a2f80..86f2b01 100755
--- a/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
+++ b/spec/integration/indirector/certificate_revocation_list/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Certificate REST Terminus" do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
     Puppet.settings[:server] = "127.0.0.1"
     Puppet.settings[:masterport] = "34343"
 
diff --git a/spec/integration/indirector/report/rest_spec.rb
b/spec/integration/indirector/report/rest_spec.rb
index 089f8fd..fdc2189 100644
--- a/spec/integration/indirector/report/rest_spec.rb
+++ b/spec/integration/indirector/report/rest_spec.rb
@@ -17,6 +17,7 @@ describe "Report REST Terminus" do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
     Puppet.settings[:server] = "127.0.0.1"
     Puppet.settings[:masterport] = "34343"
 
diff --git a/spec/integration/indirector/rest_spec.rb
b/spec/integration/indirector/rest_spec.rb
index e904839..14e9e95 100755
--- a/spec/integration/indirector/rest_spec.rb
+++ b/spec/integration/indirector/rest_spec.rb
@@ -39,6 +39,7 @@ describe Puppet::Indirector::REST do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
     Puppet.settings[:server] = "127.0.0.1"
     Puppet.settings[:masterport] = "34343"
 
diff --git a/spec/integration/network/server/webrick_spec.rb
b/spec/integration/network/server/webrick_spec.rb
index 2809df7..2b14dfb 100755
--- a/spec/integration/network/server/webrick_spec.rb
+++ b/spec/integration/network/server/webrick_spec.rb
@@ -18,6 +18,7 @@ describe Puppet::Network::Server do
 
       Puppet.settings[:confdir] = @dir
       Puppet.settings[:vardir] = @dir
+      Puppet.settings[:group] = Process.gid
 
       Puppet::SSL::Host.ca_location = :local
 
diff --git a/spec/integration/ssl/certificate_authority_spec.rb
b/spec/integration/ssl/certificate_authority_spec.rb
index be82b5f..fca17b4 100755
--- a/spec/integration/ssl/certificate_authority_spec.rb
+++ b/spec/integration/ssl/certificate_authority_spec.rb
@@ -17,6 +17,7 @@ describe Puppet::SSL::CertificateAuthority do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
 
     Puppet::SSL::Host.ca_location = :local
     @ca = Puppet::SSL::CertificateAuthority.new
diff --git a/spec/integration/ssl/certificate_request_spec.rb
b/spec/integration/ssl/certificate_request_spec.rb
index 365ecce..8426b9d 100755
--- a/spec/integration/ssl/certificate_request_spec.rb
+++ b/spec/integration/ssl/certificate_request_spec.rb
@@ -21,6 +21,7 @@ describe Puppet::SSL::CertificateRequest do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
 
     Puppet::SSL::Host.ca_location = :none
 
diff --git a/spec/integration/ssl/certificate_revocation_list_spec.rb
b/spec/integration/ssl/certificate_revocation_list_spec.rb
index 127654c..44eee36 100755
--- a/spec/integration/ssl/certificate_revocation_list_spec.rb
+++ b/spec/integration/ssl/certificate_revocation_list_spec.rb
@@ -17,6 +17,7 @@ describe Puppet::SSL::CertificateRevocationList do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
 
     Puppet::SSL::Host.ca_location = :local
   end
diff --git a/spec/integration/ssl/host_spec.rb
b/spec/integration/ssl/host_spec.rb
index 9b4152e..05862df 100755
--- a/spec/integration/ssl/host_spec.rb
+++ b/spec/integration/ssl/host_spec.rb
@@ -17,6 +17,7 @@ describe Puppet::SSL::Host do
 
     Puppet.settings[:confdir] = @dir
     Puppet.settings[:vardir] = @dir
+    Puppet.settings[:group] = Process.gid
 
     Puppet::SSL::Host.ca_location = :local
 






PATCH/puppet] [#4219] Install misses command_line dir, puppet $app --help fails
---
 install.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/install.rb b/install.rb
index d35aaa0..b06ec09 100755
--- a/install.rb
+++ b/install.rb
@@ -84,7 +84,7 @@ bins  = glob(%w{bin/*})
 rdoc  = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG
TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ }
 ri    = glob(%w{bin/*.rb sbin/* lib/**/*.rb}).reject { |e| e=~
/\.(bat|cmd)$/ }
 man   = glob(%w{man/man[0-9]/*})
-libs  = glob(%w{lib/**/*.rb lib/**/*.py})
+libs  = glob(%w{lib/**/*.rb lib/**/*.py lib/puppet/util/command_line/*})
 tests = glob(%w{test/**/*.rb})
 
 def do_bins(bins, target, strip = 's?bin/')








PATCH/puppet 1/1] Fix #4348 - Puppet doc single manifest broken
The refactoring of using environment instances instead of strings
for initializing the parser, rdoc wasn't updated, thus was unable
to initialize the parser.

Signed-off-by: Brice Figureau <brice-pupp### @daysofwonder.com>
---
 lib/puppet/util/rdoc.rb     |    2 +-
 spec/unit/util/rdoc_spec.rb |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb
index 4a80b06..085d8ec 100644
--- a/lib/puppet/util/rdoc.rb
+++ b/lib/puppet/util/rdoc.rb
@@ -41,7 +41,7 @@ module Puppet::Util::RDoc
   def manifestdoc(files)
     Puppet[:ignoreimport] = true
     files.select { |f| FileTest.file?(f) }.each do |f|
-      parser = Puppet::Parser::Parser.new(:environment =>
Puppet[:environment])
+      parser =
Puppet::Parser::Parser.new(Puppet::Node::Environment.new(Puppet[:environment]))
       parser.file = f
       ast = parser.parse
       output(f, ast)
diff --git a/spec/unit/util/rdoc_spec.rb b/spec/unit/util/rdoc_spec.rb
index 65df261..58c2034 100755
--- a/spec/unit/util/rdoc_spec.rb
+++ b/spec/unit/util/rdoc_spec.rb
@@ -75,6 +75,19 @@ describe Puppet::Util::RDoc do
       Puppet::Util::RDoc.manifestdoc([])
     end
 
+    it "should use a parser with the correct environment" do
+      FileTest.stubs(:file?).returns(true)
+      Puppet::Util::RDoc.stubs(:output)
+
+      parser = stub_everything
+      Puppet::Parser::Parser.stubs(:new).with{ |env|
env.is_a?(Puppet::Node::Environment) }.returns(parser)
+
+      parser.expects(:file=).with("file")
+      parser.expects(:parse)
+
+      Puppet::Util::RDoc.manifestdoc(["file"])
+    end
+
     it "should puppet parse all given files" do
       FileTest.stubs(:file?).returns(true)
       Puppet::Util::RDoc.stubs(:output)






PATCH/puppet 0/4] Some random puppet fix for JRuby
Hi,

Here is the first stab of JRuby Puppet compatibility.
There looks to be more thread issue (the last ones I found are
parser functions initializations), which will be addressed in
subsequent patches.

No patch in this serie have tests, because they most deal with
threading issues that can be reproduced only under JRuby.

Please review,
Brice

Brice Figureau (4):
  JRuby doesn't implement Process.maxgroups
  Fix #4244 - Cached Attributes is not thread safe
  Fix race condition in rack autoloading of request/response
  Fix #4245 - default insertion of ACL is not thread safe

 lib/puppet/network/http/rack.rb       |    3 +++
 lib/puppet/network/rest_authconfig.rb |    9 ++++++---
 lib/puppet/util/cacher.rb             |   31 +++++++++++++++++++++
PATCH/puppet 1/1] [#4336] "reportdir" was in the wrong section
Correctly revert damage done by c00285c, which incorrectly reverted in
a7e4fe8.
The result was that "puppet agent" and others were trying to create a
reportdir that they don't actually use.

Signed-off-by: Jesse Wolfe <jes5### @gmail.com>
---
 lib/puppet/defaults.rb |   20 ++++++++++
PATCH/puppet 1/1] [#4347] run_mode was colliding with --mode for "puppet doc"
The run_mode value was incorrectly getting stored to Puppet[:mode], which
was confusing the optparser for applications that declare a --mode
parameter.

Signed-off-by: Jesse Wolfe <jes### @gmail.com>
---
 lib/puppet/application.rb |    2 +-
 lib/puppet/defaults.rb    |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb
index 0a8fbc1..2fec38b 100644
--- a/lib/puppet/application.rb
+++ b/lib/puppet/application.rb
@@ -285,7 +285,7 @@ class Application
       Puppet.settings.set_value(:name, Puppet.application_name.to_s,
:mutable_defaults)
       Puppet.settings.set_value(:logdir, Puppet.run_mode.logopts,
:mutable_defaults)
       Puppet.settings.set_value(:rundir, Puppet.run_mode.run_dir,
:mutable_defaults)
-      Puppet.settings.set_value(:mode, Puppet.run_mode.name.to_s,
:mutable_defaults)
+      Puppet.settings.set_value(:run_mode, Puppet.run_mode.name.to_s,
:mutable_defaults)
     end
 
     require 'puppet'
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 84e2d93..0de5f20 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -7,7 +7,7 @@ module Puppet
     :vardir => [Puppet.run_mode.var_dir, "Where Puppet stores dynamic
and growing data.  The default for this parameter is calculated specially,
like `confdir`_."],
     :name => [Puppet.application_name.to_s, "The name of the
application, if we are running as one.  The
       default is essentially $0 without the path or ``.rb``."],
-    :mode => [Puppet.run_mode.name.to_s, "The effective 'run mode' of
the application: master, agent, or user."]
+    :run_mode => [Puppet.run_mode.name.to_s, "The effective 'run mode'
of the application: master, agent, or user."]
   )
 
   setdefaults(:main, :logdir => Puppet.run_mode.logopts)






Re: Uncaught Exception in Puppet::Resource::Catalog under 2.6
On 10/07/10 22:18, Gary Larizza wrote:
 Sorry for the delay, here it is.  http://pastie.org/1039070

It looks like Puppet::Resource::Catalog#resources doesn't exist anymore.
I suggest you file a redmine ticket with the full stacktrace so that it
can be fixed. It apparently comes from the commit 7c6b88.







PATCH/puppet 1/3] conf/redhat: Rebase rundir-perms patch
---
 conf/redhat/rundir-perms.patch |   26 +++++++++++++
storeconfigs stores wrong fact value in facts_values table
Sometimes (with variable frequency) storeconfigs stores the wrong data
in the fact_values table.  This has the end result that exported
resources, when collected, have invalid configuration.

The most recent example: the "hostname" fact for one of our nodes got,
in stead, the value that should have gone in the "processorcount"
fact.  The had the end result that the node's nagios configuration
started trying to monitor a host "8" rather than "cn19", and ssh keys
for cn19 were collected at other nodes as "8,8.example.com
<keytext>"
in stead of "cn19,cn19.example.com <keytext>".  The hostname fact is
the only destination that I've noticed the corrupted data in, but the
source has been swapfree/swapsize, processor[n], operatingsystem,
operatingsystemrelease, kernelrelease, and others.

I realize that I don't have much of a "simple, repeatable, minimal"
test case here, but I've been trying to figure it out for months to no
avail.  I had hoped that an upgrade to 2.6 would make this problem go
away, but no:  we've just now experienced it again.  For the record,
we've seen it since sometime in the 0.24.x branch (when we started
using it).

It might have something to do with an appropriately high load on
storeconfigs.  I ran it for 2 days with nodes exporting data (but not
collecting) to see if it would happen again, and I didn't notice any
corruption.  Then, today, I enabled collection (e.g., ssh_known_hosts)
on all (~138) hosts, and soon after found a corrupt nagios
configuration.  (Then again, it might just be that it's more probably
with more nodes doing the collection.)

I've never seen the actual facter command return one of these bits of
misplaced data: the furthest back I've been able to trace it is to the
facts_values table.

We're using a single puppet master, with storeconfigs storing to a
postgresql database on a different host from the puppet master host.
Everything works in the majority of cases, but fails just often enough
to make it really, really annoying.

Any help anyone can provide, including insight into where I might look
to track down the cause even further, would be much appreciated.
Thanks.

~jon





Puppet Standalone Client + Fileserving, not working.... (+ nice tutorial for puppet stand-alone) :)
Puppet local fileserving not working, as  described here:

http://docs.reductivelabs.com/guides/modules.html

I've made a project to demonstrate this:
https://mindre### @github.com/mindr...alone_testing.git

There is more in the README...(http://github.com/mindreframer/
puppet_stand_alone_testing/blob/master/Readme.md)

Would be nice to get this working, it seems wasteful the rewrite the
modules only for stand-alone usage...

Thx!





unique behavior on puppet agent running on puppet master node
(reposted from irc)

Having just upgraded to 2.6, I am seeing different behavior between
the agent running on the master node and the rest of the agents.

Most importantly, it complains about "warning: You cannot collect
without storeconfigs being set" even though storeconfigs=true in the
[master] section of puppet.conf

Less important, but still curious: the logging is quite different,
including lots of "info: Automatically imported <blah>" lines).

my puppet.conf: http://pastebin.com/nLZu9zrf

~jon





Could not retrieve information from source(s) puppet://puppet/plugins error message
Hi.

After I upgraded to latest puppet, I started receiving this message
both in clients and in master.

Following the advice below, i create an empty stub module, with empty
"lib" directory:
http://projects.puppetlabs.com/issues/2244


Any idea if this is a clean solution, or there is another, better fix?

Regards.





PATCH/puppet 1/1] Possible fix for #4297
This fix is based on refactoring Jesse's empirically derived solution
guided by
the assumption that #4297 was introduced / exposed by the fix for #4270; I
do
not have a global understanding of the code here, but am just making an
adjustment that 1) slightly reduces the code complexity, 2) doesn't appear
to
break anything, 3) empirically fixes the observed problem, 4) makes since
in
that resource classes shouldn't have to consult a passed-in scope to find
their
own namespaces.

Basically, I'm fixing what I believe was a thinko in a patch that I don't
fully
understand.

Signed-off-by: Markus Roberts <Mark### @reality.com>
---
 lib/puppet/resource/type.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index 85c0979..c27a89a 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -179,7 +179,7 @@ class Puppet::Resource::Type
 
     unless @parent_type
       raise "Must pass scope to parent_type when called first time"
unless scope
-      unless @parent_type =
scope.environment.known_resource_types.send("find_#{type}",
scope.namespaces, parent)
+      unless @parent_type =
scope.environment.known_resource_types.send("find_#{type}", [names],
parent)
         fail Puppet::ParseError, "Could not find parent resource type
'#{parent}' of type #{type} in #{scope.environment}"
       end
     end






Puppet on Windows (was Re: ANNOUNCE: Puppet 2.6.0 - Final release!)
Rohan McGovern wrote:
 James Turnbull said:
> The journey was long and arduous and many fell along the way but
Puppet
> Labs is proud to announce the 2.6.0 release!
>
 
 Is anyone aware of an attempt to package up a complete (puppet + all
 prereqs) installer for Windows?  Either official, or by someone in
the
 community?
 
 And, asking from the other direction: would anyone else be interested
in
 such a thing?
 
 I would be, because setting up puppet on Windows seems pretty tough
 right now.  I also have no need for Ruby on my Windows boxes except
 for the usage of puppet.

Rohan

There isn't such an attempt so far - we've got it on the cards to do -
but any progress in that direction would be awesome.

We've got some basic notes at:

http://projects.puppetlabs.com/projec...ki/Puppet_Windows

Regards

James Turnbull







PATCH/puppet 1/1] extlookup() is a builtin
This patch promotes extlookup() to being a builtin function.
It also adds test and makes some minor tweaks to the code.
The behavior of extlookup has been left unchanged.

Signed-off-by: Jesse Wolfe <jes### @gmail.com>
---
 {ext => lib/puppet/parser/functions}/extlookup.rb |   24 ++----
 spec/unit/parser/functions/extlookup_spec.rb      |   85
+++++++++++++++++++++
 2 files changed, 93 insertions(+), 16 deletions(-)
 rename {ext => lib/puppet/parser/functions}/extlookup.rb (92%)
 create mode 100755 spec/unit/parser/functions/extlookup_spec.rb

diff --git a/ext/extlookup.rb b/lib/puppet/parser/functions/extlookup.rb
similarity index 92%
rename from ext/extlookup.rb
rename to lib/puppet/parser/functions/extlookup.rb
index d87583b..ee230e7 100644
--- a/ext/extlookup.rb
+++ b/lib/puppet/parser/functions/extlookup.rb
@@ -82,11 +82,11 @@ require 'csv'
 module Puppet::Parser::Functions
   newfunction(:extlookup, :type => :rvalue) do |args|
     key = args[0]
-    default = "_ExtUNSET_"
-    datafile = "_ExtUNSET_"
 
-    default = args[1] if args[1]
-    datafile = args[2] if args[2]
+    default  = args[1]
+    datafile = args[2]
+
+    raise Puppet::ParseError, ("extlookup(): wrong number of arguments
(#{args.length}; must be <= 3)") if args.length > 3
 
     extlookup_datadir = lookupvar('extlookup_datadir')
     extlookup_precedence = Array.new
@@ -123,12 +123,13 @@ module Puppet::Parser::Functions
       datafiles << extlookup_datadir + "/#{d}.csv"
     end
 
-    desired = "_ExtUNSET_"
+    desired = nil
 
     datafiles.each do |file|
+      parser = Puppet::Parser::Parser.new(environment)
       parser.watch_file(file) if File.exists?(file)
 
-      if desired == "_ExtUNSET_"
+      if desired.nil?
         if File.exists?(file)
           result = CSV.read(file).find_all do |r|
             r[0] == key
@@ -167,15 +168,6 @@ module Puppet::Parser::Functions
       end
     end
 
-    # don't accidently return nil's and such rather throw a parse error
-    if desired == "_ExtUNSET_" && default == "_ExtUNSET_"
-      raise Puppet::ParseError, "No match found for '#{key}' in any data
file during extlookup()"
-    else
-      desired = default if desired == "_ExtUNSET_"
-    end
-
-    desired
+    desired || default or raise Puppet::ParseError, "No match found for
'#{key}' in any data file during extlookup()"
   end
 end
-
-# vi:tabstop=4:expandtab:ai
diff --git a/spec/unit/parser/functions/extlookup_spec.rb
b/spec/unit/parser/functions/extlookup_spec.rb
new file mode 100755
index 0000000..bf28803
--- /dev/null
+++ b/spec/unit/parser/functions/extlookup_spec.rb
@@ -0,0 +1,85 @@
+#! /usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+require 'tempfile'
+
+describe "the extlookup function" do
+
+  before :each do
+    @scope = Puppet::Parser::Scope.new
+    
+   
@scope.stubs(:environment).returns(Puppet::Node::Environment.new('production'))
+  end
+
+  it "should exist" do
+    Puppet::Parser::Functions.function("extlookup").should ==
"function_extlookup"
+  end
+
+  it "should raise a ParseError if there is less than 1 arguments" do
+    lambda { @scope.function_extlookup([]) }.should(
raise_error(Puppet::ParseError))
+  end
+
+  it "should raise a ParseError if there is more than 3 arguments" do
+    lambda { @scope.function_extlookup(["foo", "bar", "baz", "gazonk"])
}.should( raise_error(Puppet::ParseError))
+  end
+
+  it "should return the default" do
+    result = @scope.function_extlookup([ "key", "default"])
+    result.should == "default"
+  end
+
+  it "should lookup the key in a supplied datafile" do
+    t = Tempfile.new('extlookup.csv') do
+      t.puts 'key,value'
+      t.puts 'nonkey,nonvalue'
+      t.close
+
+      result = @scope.function_extlookup([ "key", "default", t.path])
+      result.should == "value"
+    end
+  end
+
+  it "should return an array if the datafile contains more than two
columns" do
+    t = Tempfile.new('extlookup.csv') do
+      t.puts 'key,value1,value2'
+      t.puts 'nonkey,nonvalue,nonvalue'
+      t.close
+
+      result = @scope.function_extlookup([ "key", "default", t.path])
+      result.should == ["value1", "value2"]
+    end
+  end
+
+  it "should raise an error if there's no matching key and no default" do
+    t = Tempfile.new('extlookup.csv') do
+      t.puts 'key,value'
+      t.puts 'nonkey,nonvalue'
+      t.close
+
+      result = @scope.function_extlookup([ "key", nil, t.path])
+      result.should == "value"
+    end
+  end
+
+  describe "should look in $extlookup_datadir for data files listed by
$extlookup_precedence" do
+    before do 
+      @scope.stubs(:lookupvar).with('extlookup_datadir').returns("/tmp")
+     
@scope.stubs(:lookupvar).with('extlookup_precedence').returns(["one","two"])
+      File.open("/tmp/one.csv","w"){|one| one.puts "key,value1" }
+      File.open("/tmp/two.csv","w") do |two|
+        two.puts "key,value2"
+        two.puts "key2,value_two"
+      end
+    end
+
+    it "when the key is in the first file" do
+      result = @scope.function_extlookup([ "key" ])
+      result.should == "value1"
+    end
+
+    it "when the key is in the second file" do
+      result = @scope.function_extlookup([ "key2" ])
+      result.should == "value_two"
+    end
+  end
+end






PATCH/puppet 1/1] This commit resolves:
created init provider method self.get_services
  - accepts an array of filenames to exclude when retrieving services.

added unit tests to verify that I can specify files to exclude.

Signed-off-by: Dan Bode <d### @reductivelabs.com>
---
 lib/puppet/provider/service/init.rb       |    9 +++++--
 lib/puppet/provider/service/redhat.rb     |    5 ++++
 spec/unit/provider/service/init_spec.rb   |   35
+++++++++++++++++++++++++++++
 spec/unit/provider/service/redhat_spec.rb |   19 +++++++++++++++
 4 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/lib/puppet/provider/service/init.rb
b/lib/puppet/provider/service/init.rb
index c05a326..58b7f91 100755
--- a/lib/puppet/provider/service/init.rb
+++ b/lib/puppet/provider/service/init.rb
@@ -28,11 +28,13 @@ Puppet::Type.type(:service).provide :init, :parent
=> :base do
 
     # List all services of this type.
     def self.instances
-        self.defpath = [self.defpath] unless self.defpath.is_a? Array
+        get_services(self.defpath)
+    end
 
+    def self.get_services(defpath, exclude=[])
+        defpath = [defpath] unless defpath.is_a? Array
         instances = []
-
-        self.defpath.each do |path|
+        defpath.each do |path|
             unless FileTest.directory?(path)
                 Puppet.debug "Service path %s does not exist" % path
                 next
@@ -47,6 +49,7 @@ Puppet::Type.type(:service).provide :init, :parent =>
:base do
             Dir.entries(path).each do |name|
                 fullpath = File.join(path, name)
                 next if name =~ /^\./
+                next if exclude.include? name 
                 next if not FileTest.executable?(fullpath)
                 instances << new(:name => name, :path =>
path)
             end
diff --git a/lib/puppet/provider/service/redhat.rb
b/lib/puppet/provider/service/redhat.rb
index 45a9074..065efe6 100755
--- a/lib/puppet/provider/service/redhat.rb
+++ b/lib/puppet/provider/service/redhat.rb
@@ -11,6 +11,11 @@ Puppet::Type.type(:service).provide :redhat, :parent
=> :init, :source => :init
 
     defaultfor :operatingsystem => [:redhat, :fedora, :suse, :centos,
:sles, :oel, :ovm]
 
+    def self.instances
+        # this exclude list is all from /sbin/service (5.x), but I did
not exclude kudzu
+        self.get_services(['/etc/init.d/'], ['functions', 'halt',
'killall', 'single', 'linuxconf'])
+    end
+
     def self.defpath
         superclass.defpath
     end
diff --git a/spec/unit/provider/service/init_spec.rb
b/spec/unit/provider/service/init_spec.rb
index 32bfaa2..cabd090 100755
--- a/spec/unit/provider/service/init_spec.rb
+++ b/spec/unit/provider/service/init_spec.rb
@@ -10,6 +10,7 @@ provider_class =
Puppet::Type.type(:service).provider(:init)
 describe provider_class do
 
     before :each do
+        @class = Puppet::Type.type(:service).provider(:init)
         @resource = stub 'resource'
         @resource.stubs(:[]).returns(nil)
         @resource.stubs(:[]).with(:name).returns "myservice"
@@ -22,6 +23,40 @@ describe provider_class do
         @provider.resource = @resource
     end
 
+    describe "when getting all service instances" do
+        before :each do 
+            @services = ['one', 'two', 'three', 'four']
+            Dir.stubs(:entries).returns @services
+            FileTest.stubs(:directory?).returns(true)
+            FileTest.stubs(:executable?).returns(true)
+            @class.stubs(:defpath).returns('tmp')
+        end
+        it "should return instances for all services" do
+            @services.each do |inst|
+                @class.expects(:new).with({:name => inst, :path =>
@class.defpath}).returns("#{inst}_instance")
+            end
+            results = @services.collect {|x| "#{x}_instance"}
+            @class.instances.should == results
+        end
+        it "should omit an array of services from exclude list" do
+            exclude = ['two', 'four']
+            (@services-exclude).each do |inst|
+                @class.expects(:new).with({:name => inst, :path =>
@class.defpath}).returns("#{inst}_instance")
+            end
+            results = (@services-exclude).collect {|x| "#{x}_instance"}
+            @class.get_services(@class.defpath, exclude).should ==
results
+        end
+        it "should omit a single service from the exclude list" do
+            exclude = 'two'
+            (@services-exclude.to_a).each do |inst|
+                @class.expects(:new).with({:name => inst, :path =>
@class.defpath}).returns("#{inst}_instance")
+            end
+            results = @services.reject{|x| x==exclude }.collect {|x|
"#{x}_instance"}
+            @class.get_services(@class.defpath, exclude).should ==
results
+        end
+        it "should use defpath" do
+        end
+    end
 
     describe "when searching for the init script" do
         it "should discard paths that do not exist" do
diff --git a/spec/unit/provider/service/redhat_spec.rb
b/spec/unit/provider/service/redhat_spec.rb
index 47997dc..840b192 100755
--- a/spec/unit/provider/service/redhat_spec.rb
+++ b/spec/unit/provider/service/redhat_spec.rb
@@ -10,6 +10,7 @@ provider_class =
Puppet::Type.type(:service).provider(:redhat)
 describe provider_class do
 
     before :each do
+        @class = Puppet::Type.type(:service).provider(:redhat)
         @resource = stub 'resource'
         @resource.stubs(:[]).returns(nil)
         @resource.stubs(:[]).with(:name).returns "myservice"
@@ -19,6 +20,24 @@ describe provider_class do
         FileTest.stubs(:file?).with('/sbin/service').returns true
         FileTest.stubs(:executable?).with('/sbin/service').returns true
     end
+    
+    # test self.instances
+    describe "when getting all service instances" do
+        before :each do 
+            @services = ['one', 'two', 'three', 'four', 'kudzu',
'functions', 'halt', 'killall', 'single', 'linuxconf']
+            @not_services = ['functions', 'halt', 'killall', 'single',
'linuxconf']
+            Dir.stubs(:entries).returns @services
+            FileTest.stubs(:directory?).returns(true)
+            FileTest.stubs(:executable?).returns(true)
+        end
+        it "should return instances for all services" do
+            (@services-@not_services).each do |inst|
+                @class.expects(:new).with({:name => inst, :path =>
'/etc/init.d/'}).returns("#{inst}_instance")
+            end
+            results = (@services-@not_services).collect {|x|
"#{x}_instance"}
+            @class.instances.should == results
+        end
+    end
 
     it "should have an enabled? method" do
         @provider.should respond_to(:enabled?)