23099224 The SMF provider needs to add the '-s' flag to the restartcmd method
authorShawn Ferry <shawn.ferry@oracle.com>
Tue, 26 Apr 2016 23:36:26 -0400
changeset 5864 06703eb0e31f
parent 5863 9108cc241851
child 5865 3e9949415308
23099224 The SMF provider needs to add the '-s' flag to the restartcmd method 23099209 The SMF provider should set has_feature :refreshable
components/ruby/puppet/patches/puppet-13-smf-restartcmd.patch
components/ruby/puppet/patches/puppet-14-smf-refreshable.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ruby/puppet/patches/puppet-13-smf-restartcmd.patch	Tue Apr 26 23:36:26 2016 -0400
@@ -0,0 +1,72 @@
+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
[email protected]@ -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
[email protected]@ -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
+ #
[email protected]@ -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
[email protected]@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ruby/puppet/patches/puppet-14-smf-refreshable.patch	Tue Apr 26 23:36:26 2016 -0400
@@ -0,0 +1,15 @@
+smf understands the concept of refreshable
+PUP-6238 Serivce SMF should declare has_feature :refreshable
+
+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
[email protected]@ -23,6 +23,8 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do
+   commands :adm => "/usr/sbin/svcadm", :svcs => "/usr/bin/svcs"
+   commands :svccfg => "/usr/sbin/svccfg"
+
++  has_feature :refreshable
++
+   def setupservice
+       if resource[:manifest]
+         [command(:svcs), "-l", @resource[:name]]