summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-05-12 18:25:14 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitac7efc8f0284d6b35f5428da06ba371cf94998ec (patch)
treec1a6a6df5dd2d533c1d0b12b869a0758b8c4cb6f
parent5665e3984f73c70b90f65dd8bf4445b5adda5121 (diff)
downloadpuppet-ac7efc8f0284d6b35f5428da06ba371cf94998ec.tar.gz
puppet-ac7efc8f0284d6b35f5428da06ba371cf94998ec.tar.xz
puppet-ac7efc8f0284d6b35f5428da06ba371cf94998ec.zip
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@gmail.com>
-rw-r--r--lib/puppet/application/doc.rb2
-rw-r--r--lib/puppet/indirector/catalog/compiler.rb2
-rw-r--r--lib/puppet/indirector/file.rb2
-rw-r--r--lib/puppet/indirector/yaml.rb2
-rw-r--r--lib/puppet/network/authorization.rb3
-rw-r--r--lib/puppet/network/http/webrick.rb2
-rw-r--r--lib/puppet/network/http_server/webrick.rb2
-rw-r--r--lib/puppet/ssl/certificate_authority.rb2
-rwxr-xr-xspec/unit/application/doc.rb5
-rwxr-xr-xspec/unit/indirector/file.rb8
-rwxr-xr-xspec/unit/indirector/yaml.rb9
-rwxr-xr-xspec/unit/network/http/webrick.rb8
-rwxr-xr-xspec/unit/ssl/certificate_authority.rb10
13 files changed, 27 insertions, 30 deletions
diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb
index 0f4381f4b..5da7040ae 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 f83245a27..0dccf3613 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 cc7ad9b07..0aedccf91 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 782112ebd..710246686 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 9ea4bf69e..7a61ab9b9 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 1a3f5ddce..a97add0c0 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 051a35234..aa930681b 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 111b72009..bd081c914 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 c224b0de5..960ef7ac6 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 fd56aa6c7..207d897bf 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 153b9651b..d93199e1c 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 b8163fef7..aaab53b0c 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 4d2303a60..3b1b9486f 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