22189175 nis securenets property is not read and/or written properly
authorPatrick Einheber <patrick.einheber@oracle.com>
Tue, 17 Nov 2015 13:03:07 -0800
changeset 5100 fec60e047e04
parent 5099 a14d6941c0c9
child 5101 08e9f23e354f
22189175 nis securenets property is not read and/or written properly
components/ruby/puppet/files/solaris/lib/puppet/provider/nis/solaris.rb
components/ruby/puppet/files/solaris/lib/puppet/type/nis.rb
--- a/components/ruby/puppet/files/solaris/lib/puppet/provider/nis/solaris.rb	Tue Nov 17 12:35:41 2015 -0800
+++ b/components/ruby/puppet/files/solaris/lib/puppet/provider/nis/solaris.rb	Tue Nov 17 13:03:07 2015 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
 #
 
 Puppet::Type.type(:nis).provide(:nis) do
@@ -86,8 +86,40 @@
         end
     end
 
+    [:securenets].each do |field|
+        define_method(field) do
+            begin
+                hash = {}
+                val = svcprop("-p", "config/" + field.to_s, Domain_fmri).strip()
+                arr = val.tr('\\', '').split(/ /)
+                until arr == []
+                  hash[arr[0]] = arr[1]
+                  arr.shift
+                  arr.shift
+                end
+                hash
+            rescue
+                # if the property isn't set, don't raise an error
+                nil
+            end
+        end
+
+        define_method(field.to_s + "=") do |should|
+          arr = []
+          if not should.empty?
+            should.each do |key, value|
+              arr.push('"' + key + " " + value + '"')
+            end
+            arr[0] = "(" + arr[0]
+            arr[-1] = arr[-1] + ")"
+          end
+          svccfg("-s", Domain_fmri, "setprop",
+                           "config/" + field.to_s, "=", arr)
+        end
+   end
+
     # svc:/network/nis/domain properties
-    [:domainname, :ypservers, :securenets].each do |field|
+    [:domainname, :ypservers].each do |field|
         define_method(field) do
             begin
                 svcprop("-p", "config/" + field.to_s, Domain_fmri).strip()
--- a/components/ruby/puppet/files/solaris/lib/puppet/type/nis.rb	Tue Nov 17 12:35:41 2015 -0800
+++ b/components/ruby/puppet/files/solaris/lib/puppet/type/nis.rb	Tue Nov 17 13:03:07 2015 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
 #
 
 require 'ipaddr'
@@ -83,6 +83,19 @@
               The first element in the hash is either a host or a netmask.
               The second element must be an IP network address.  Specify
               multiple entries as separate entries in the hash."
+
+        def insync?(is)
+            is = {} if is == :absent or is.nil?
+            is.sort == self.should.sort
+        end
+
+        def should_to_s(newvalue)
+          newvalue.to_s
+        end
+
+        def is_to_s(currentvalue)
+          currentvalue.to_s
+        end
     end
 
     newproperty(:use_broadcast) do