18896910 VNIC resource type can't handle dash characters in name.
authorDrew Fisher <drew.fisher@oracle.com>
Mon, 21 Jul 2014 11:25:46 -0600
changeset 2004 2a230bc62c46
parent 2003 81f9a60cccb1
child 2005 ef2abe232400
18896910 VNIC resource type can't handle dash characters in name. 19261753 ldap resource type fails on cred/bind_passwd
components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb
components/puppet/files/solaris/lib/puppet/provider/vnic/solaris.rb
--- a/components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb	Tue Jul 15 07:20:42 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb	Mon Jul 21 11:25:46 2014 -0600
@@ -56,8 +56,15 @@
             pg, prop = fullprop.split("/")
             props[prop] = value if validprops.include? prop.to_sym
         end
-        props[:bind_passwd] = svcprop("-p", "cred/bind_passwd",
-                                      "svc:/network/ldap/client").strip
+
+        # attempt to set the cred/bind_passwd value
+        begin
+            props[:bind_passwd] = svcprop("-p", "cred/bind_passwd",
+                                          "svc:/network/ldap/client").strip()
+        rescue
+            props[:bind_passwd] = nil
+        end
+
         props[:name] = "current"
         return Array new(props)
     end
--- a/components/puppet/files/solaris/lib/puppet/provider/vnic/solaris.rb	Tue Jul 15 07:20:42 2014 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/vnic/solaris.rb	Mon Jul 21 11:25:46 2014 -0600
@@ -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(:vnic).provide(:vnic) do
@@ -30,14 +30,18 @@
     commands :dladm => '/usr/sbin/dladm'
 
     def self.instances
+        vnics = []
         dladm("show-vnic", "-p", "-o", "link,over,macaddress").split(
               "\n").collect do |line|
             link, over, mac = line.split(":", 3)
-            new(:name => link,
-                :ensure => :present,
-                :lower_link => over,
-                :mac_address => mac.delete("\\"))  # remove the escape character
+            next if not link =~ /^[[:alpha:]]([\w.]){1,29}([\d])$/i
+            # remove the escape character
+            vnics << new(:name => link,
+                         :ensure => :present,
+                         :lower_link => over,
+                         :mac_address => mac.delete("\\"))
         end
+        vnics
     end
         
     def self.prefetch(resources)