summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-02 04:30:40 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-02 04:30:40 +0000
commitb67a19b6b0483d73178a928e9d1c2bb752b2f077 (patch)
treedfb6505ece37940f251676bfa95712aba9771ee0 /lib/puppet
parenta435d076d4d61e35fe4433a5c3e76ffb2203ac5d (diff)
downloadpuppet-b67a19b6b0483d73178a928e9d1c2bb752b2f077.tar.gz
puppet-b67a19b6b0483d73178a928e9d1c2bb752b2f077.tar.xz
puppet-b67a19b6b0483d73178a928e9d1c2bb752b2f077.zip
Fixing #132, which involved creating a separate CA client and using it to retrieve the certificates. There was more work to do because of the weird client/daemon/server heirarchy.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1160 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/client.rb2
-rw-r--r--lib/puppet/client/ca.rb2
-rwxr-xr-xlib/puppet/daemon.rb41
-rw-r--r--lib/puppet/networkclient.rb9
4 files changed, 29 insertions, 25 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb
index 0dd5221ed..7f6ed2592 100644
--- a/lib/puppet/client.rb
+++ b/lib/puppet/client.rb
@@ -136,6 +136,7 @@ module Puppet
Puppet.notice "Already in shutdown"
else
self.stopping = true
+ rmpidfile()
Puppet::Storage.store
exit
end
@@ -144,7 +145,6 @@ module Puppet
# Start listening for events. We're pretty much just listening for
# timer events here.
def start
- super
# Create our timer
timer = EventLoop::Timer.new(
:interval => Puppet[:runinterval],
diff --git a/lib/puppet/client/ca.rb b/lib/puppet/client/ca.rb
index a7fa71e88..8904c4a13 100644
--- a/lib/puppet/client/ca.rb
+++ b/lib/puppet/client/ca.rb
@@ -1,4 +1,4 @@
-class Puppet::Client::CAClient < Puppet::Client::ProxyClient
+class Puppet::Client::CA < Puppet::Client::ProxyClient
@drivername = :CA
# set up the appropriate interface methods
diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb
index f8d67db95..d2d39eec5 100755
--- a/lib/puppet/daemon.rb
+++ b/lib/puppet/daemon.rb
@@ -204,27 +204,31 @@ module Puppet
return retrieved
end
+ # Remove the pid file
+ def rmpidfile
+ if defined? @pidfile and @pidfile and FileTest.exists?(@pidfile)
+ begin
+ File.unlink(@pidfile)
+ rescue => detail
+ Puppet.err "Could not remove PID file %s: %s" %
+ [@pidfile, detail]
+ end
+ end
+ end
+
# Create the pid file.
def setpidfile
Puppet.config.use(:puppet)
@pidfile = self.pidfile
- if FileTest.exists?(@pidfile) and not defined? $setpidfile
- raise Puppet::Error, "A PID file already exists for #{Puppet.name}
+ if FileTest.exists?(@pidfile)
+ if defined? $setpidfile
+ return
+ else
+ raise Puppet::Error, "A PID file already exists for #{Puppet.name}
at #{@pidfile}. Not starting."
- #Puppet.info "Deleting old pid file"
- #begin
- # File.unlink(@pidfile)
- #rescue Errno::EACCES
- # Puppet.err "Could not delete old PID file; cannot create new one"
- # return
- #end
+ end
end
- #unless FileTest.exists?(Puppet[:rundir])
- # Puppet.recmkdir(Puppet[:rundir])
- # File.chmod(01777, Puppet[:rundir])
- #end
-
Puppet.info "Creating PID file to %s" % @pidfile
begin
File.open(@pidfile, "w") { |f| f.puts $$ }
@@ -238,14 +242,7 @@ at #{@pidfile}. Not starting."
# Shut down our server
def shutdown
# Remove our pid file
- if defined? @pidfile and @pidfile and FileTest.exists?(@pidfile)
- begin
- File.unlink(@pidfile)
- rescue => detail
- Puppet.err "Could not remove PID file %s: %s" %
- [@pidfile, detail]
- end
- end
+ rmpidfile()
# And close all logs
Puppet::Log.close
diff --git a/lib/puppet/networkclient.rb b/lib/puppet/networkclient.rb
index ef3d88179..09c6bc0ab 100644
--- a/lib/puppet/networkclient.rb
+++ b/lib/puppet/networkclient.rb
@@ -44,6 +44,10 @@ module Puppet
# so that they namespaces can define the same methods if
# they want.
newclient = Class.new(self)
+
+ #name = "Puppet::NetworkClient::" + handler.to_s.sub(/^.+::/, '')
+ name = handler.to_s.sub(/^.+::/, '')
+ const_set(name, newclient)
@clients[namespace] = newclient
interface.methods.each { |ary|
@@ -138,7 +142,10 @@ module Puppet
if hash[:Certificate]
self.cert = hash[:Certificate]
else
- Puppet.err "No certificate; running with reduced functionality."
+ unless defined? $nocertwarned
+ Puppet.err "No certificate; running with reduced functionality."
+ $nocertwarned = true
+ end
end
if hash[:Key]