author | Shawn Ferry <shawn.ferry@oracle.com> |
Tue, 26 Apr 2016 23:36:26 -0400 | |
changeset 5864 | 06703eb0e31f |
permissions | -rw-r--r-- |
5864
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
1 |
Add -s for synchronous restart |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
2 |
Upstream as PUP-6233 |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
3 |
|
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
4 |
diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
5 |
--- a/lib/puppet/provider/service/smf.rb |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
6 |
+++ b/lib/puppet/provider/service/smf.rb |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
7 |
@@ -66,7 +71,12 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
8 |
end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
9 |
|
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
10 |
def restartcmd |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
11 |
- [command(:adm), :restart, @resource[:name]] |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
12 |
+ if Puppet::Util::Package.versioncmp(Facter.value(:kernelrelease), '5.11') >= 0 |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
13 |
+ [command(:adm), :restart, "-s", @resource[:name]] |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
14 |
+ else |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
15 |
+ # Solaris 10 does not have synchronous restart |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
16 |
+ [command(:adm), :restart, @resource[:name]] |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
17 |
+ end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
18 |
end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
19 |
|
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
20 |
def startcmd |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
21 |
diff --git a/spec/unit/provider/service/smf_spec.rb b/spec/unit/provider/service/smf_spec.rb |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
22 |
--- a/spec/unit/provider/service/smf_spec.rb |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
23 |
+++ b/spec/unit/provider/service/smf_spec.rb |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
24 |
@@ -1,4 +1,7 @@ |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
25 |
#! /usr/bin/env ruby |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
26 |
+####################################################################### |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
27 |
+# Oracle has modified the originally distributed contents of this file. |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
28 |
+####################################################################### |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
29 |
# |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
30 |
# Unit testing for the SMF service Provider |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
31 |
# |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
32 |
@@ -20,6 +23,8 @@ describe provider_class, :as_platform => :posix do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
33 |
FileTest.stubs(:executable?).with('/usr/sbin/svcadm').returns true |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
34 |
FileTest.stubs(:file?).with('/usr/bin/svcs').returns true |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
35 |
FileTest.stubs(:executable?).with('/usr/bin/svcs').returns true |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
36 |
+ Facter.clear |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
37 |
+ Facter.stubs(:fact).with(:kernelrelease).returns Facter.add(:kernelrelease) { setcode { '5.11' } } |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
38 |
end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
39 |
|
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
40 |
describe ".instances" do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
41 |
@@ -144,8 +149,30 @@ describe provider_class, :as_platform => :posix do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
42 |
end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
43 |
|
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
44 |
describe "when restarting" do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
45 |
+ context 'with :kernelrelease == 5.10' do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
46 |
+ it "should call 'svcadm restart /system/myservice'" do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
47 |
+ Facter.clear |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
48 |
+ Facter.stubs(:fact).with(:kernelrelease).returns Facter.add(:kernelrelease) { setcode { '5.10' } } |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
49 |
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true) |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
50 |
+ @provider.restart |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
51 |
+ end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
52 |
+ end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
53 |
+ context 'with :kernelrelease == 5.11' do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
54 |
+ it "should call 'svcadm restart -s /system/myservice'" do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
55 |
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "-s", "/system/myservice"], true) |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
56 |
+ @provider.restart |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
57 |
+ end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
58 |
+ end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
59 |
+ context 'with :kernelrelease >= 5.11' do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
60 |
+ it "should call 'svcadm restart -s /system/myservice'" do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
61 |
+ Facter.clear |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
62 |
+ Facter.stubs(:fact).with(:kernelrelease).returns Facter.add(:kernelrelease) { setcode { '5.12' } } |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
63 |
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "-s", "/system/myservice"], true) |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
64 |
+ @provider.restart |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
65 |
+ end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
66 |
+ end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
67 |
it "should call 'svcadm restart /system/myservice'" do |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
68 |
- @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true) |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
69 |
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "-s", "/system/myservice"], true) |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
70 |
@provider.restart |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
71 |
end |
06703eb0e31f
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
Shawn Ferry <shawn.ferry@oracle.com>
parents:
diff
changeset
|
72 |
end |