diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-08 01:39:39 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-08 01:39:39 +0000 |
| commit | 7e07e3dc843798bdbc7a03428ca054adaff2fb72 (patch) | |
| tree | 34d0f9f8c2ee11bdc281e6e4d18cad444253fe36 /lib/puppet/network/server/runner.rb | |
| parent | 6d8068eddd0d29ec53f62557eb53f6ebb8e40591 (diff) | |
| download | puppet-7e07e3dc843798bdbc7a03428ca054adaff2fb72.tar.gz puppet-7e07e3dc843798bdbc7a03428ca054adaff2fb72.tar.xz puppet-7e07e3dc843798bdbc7a03428ca054adaff2fb72.zip | |
Moving all of the client and server code into a single network/ directory. In other words, more code structure cleanup.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2179 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/network/server/runner.rb')
| -rwxr-xr-x | lib/puppet/network/server/runner.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/puppet/network/server/runner.rb b/lib/puppet/network/server/runner.rb new file mode 100755 index 000000000..c0ec8fb9d --- /dev/null +++ b/lib/puppet/network/server/runner.rb @@ -0,0 +1,61 @@ +class Puppet::Network::Server + class MissingMasterError < RuntimeError; end # Cannot find the master client + # A simple server for triggering a new run on a Puppet client. + class Runner < Handler + @interface = XMLRPC::Service::Interface.new("puppetrunner") { |iface| + iface.add_method("string run(string, string)") + } + + # Run the client configuration right now, optionally specifying + # tags and whether to ignore schedules + def run(tags = nil, ignoreschedules = false, fg = true, client = nil, clientip = nil) + # We need to retrieve the client + master = Puppet::Network::Client::MasterClient.instance + + unless master + raise MissingMasterError, "Could not find the master client" + end + + if Puppet::Util::Pidlock.new(Puppet[:puppetdlockfile]).locked? + Puppet.notice "Could not trigger run; already running" + return "running" + end + + if tags == "" + tags = nil + end + + if ignoreschedules == "" + ignoreschedules == nil + end + + msg = "" + if client + msg = "%s(%s) " % [client, clientip] + end + msg += "triggered run" % + if tags + msg += " with tags %s" % tags + end + + if ignoreschedules + msg += " without schedules" + end + + Puppet.notice msg + + # And then we need to tell it to run, with this extra info. + if fg + master.run(tags, ignoreschedules) + else + Puppet.newthread do + master.run(tags, ignoreschedules) + end + end + + return "success" + end + end +end + +# $Id$ |
