diff options
| author | Andrew Forgue <andrew.forgue@gmail.com> | 2009-11-24 18:28:30 -0500 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 44f1465e937c0d7157de0caf7d2e6af9a38f09d8 (patch) | |
| tree | 40f577f3dd02729a07e2b887fc783df8f1a5e2f0 /lib/puppet/provider/service | |
| parent | 02ed8db54372c8b824a10f6fb1df9773f0eb93d5 (diff) | |
| download | puppet-44f1465e937c0d7157de0caf7d2e6af9a38f09d8.tar.gz puppet-44f1465e937c0d7157de0caf7d2e6af9a38f09d8.tar.xz puppet-44f1465e937c0d7157de0caf7d2e6af9a38f09d8.zip | |
Fixing #2864 Added support for AIX System Resource Controller (SRC) - service start stop
This provider supports start/stop and restart of AIX services using the
native AIX service manager, called the System Resource Controller.
Currently it will not stop and start (but only refresh) a service that
uses sockets or message queues as its communication method. It will run
stopsrc and then startsrc for services that use signals as their
communication method.
Signed-off-by: Andrew Forgue <andrew.forgue@gmail.com>
Diffstat (limited to 'lib/puppet/provider/service')
| -rwxr-xr-x | lib/puppet/provider/service/src.rb | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb new file mode 100755 index 000000000..eadce8e96 --- /dev/null +++ b/lib/puppet/provider/service/src.rb @@ -0,0 +1,91 @@ +# AIX System Resource controller (SRC) +Puppet::Type.type(:service).provide :src, :parent => :base do + + desc "Support for AIX's System Resource controller. + + Services are started/stopped based on the stopsrc and startsrc + commands, and some services can be refreshed with refresh command. + + * Enabling and disableing services is not supported, as it requires + modifications to /etc/inittab. + + * Starting and stopping groups of subsystems is not yet supported + " + + defaultfor :operatingsystem => :aix + confine :operatingsystem => :aix + + commands :stopsrc => "/usr/bin/stopsrc" + commands :startsrc => "/usr/bin/startsrc" + commands :refresh => "/usr/bin/refresh" + commands :lssrc => "/usr/bin/lssrc" + + has_feature :refreshable + + def startcmd + [command(:startsrc), "-s", @resource[:name]] + end + + def stopcmd + [command(:stopsrc), "-s", @resource[:name]] + end + + def restart + begin + execute([command(:lssrc), "-Ss", @resource[:name]]).each do |line| + args = line.split(":") + + next unless args[0] == @resource[:name] + + # Subsystems with the -K flag can get refreshed (HUPed) + # While subsystems with -S (signals) must be stopped/started + method = args[11] + do_refresh = case method + when "-K" then :true + when "-S" then :false + else self.fail("Unknown service communication method #{method}") + end + + begin + if do_refresh == :true + execute([command(:refresh), "-s", @resource[:name]]) + else + self.stop + self.start + end + return :true + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error.new("Unable to restart service %s, error was: %s" % [ @resource[:name], detail ] ) + end + end + self.fail("No such service found") + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error.new("Cannot get status of %s, error was: %s" % [ @resource[:name], detail ] ) + end + end + + def status + begin + execute([command(:lssrc), "-s", @resource[:name]]).each do |line| + args = line.split + + # This is the header line + next unless args[0] == @resource[:name] + + # PID is the 3rd field, but inoperative subsystems + # skip this so split doesn't work right + state = case args[-1] + when "active" then :running + when "inoperative" then :stopped + end + Puppet.debug("Service #{@resource[:name]} is #{args[-1]}") + return state + end + self.fail("No such service found") + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error.new("Cannot get status of %s, error was: %s" % [ @resource[:name], detail ] ) + end + end + +end + |
