Add -s for synchronous restart
Upstream as PUP-6233
diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb
--- a/lib/puppet/provider/service/smf.rb
+++ b/lib/puppet/provider/service/smf.rb
@@ -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
diff --git a/spec/unit/provider/service/smf_spec.rb b/spec/unit/provider/service/smf_spec.rb
--- a/spec/unit/provider/service/smf_spec.rb
+++ b/spec/unit/provider/service/smf_spec.rb
@@ -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.clear
+ 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.clear
+ Facter.stubs(:fact).with(:kernelrelease).returns Facter.add(:kernelrelease) { setcode { '5.10' } }
+ @provider.expects(:texecute).with(:restart, ["/usr/sbin/svcadm", :restart, "/system/myservice"], true)
+ @provider.restart
+ 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)
+ @provider.restart
+ end
+ end
+ context 'with :kernelrelease >= 5.11' do
+ it "should call 'svcadm restart -s /system/myservice'" do
+ Facter.clear
+ 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)
+ @provider.restart
+ 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)
@provider.restart
end
end