[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:33:50 UTC 2010


The following commit has been merged in the upstream branch:
commit ac7efc8f0284d6b35f5428da06ba371cf94998ec
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Wed May 12 18:25:14 2010 -0700

    Feature #2935 Puppet::Mode#master?
    
    Use a predicate function on the Mode object instead of comparing with
    the executable name everywhere
    
    Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>

diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb
index 0f4381f..5da7040 100644
--- a/lib/puppet/application/doc.rb
+++ b/lib/puppet/application/doc.rb
@@ -207,8 +207,6 @@ class Puppet::Application::Doc < Puppet::Application
             end
         end
 
-        # hack to get access to puppetmasterd modulepath and manifestdir
-        Puppet[:name] = "puppetmasterd"
         # Now parse the config
         Puppet.parse_config
 
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index f83245a..0dccf36 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -53,7 +53,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
 
     # Is our compiler part of a network, or are we just local?
     def networked?
-        $0 =~ /puppetmasterd/
+        Puppet.mode.master?
     end
 
     private
diff --git a/lib/puppet/indirector/file.rb b/lib/puppet/indirector/file.rb
index cc7ad9b..0aedccf 100644
--- a/lib/puppet/indirector/file.rb
+++ b/lib/puppet/indirector/file.rb
@@ -4,7 +4,7 @@ require 'puppet/indirector/terminus'
 class Puppet::Indirector::File < Puppet::Indirector::Terminus
     # Where do we store our data?
     def data_directory
-        name = Puppet[:name] == "puppetmasterd" ? :server_datadir : :client_datadir
+        name = Puppet.mode.master? ? :server_datadir : :client_datadir
 
         File.join(Puppet.settings[name], self.class.indirection_name.to_s)
     end
diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb
index 782112e..7102466 100644
--- a/lib/puppet/indirector/yaml.rb
+++ b/lib/puppet/indirector/yaml.rb
@@ -45,7 +45,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus
 
     # Get the yaml directory
     def base
-        (Puppet[:name] == "puppetmasterd") ? Puppet[:yamldir] : Puppet[:clientyamldir]
+        Puppet.mode.master? ? Puppet[:yamldir] : Puppet[:clientyamldir]
     end
 
     # Return the path to a given node's file.
diff --git a/lib/puppet/network/authorization.rb b/lib/puppet/network/authorization.rb
index 9ea4bf6..7a61ab9 100644
--- a/lib/puppet/network/authorization.rb
+++ b/lib/puppet/network/authorization.rb
@@ -34,8 +34,7 @@ module Puppet::Network
                         return false
                     end
                 else
-                    # This is a hack way of seeing if we're a config master.
-                    if Puppet[:name] == "puppetmasterd"
+                    if Puppet.mode.master?
                         Puppet.debug "Allowing " + msg
                         return true
                     else
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index 1a3f5dd..a97add0 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -70,7 +70,7 @@ class Puppet::Network::HTTP::WEBrick
         # Make sure the settings are all ready for us.
         Puppet.settings.use(:main, :ssl, Puppet[:name])
 
-        if Puppet[:name] == "puppetmasterd"
+        if Puppet.mode.master?
             file = Puppet[:masterhttplog]
         else
             file = Puppet[:httplog]
diff --git a/lib/puppet/network/http_server/webrick.rb b/lib/puppet/network/http_server/webrick.rb
index 051a352..aa93068 100644
--- a/lib/puppet/network/http_server/webrick.rb
+++ b/lib/puppet/network/http_server/webrick.rb
@@ -45,7 +45,7 @@ module Puppet
                 # yuck; separate http logs
                 file = nil
                 Puppet.settings.use(:main, :ssl, Puppet[:name])
-                if Puppet[:name] == "puppetmasterd"
+                if Puppet.mode.master?
                     file = Puppet[:masterhttplog]
                 else
                     file = Puppet[:httplog]
diff --git a/lib/puppet/ssl/certificate_authority.rb b/lib/puppet/ssl/certificate_authority.rb
index 111b720..bd081c9 100644
--- a/lib/puppet/ssl/certificate_authority.rb
+++ b/lib/puppet/ssl/certificate_authority.rb
@@ -33,7 +33,7 @@ class Puppet::SSL::CertificateAuthority
 
     def self.ca?
         return false unless Puppet[:ca]
-        return false unless Puppet[:name] == "puppetmasterd"
+        return false unless Puppet.mode.master?
         return true
     end
 
diff --git a/spec/unit/application/doc.rb b/spec/unit/application/doc.rb
index c224b0d..960ef7a 100755
--- a/spec/unit/application/doc.rb
+++ b/spec/unit/application/doc.rb
@@ -190,7 +190,6 @@ describe Puppet::Application::Doc do
 
             before :each do
                 @doc.options.stubs(:[]).returns(false)
-                Puppet.stubs(:[]=).with(:name, "puppetmasterd")
                 Puppet.stubs(:parse_config)
                 Puppet::Util::Log.stubs(:level=)
                 Puppet::Util::Log.stubs(:newdestination)
@@ -224,8 +223,8 @@ describe Puppet::Application::Doc do
                 end
             end
 
-            it "should pretend to be puppetmasterd" do
-                Puppet.expects(:[]=).with(:name, "puppetmasterd")
+            it "should operate in master mode" do
+                @doc.class.mode.name.should == :master
 
                 @doc.setup_rdoc
             end
diff --git a/spec/unit/indirector/file.rb b/spec/unit/indirector/file.rb
index fd56aa6..207d897 100755
--- a/spec/unit/indirector/file.rb
+++ b/spec/unit/indirector/file.rb
@@ -30,15 +30,15 @@ describe Puppet::Indirector::File do
             @searcher.should respond_to(:find)
         end
 
-        it "should use the server data directory plus the indirection name if the process name is 'puppetmasterd'" do
-            Puppet.settings.expects(:value).with(:name).returns "puppetmasterd"
+        it "should use the server data directory plus the indirection name if the process mode is master" do
+            Puppet.mode.expects(:master?).returns true
             Puppet.settings.expects(:value).with(:server_datadir).returns "/my/dir"
 
             @searcher.data_directory.should == File.join("/my/dir", "mystuff")
         end
 
-        it "should use the client data directory plus the indirection name if the process name is not 'puppetmasterd'" do
-            Puppet.settings.expects(:value).with(:name).returns "puppetd"
+        it "should use the client data directory plus the indirection name if the process mode is not master" do
+            Puppet.mode.expects(:master?).returns false
             Puppet.settings.expects(:value).with(:client_datadir).returns "/my/dir"
 
             @searcher.data_directory.should == File.join("/my/dir", "mystuff")
diff --git a/spec/unit/indirector/yaml.rb b/spec/unit/indirector/yaml.rb
index 153b965..d93199e 100755
--- a/spec/unit/indirector/yaml.rb
+++ b/spec/unit/indirector/yaml.rb
@@ -22,19 +22,20 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
         @dir = "/what/ever"
         Puppet.settings.stubs(:value).returns("fakesettingdata")
         Puppet.settings.stubs(:value).with(:clientyamldir).returns(@dir)
+        Puppet.mode.stubs(:master?).returns false
 
         @request = stub 'request', :key => :me, :instance => @subject
     end
 
     describe Puppet::Indirector::Yaml, " when choosing file location" do
-        it "should use the server_datadir if the process name is 'puppetmasterd'" do
-            Puppet.settings.expects(:value).with(:name).returns "puppetmasterd"
+        it "should use the server_datadir if the mode is master" do
+            Puppet.mode.expects(:master?).returns true
             Puppet.settings.expects(:value).with(:yamldir).returns "/server/yaml/dir"
             @store.path(:me).should =~ %r{^/server/yaml/dir}
         end
 
-        it "should use the client yamldir if the process name is not 'puppetmasterd'" do
-            Puppet.settings.expects(:value).with(:name).returns "cient"
+        it "should use the client yamldir if the mode is not master" do
+            Puppet.mode.expects(:master?).returns false
             Puppet.settings.expects(:value).with(:clientyamldir).returns "/client/yaml/dir"
             @store.path(:me).should =~ %r{^/client/yaml/dir}
         end
diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb
index b8163fe..aaab53b 100755
--- a/spec/unit/network/http/webrick.rb
+++ b/spec/unit/network/http/webrick.rb
@@ -211,8 +211,8 @@ describe Puppet::Network::HTTP::WEBrick do
             @server.setup_logger
         end
 
-        it "should use the masterlog if the process name is 'puppetmasterd'" do
-            Puppet.settings.stubs(:value).with(:name).returns "puppetmasterd"
+        it "should use the masterlog if the process mode is master" do
+            Puppet.mode.stubs(:master?).returns(true)
             Puppet.settings.expects(:value).with(:masterhttplog).returns "/master/log"
 
             File.expects(:open).with("/master/log", "a+").returns @filehandle
@@ -220,8 +220,8 @@ describe Puppet::Network::HTTP::WEBrick do
             @server.setup_logger
         end
 
-        it "should use the httplog if the process name is not 'puppetmasterd'" do
-            Puppet.settings.stubs(:value).with(:name).returns "other"
+        it "should use the httplog if the process mode is not master" do
+            Puppet.mode.stubs(:master?).returns(false)
             Puppet.settings.expects(:value).with(:httplog).returns "/other/log"
 
             File.expects(:open).with("/other/log", "a+").returns @filehandle
diff --git a/spec/unit/ssl/certificate_authority.rb b/spec/unit/ssl/certificate_authority.rb
index 4d2303a..3b1b948 100755
--- a/spec/unit/ssl/certificate_authority.rb
+++ b/spec/unit/ssl/certificate_authority.rb
@@ -24,10 +24,10 @@ describe Puppet::SSL::CertificateAuthority do
     end
 
     describe "when finding an existing instance" do
-        describe "and the host is a CA host and the proces name is 'puppetmasterd'" do
+        describe "and the host is a CA host and the mode is master" do
             before do
                 Puppet.settings.stubs(:value).with(:ca).returns true
-                Puppet.settings.stubs(:value).with(:name).returns "puppetmasterd"
+                Puppet.mode.stubs(:master?).returns true
 
                 @ca = mock('ca')
                 Puppet::SSL::CertificateAuthority.stubs(:new).returns @ca
@@ -45,7 +45,7 @@ describe Puppet::SSL::CertificateAuthority do
         describe "and the host is not a CA host" do
             it "should return nil" do
                 Puppet.settings.stubs(:value).with(:ca).returns false
-                Puppet.settings.stubs(:value).with(:name).returns "puppetmasterd"
+                Puppet.mode.stubs(:master?).returns true
 
                 ca = mock('ca')
                 Puppet::SSL::CertificateAuthority.expects(:new).never
@@ -53,10 +53,10 @@ describe Puppet::SSL::CertificateAuthority do
             end
         end
 
-        describe "and the process name is not 'puppetmasterd'" do
+        describe "and the mode is not master" do
             it "should return nil" do
                 Puppet.settings.stubs(:value).with(:ca).returns true
-                Puppet.settings.stubs(:value).with(:name).returns "puppetd"
+                Puppet.mode.stubs(:master?).returns false
 
                 ca = mock('ca')
                 Puppet::SSL::CertificateAuthority.expects(:new).never

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list