19547272 PUPPET pkg_publisher resource provider type fails s11u3-sru
authorSowrabha H G<sowrabha.hg@oracle.com>
Tue, 03 May 2016 02:32:08 -0700
branchs11u3-sru
changeset 5905 085130968f36
parent 5883 e4ca97d40c81
child 5906 ec8d1b679416
19547272 PUPPET pkg_publisher resource provider type fails
components/ruby/puppet/files/solaris/lib/puppet/provider/pkg_publisher/solaris.rb
components/ruby/puppet/files/solaris/lib/puppet/type/pkg_publisher.rb
--- a/components/ruby/puppet/files/solaris/lib/puppet/provider/pkg_publisher/solaris.rb	Fri Apr 29 08:21:43 2016 -0700
+++ b/components/ruby/puppet/files/solaris/lib/puppet/provider/pkg_publisher/solaris.rb	Tue May 03 02:32:08 2016 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.type(:pkg_publisher).provide(:pkg_publisher) do
@@ -40,7 +40,6 @@
             if not publisher_order.include?("name")
                 publisher_order << name
             end
-
             # strip off any trailing "/" characters
             if origin.end_with?("/")
                 origin = origin[0..-2]
@@ -49,11 +48,24 @@
             if publishers.has_key?(name)
                 # if we've seen this publisher before, simply update the origin
                 # array
-                publishers[name]["origin"] << origin
+	        if type.eql? "mirror"
+                    publishers[name]["mirror"] << origin
+		else
+                    publishers[name]["origin"] << origin
+		end
+
             else
                 # create a new hash entry for this publisher
                 publishers[name] = {'sticky' => sticky, 'enable' => enabled,
-                                    'origin' => Array[origin]}
+                                    'origin' => Array[],
+				    'mirror' => Array[]}
+					
+		if type.eql? "mirror"
+                    publishers[name]["mirror"] << origin
+		else
+                    publishers[name]["origin"] << origin
+		end
+
                 publishers[name]["proxy"] = proxy if proxy != "-"
 
                 index = publisher_order.index(name)
@@ -66,7 +78,6 @@
                 end
             end
         end
-
         # create new entries for the system
         publishers.keys.collect do |publisher|
             new(:name => publisher,
@@ -74,6 +85,7 @@
                 :sticky => publishers[publisher]["sticky"],
                 :enable => publishers[publisher]["enable"],
                 :origin => publishers[publisher]["origin"],
+                :mirror => publishers[publisher]["mirror"],
                 :proxy => publishers[publisher]["proxy"],
                 :searchfirst => publishers[publisher]["searchfirst"],
                 :searchafter => publishers[publisher]["searchafter"],
@@ -97,7 +109,7 @@
 
     # property getters - each getter does exactly the same thing so create
     # dynamic methods to handle them
-    [:sticky, :enable, :origin, :proxy, :searchfirst, :searchafter,
+    [:sticky, :enable, :origin, :mirror, :proxy, :searchfirst, :searchafter,
      :searchbefore, :sslkey, :sslcert].each do |property|
         define_method(property) do
             begin
@@ -117,17 +129,32 @@
 
     def build_origin
         origins = []
-        
-        # add all the origins from the manifest
-        for o in @resource[:origin] do
-            origins << "-g" << o
-        end
+	
+        # add all the origins from the manifest 
+        if !@resource[:origin].nil?
+	   for o in @resource[:origin] do
+               origins << "-g" << o
+           end
+	end
 
-        # remove all the existing origins
+        # add all the mirrors from the manifest 
+	if !@resource[:mirror].nil?
+	    for o in @resource[:mirror] do
+                origins << "-m" << o
+            end
+	end
+        # remove all the existing origins and mirrors
         if @property_hash != {}
-            for o in @property_hash[:origin] do
-                origins << "-G" << o
-            end
+           if !@property_hash[:origin].nil?
+              for o in @property_hash[:origin] do
+                  origins << "-G" << o
+              end
+	   end
+           if !@property_hash[:mirror].nil?
+              for o in @property_hash[:mirror] do
+                  origins << "-M" << o
+              end
+           end
         end
         origins
     end
@@ -237,6 +264,10 @@
             end
         end
     end
+    
+    def mirror=(value)
+        create
+    end
 
     def destroy
         pkg("unset-publisher", @resource[:name])
--- a/components/ruby/puppet/files/solaris/lib/puppet/type/pkg_publisher.rb	Fri Apr 29 08:21:43 2016 -0700
+++ b/components/ruby/puppet/files/solaris/lib/puppet/type/pkg_publisher.rb	Tue May 03 02:32:08 2016 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 #
 
 require 'puppet/property/list'
@@ -61,7 +61,6 @@
             end
         end
     end
-
     newproperty(:enable) do
         desc "Enable the publisher"
         newvalues(:true, :false)
@@ -99,4 +98,31 @@
     newproperty(:sslcert) do
         desc "Specify the client SSL certificate"
     end
+
+    newproperty(:mirror, :parent => Puppet::Property::List) do
+        desc "Which mirror URI(s) to set.  For multiple mirrors, specify them
+              as a list"
+	
+        # ensure should remains an array
+        def should
+            @should
+        end
+
+        def insync?(is)
+            is = [] if is == :absent or is.nil?
+            is.sort == self.should.sort
+        end
+
+        def retrieve
+            provider.mirror
+        end
+        
+        munge do |value|
+            if value.start_with? "file" and value.end_with? "/"
+                value = value.chomp("/")
+            else
+                value
+            end
+        end
+    end
 end