19145371 link properties continuously reapplied
authorDavid Miner <dave.miner@oracle.com>
Thu, 07 Aug 2014 18:35:12 -0400
changeset 2038 b64efc6f1fe1
parent 2037 3559e1505b2b
child 2039 48227b55e297
19145371 link properties continuously reapplied 19376049 address_object mis-handles down property
components/puppet/files/solaris/lib/puppet/provider/address_object/solaris.rb
components/puppet/files/solaris/lib/puppet/provider/address_properties/solaris.rb
components/puppet/files/solaris/lib/puppet/provider/interface_properties/solaris.rb
components/puppet/files/solaris/lib/puppet/provider/link_properties/solaris.rb
components/puppet/files/solaris/lib/puppet/provider/protocol_properties/solaris.rb
components/puppet/files/solaris/lib/puppet/type/address_object.rb
components/puppet/files/solaris/lib/puppet/type/address_properties.rb
components/puppet/files/solaris/lib/puppet/type/interface_properties.rb
components/puppet/files/solaris/lib/puppet/type/link_properties.rb
components/puppet/files/solaris/lib/puppet/type/protocol_properties.rb
--- a/components/puppet/files/solaris/lib/puppet/provider/address_object/solaris.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/address_object/solaris.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.type(:address_object).provide(:address_object) do
@@ -50,15 +50,20 @@
                 remote = nil
             end
 
+            down = :false
             if state == "ok"
                 enable = :true
-            else
+            elsif state == "disabled"
                 enable = :false
+            elsif state == "down"
+                down = :true
+                enable = :true
             end
 
             new(:name => addrobj,
                 :ensure => :present,
                 :address_type => type,
+                :down => down,
                 :enable => enable,
                 :address => local,
                 :remote_address => remote)
@@ -85,6 +90,30 @@
         end
     end
 
+    def enable=(value)
+        if value == :true
+            ipadm("enable-addr", "-t", @resource[:name])
+        elsif value == :false
+            ipadm("disable-addr", "-t", @resource[:name])
+        end
+    end
+    
+    def is_temp
+        temp = []
+        if @resource[:temporary] == :true
+            temp << "-t"
+        end
+        temp
+    end
+    
+    def down=(value)
+        if value == :true
+            ipadm("down-addr", is_temp, @resource[:name])
+        elsif value == :false
+            ipadm("up-addr", is_temp, @resource[:name])
+        end
+    end
+            
     def add_options
         options = []
         if @resource[:temporary] == :true
@@ -103,8 +132,8 @@
             options << "-a" << "remote=#{remote_address}"
         end
 
-        if down = @resource[:down]
-            options << "-d" << down
+        if @resource[:down] == :true
+            options << "-d"
         end
 
         if seconds = @resource[:seconds]
@@ -139,9 +168,6 @@
 
     def create
         ipadm("create-addr", add_options, @resource[:name])
-        if @resource[:enable] == :true
-            ipadm("enable-addr", @resource[:name])
-        end
     end
 
     def destroy
--- a/components/puppet/files/solaris/lib/puppet/provider/address_properties/solaris.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/address_properties/solaris.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.type(:address_properties).provide(:address_properties) do
@@ -73,9 +73,15 @@
     end
 
     def properties=(value)
-        value.each do |key, value|
-            ipadm("set-addrprop", "-p", "#{key}=#{value}", @resource[:name])
+        ipadm("set-addrprop", add_properties(value), @resource[:name])
+    end
+
+    def add_properties(props)
+        a = []
+        props.each do |key, value|
+            a << "#{key}=#{value}"
         end
+        properties = Array["-p", a.join(",")]
     end
 
     def exists?
@@ -101,9 +107,7 @@
     end
 
     def create
-        @addrprops.each do |key, value|
-            ipadm("set-addrprop", "-p", "#{key}=#{value}", @resource[:address])
-        end
+        ipadm("set-addrprop", add_properties(@addrprops), @resource[:address])
     end
 
     def exec_cmd(*cmd)
--- a/components/puppet/files/solaris/lib/puppet/provider/interface_properties/solaris.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/interface_properties/solaris.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.type(:interface_properties).provide(:interface_properties) do
@@ -73,9 +73,15 @@
     end
 
     def properties=(value)
-        value.each do |key, value|
-            ipadm("set-ifprop", "-p", "#{key}=#{value}", @resource[:name])
+        ipadm("set-ifprop", add_properties(value), @resource[:name])
+    end
+
+    def add_properties(props)
+        a = []
+        props.each do |key, value|
+            a << "#{key}=#{value}"
         end
+        properties = Array["-p", a.join(",")]
     end
 
     def exists?
@@ -105,9 +111,7 @@
 
     def create
         name, proto = @resource[:interface].split("/")
-        @ifprops.each do |key, value|
-            ipadm("set-ifprop", "-m", proto, "-p", "#{key}=#{value}", name)
-        end
+        ipadm("set-ifprop", "-m", proto, add_properties(@ifprops), name)
     end
 
     def exec_cmd(*cmd)
--- a/components/puppet/files/solaris/lib/puppet/provider/link_properties/solaris.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/link_properties/solaris.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.type(:link_properties).provide(:link_properties) do
@@ -52,23 +52,26 @@
         end
     end
 
+    def self.prefetch(resources)
+        instances.each do |prov|
+            if resource = resources[prov.name]
+                resource.provider = prov
+            end
+        end
+    end
+
     def properties
         @property_hash[:properties]
     end
 
     def properties=(value)
-        value.each do |key, value|
-            dladm("set-linkprop", "-p", "#{key}=#{value}", @resource[:name])
-        end
+        dladm("set-linkprop", add_properties(value), @resource[:name])
     end
 
-    def add_properties
-        return [] if not @linkprops
-        if @linkprops
-            a = []
-            @linkprops.each do |key, value|
-                a << "#{key}=#{value}"
-            end
+    def add_properties(props)
+        a = []
+        props.each do |key, value|
+            a << "#{key}=#{value}"
         end
         properties = Array["-p", a.join(",")]
     end
@@ -96,7 +99,9 @@
     end
 
     def create
-        dladm("set-linkprop", add_properties, @resource[:link])
+        if @linkprops
+            dladm("set-linkprop", add_properties(@linkprops), @resource[:link])
+        end
     end
 
     def exec_cmd(*cmd)
@@ -104,3 +109,4 @@
         {:out => output, :exit => $CHILD_STATUS.exitstatus}
     end
 end
+
--- a/components/puppet/files/solaris/lib/puppet/provider/protocol_properties/solaris.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/protocol_properties/solaris.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.type(:protocol_properties).provide(:protocol_properties) do
@@ -73,11 +73,17 @@
     end
 
     def properties=(value)
-        value.each do |key, value|
-            ipadm("set-prop", "-p", "#{key}=#{value}", @resource[:name])
-        end
+        ipadm("set-prop", "-p", add_properties(value), @resource[:name])
     end
 
+    def add_properties(props)
+        a = []
+        props.each do |key, value|
+            a << "#{key}=#{value}"
+        end
+        properties = Array["-p", a.join(",")]
+    end
+    
     def exists?
         if @resource[:properties] == nil
             return :false
@@ -101,9 +107,7 @@
     end
 
     def create
-        @protoprops.each do |key, value|
-            ipadm("set-prop", "-p", "#{key}=#{value}", @resource[:name])
-        end
+        ipadm("set-prop", add_properties(@protoprops), @resource[:name])
     end
 
     def exec_cmd(*cmd)
--- a/components/puppet/files/solaris/lib/puppet/type/address_object.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/address_object.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -35,8 +35,7 @@
 
     newparam(:temporary) do
         desc "Optional parameter that specifies that the address object is
-              temporary.  Temporary aggregation links last until the next
-              reboot."
+              temporary.  Temporary address objects last until the next reboot."
         newvalues(:true, :false)
     end
 
@@ -48,7 +47,8 @@
     end
 
     newproperty(:enable) do
-        desc "Specifies the address object should be enabled or disabled."
+        desc "Specifies the address object should be enabled or disabled.
+              This property is only applied temporarily, until next reboot."
         newvalues(:true, :false)
     end
 
--- a/components/puppet/files/solaris/lib/puppet/type/address_properties.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/address_properties.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.newtype(:address_properties) do
@@ -47,5 +47,14 @@
     newproperty(:properties) do
         desc "A hash table of propname=propvalue entries to apply to an
               address object"
+
+        def property_matches?(current, desired)
+            desired.each do |key, value|
+                if current[key] != value
+                    return :false
+                end
+            end
+            return :true
+        end
     end
 end
--- a/components/puppet/files/solaris/lib/puppet/type/interface_properties.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/interface_properties.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -53,5 +53,14 @@
     newproperty(:properties) do
         desc "A hash table of propname=propvalue entries to apply to the
               interface"
+
+        def property_matches?(current, desired)
+            desired.each do |key, value|
+                if current[key] != value
+                    return :false
+                end
+            end
+            return :true
+        end
     end
 end
--- a/components/puppet/files/solaris/lib/puppet/type/link_properties.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/link_properties.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -41,5 +41,14 @@
 
     newproperty(:properties) do
         desc "A hash table of propname=propvalue entries to apply to the link"
+        
+        def property_matches?(current, desired)
+            desired.each do |key, value|
+                if current[key] != value
+                    return :false
+                end
+            end
+            return :true
+        end
     end
 end
--- a/components/puppet/files/solaris/lib/puppet/type/protocol_properties.rb	Fri Aug 08 05:49:12 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/protocol_properties.rb	Thu Aug 07 18:35:12 2014 -0400
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.newtype(:protocol_properties) do
@@ -47,5 +47,14 @@
     newproperty(:properties) do
         desc "A hash table of propname=propvalue entries to apply to an
               protocol"
+
+        def property_matches?(current, desired)
+            desired.each do |key, value|
+                if current[key] != value
+                    return :false
+                end
+            end
+            return :true
+        end
     end
 end