1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
|