Add -s for synchronous restart
Upstream as PUP-6233
@@ -66,7 +71,12 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
end
def restartcmd
- [command(:adm), :restart, @resource[:name]]
+ if Puppet::Util::Package.versioncmp(Facter.value(:kernelrelease), '5.11') >= 0
+ [command(:adm), :restart, "-s", @resource[:name]]
+ else
+ # Solaris 10 does not have synchronous restart
+ [command(:adm), :restart, @resource[:name]]
+ end
end
def startcmd
@@ -1,4 +1,7 @@
#! /usr/bin/env ruby
+#######################################################################
+# Oracle has modified the originally distributed contents of this file.
+#######################################################################
#
# Unit testing for the SMF service Provider
#
@@ -20,6 +23,8 @@ describe provider_class, :as_platform => :posix do
FileTest.stubs(:executable?).with('/usr/sbin/svcadm').returns true
FileTest.stubs(:file?).with('/usr/bin/svcs').returns true
FileTest.stubs(:executable?).with('/usr/bin/svcs').returns true
+ Facter.stubs(:fact).with(:kernelrelease).returns Facter.add(:kernelrelease) { setcode { '5.11' } }
end
describe ".instances" do
@@ -144,8 +149,30 @@ describe provider_class, :as_platform => :posix do
end
describe "when restarting" do
+ context 'with :kernelrelease == 5.10' do
+ it "should call 'svcadm restart /system/myservice'" do
+ Facter.stubs(:fact).with(:kernelrelease).returns Facter.add(:kernelrelease) { setcode { '5.10' } }
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true)
+ end
+ end
+ context 'with :kernelrelease == 5.11' do
+ it "should call 'svcadm restart -s /system/myservice'" do
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "-s", "/system/myservice"], true)
+ end
+ end
+ context 'with :kernelrelease >= 5.11' do
+ it "should call 'svcadm restart -s /system/myservice'" do
+ Facter.stubs(:fact).with(:kernelrelease).returns Facter.add(:kernelrelease) { setcode { '5.12' } }
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "-s", "/system/myservice"], true)
+ end
+ end
it "should call 'svcadm restart /system/myservice'" do
- @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true)
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "-s", "/system/myservice"], true)
end
end