[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

Andrew Shafer andrew at reductivelabs.com
Fri Jan 23 14:21:57 UTC 2009


The following commit has been merged in the master branch:
commit 7e2da7eeb25bb8879af40f12c4a04047a159374e
Author: Andrew Shafer <andrew at reductivelabs.com>
Date:   Sun Dec 7 22:41:45 2008 -0700

    Refactor #1802 Use 'zfs get -H -o value' instead of parsing output for value
    
    just simplifying code

diff --git a/lib/puppet/provider/zfs/solaris.rb b/lib/puppet/provider/zfs/solaris.rb
index 4d382cf..256e4e9 100644
--- a/lib/puppet/provider/zfs/solaris.rb
+++ b/lib/puppet/provider/zfs/solaris.rb
@@ -15,14 +15,6 @@ Puppet::Type.type(:zfs).provide(:solaris) do
         properties
     end
 
-    def arrayify_second_line_on_whitespace(text)
-        if second_line = text.split("\n")[1]
-            second_line.split("\s")
-        else
-            []
-        end
-    end
-
     def create
         zfs *([:create] + add_properties + [@resource[:name]])
     end
@@ -41,10 +33,7 @@ Puppet::Type.type(:zfs).provide(:solaris) do
 
     [:mountpoint, :compression, :copies, :quota, :reservation, :sharenfs, :snapdir].each do |field|
         define_method(field) do
-            #special knowledge of format
-            #the command returns values in this format with the header
-            #NAME PROPERTY VALUE SOURCE
-            arrayify_second_line_on_whitespace(zfs(:get, field, @resource[:name]))[2]
+            zfs(:get, "-H", "-o", "value", field, @resource[:name]).strip
         end
 
         define_method(field.to_s + "=") do |should|
diff --git a/spec/unit/provider/zfs/solaris.rb b/spec/unit/provider/zfs/solaris.rb
index 63aefcd..9189e44 100755
--- a/spec/unit/provider/zfs/solaris.rb
+++ b/spec/unit/provider/zfs/solaris.rb
@@ -66,12 +66,12 @@ describe provider_class do
     [:mountpoint, :compression, :copies, :quota, :reservation, :sharenfs, :snapdir].each do |prop|
         describe "when getting the #{prop} value" do
             it "should call zfs with :get, #{prop} and this zfs" do
-                @provider.expects(:zfs).with(:get, prop, @resource[:name]).returns("NAME PROPERTY VALUE SOURCE\nmyzfs name value blah")
+                @provider.expects(:zfs).with(:get, "-H", "-o", "value", prop, @resource[:name]).returns("value\n")
                 @provider.send(prop)
             end
 
             it "should get the third value of the second line from the output" do
-                @provider.stubs(:zfs).with(:get, prop, @resource[:name]).returns("NAME PROPERTY VALUE SOURCE\nmyzfs name value blah")
+                @provider.stubs(:zfs).with(:get, "-H", "-o", "value", prop, @resource[:name]).returns("value\n")
                 @provider.send(prop).should == "value"
             end
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list