components/ruby/puppet/files/solaris/lib/puppet/provider/pkg_publisher/solaris.rb
branchs11u3-sru
changeset 5905 085130968f36
parent 3458 4912663e9858
--- 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])