--- a/components/puppet/files/solaris/lib/puppet/provider/dns/solaris.rb Thu Jan 09 03:35:51 2014 -0800
+++ b/components/puppet/files/solaris/lib/puppet/provider/dns/solaris.rb Fri Jan 31 14:12:10 2014 -0700
@@ -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(:dns).provide(:dns) do
@@ -29,12 +29,11 @@
defaultfor :osfamily => :solaris, :kernelrelease => ['5.11', '5.12']
commands :svccfg => '/usr/sbin/svccfg', :svcprop => '/usr/bin/svcprop'
- class << self; attr_accessor :dns_fmri end
- @@dns_fmri = "svc:/network/dns/client"
+ Dns_fmri = "svc:/network/dns/client"
def self.instances
props = {}
- svcprop("-p", "config", @@dns_fmri).split("\n").each do |line|
+ svcprop("-p", "config", Dns_fmri).split("\n").each do |line|
fullprop, type, value = line.split(" ", 2)
pg, prop = fullprop.split("/")
props[prop] = value \
@@ -48,7 +47,7 @@
Puppet::Type.type(:dns).validproperties.each do |field|
define_method(field) do
begin
- svcprop("-p", "config/" + field.to_s, @@dns_fmri).strip()
+ svcprop("-p", "config/" + field.to_s, Dns_fmri).strip()
rescue
# if the property isn't set, don't raise an error
nil
@@ -58,18 +57,27 @@
define_method(field.to_s + "=") do |should|
begin
if should.is_a? Array
- # the first entry needs the open paren and the last entry
- # needs the close paren
- should[0] = "(" + should[0]
- should[-1] = should[-1] + ")"
-
- svccfg("-s", @@dns_fmri, "setprop",
- "config/" + field.to_s, "=", should)
+ # in Solaris 11, the list of values needs to be single
+ # argument to svccfg.
+ values = ""
+ for entry in should
+ values += "\"#{entry}\" "
+ end
+ values = "(" + values + ")"
+ svccfg("-s", Dns_fmri, "setprop",
+ "config/" + field.to_s, "=", values)
else
- svccfg("-s", @@dns_fmri, "setprop",
- "config/" + field.to_s, "=", '"' + should + '"')
+ # Puppet seems to get confused about when to pass an empty
+ # string or "\"\"". Catch either condition to handle
+ # passing values to SMF correctly
+ if should.to_s.empty? or should.to_s == '""'
+ value = should.to_s
+ else
+ value = "\"" + should.to_s + "\""
+ end
+ svccfg("-s", Dns_fmri, "setprop",
+ "config/" + field.to_s, "=", value)
end
- svccfg("-s", @@dns_fmri, "refresh")
rescue => detail
raise Puppet::Error,
"Unable to set #{field.to_s} to #{should.inspect}\n"
@@ -77,4 +85,8 @@
end
end
end
+
+ def flush
+ svccfg("-s", Dns_fmri, "refresh")
+ end
end