From fc14b81f99adc9c9308a26d322adaa59a7b7716d Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 28 Jan 2009 17:11:19 -0600 Subject: Splitting the Agent class into Agent and Configurer Once I went to add runinterval support to the Agent class, I realized it's really two classes: One that handles starting, stopping, running, et al (still called Agent), and one that handles downloading the catalog, running it, etc. (now called Configurer). This commit includes some additional code, but 95% of it is just moving code around. Signed-off-by: Luke Kanies --- bin/puppetd | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/puppetd b/bin/puppetd index ecea2d894..2a71a9a08 100755 --- a/bin/puppetd +++ b/bin/puppetd @@ -162,7 +162,8 @@ trap(:INT) do end require 'puppet' -require 'puppet/network/client' +require 'puppet/agent' +require 'puppet/configurer' require 'getoptlong' options = [ @@ -329,13 +330,19 @@ Puppet::SSL::Host.ca_location = :remote Puppet::Transaction::Report.terminus_class = :rest +Puppet::Resource::Catalog.terminus_class = :rest +Puppet::Resource::Catalog.cache_class = :yaml + +Puppet::Node::Facts.terminus_class = :facter +Puppet::Node::Facts.cache_class = :rest + # We need tomake the client either way, we just don't start it # if --no-client is set. -client = Puppet::Network::Client.master.new(args) +agent = Puppet::Agent.new(Puppet::Configurer) if options[:enable] - client.enable + agent.enable elsif options[:disable] - client.disable + agent.disable end if options[:enable] or options[:disable] @@ -347,12 +354,11 @@ server = nil # It'd be nice to daemonize later, but we have to daemonize before the # waitforcert happens. if Puppet[:daemonize] - client.daemonize + agent.daemonize end host = Puppet::SSL::Host.new cert = host.wait_for_cert(options[:waitforcert]) -client.recycle_connection objects = [] @@ -402,7 +408,7 @@ elsif options[:onetime] and Puppet[:listen] end if options[:client] - objects << client + objects << agent end # Set traps for INT and TERM @@ -417,10 +423,10 @@ if options[:onetime] end # Add the service, so the traps work correctly. - Puppet.newservice(client) + Puppet.newservice(agent) begin - client.run + agent.run rescue => detail if Puppet[:trace] puts detail.backtrace @@ -435,7 +441,7 @@ else if options[:client] Puppet.notice "Starting Puppet client version %s" % [Puppet.version] - Puppet.newservice(client) + Puppet.newservice(agent) end Puppet.settraps -- cgit v1.2.3