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

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:21:51 UTC 2009


The following commit has been merged in the master branch:
commit 3eff2254e69cf66b6e9f94631900fba26172c850
Author: Andrew Shafer <andrew at reductivelabs.com>
Date:   Mon Dec 1 02:58:09 2008 -0700

    Feature 1696 Add support for branded zones
    
    Applied the patch from the ticket and wrote tests with the changes

diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb
index 24bbb99..a5a1819 100644
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@ -36,9 +36,8 @@ Puppet::Type.type(:zone).provide(:solaris) do
     # Perform all of our configuration steps.
     def configure
         # If the thing is entirely absent, then we need to create the config.
-        str = %{create -b
-set zonepath=%s
-} % @resource[:path]
+        # Is there someway to get this on one line?
+        str = "create -b #{@resource[:create_args]}\nset zonepath=%s\n" % @resource[:path]
 
         # Then perform all of our configuration steps.  It's annoying
         # that we need this much internal info on the resource.
@@ -66,7 +65,11 @@ set zonepath=%s
     end
 
     def install
-        zoneadm :install
+        if @resource[:install_args]
+            zoneadm :install, @resource[:install_args].split(" ")
+        else
+            zoneadm :install
+        end
     end
 
     # Look up the current status.
diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb
index 7601ec4..8c42612 100644
--- a/lib/puppet/type/zone.rb
+++ b/lib/puppet/type/zone.rb
@@ -357,6 +357,14 @@ end
         end
     end
 
+    newparam(:create_args) do
+        desc "Arguments to the zonecfg create command.  This can be used to create branded zones."
+    end
+    
+    newparam(:install_args) do
+        desc "Arguments to the zoneadm install command.  This can be used to create branded zones."
+    end
+
     newparam(:realhostname) do
         desc "The actual hostname of the zone."
     end
diff --git a/spec/unit/provider/zone/solaris.rb b/spec/unit/provider/zone/solaris.rb
new file mode 100755
index 0000000..b7dd747
--- /dev/null
+++ b/spec/unit/provider/zone/solaris.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider_class = Puppet::Type.type(:zone).provider(:solaris)
+
+describe provider_class do
+    before do
+        @resource = stub("resource", :name => "mypool")
+        @resource.stubs(:[]).returns "shouldvalue"
+        @provider = provider_class.new(@resource)
+    end
+
+    describe "when calling configure" do
+        it "should add the create args to the create str" do
+            @resource.stubs(:properties).returns([])
+            @resource.stubs(:[]).with(:create_args).returns("create_args")
+            @provider.expects(:setconfig).with("create -b create_args\nset zonepath=shouldvalue\ncommit\n")
+            @provider.configure
+        end
+    end
+
+    describe "when installing" do
+        it "should call zoneadm" do
+            @provider.expects(:zoneadm)
+            @provider.install
+        end
+        
+        it "should just install if there are no install args" do
+            @resource.stubs(:[]).with(:install_args).returns(nil)
+            @provider.expects(:zoneadm).with(:install)
+            @provider.install
+        end
+
+        it "should add the install args to the command if they exist" do
+            @resource.stubs(:[]).with(:install_args).returns("install args")
+            @provider.expects(:zoneadm).with(:install, ["install", "args"])
+            @provider.install
+        end
+    end
+
+end
diff --git a/spec/unit/type/zpool.rb b/spec/unit/type/zone.rb
similarity index 50%
copy from spec/unit/type/zpool.rb
copy to spec/unit/type/zone.rb
index 6477d06..c993026 100755
--- a/spec/unit/type/zpool.rb
+++ b/spec/unit/type/zone.rb
@@ -2,27 +2,19 @@
 
 Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
 
-zpool = Puppet::Type.type(:zpool)
+zone = Puppet::Type.type(:zone)
 
-describe zpool do
+describe zone do
     before do
         @provider = stub 'provider'
         @resource = stub 'resource', :resource => nil, :provider => @provider, :line => nil, :file => nil
     end
 
-    properties = [:ensure, :disk, :mirror, :raidz, :spare, :log]
-
-    properties.each do |property|
-        it "should have a %s property" % property do
-            zpool.attrclass(property).ancestors.should be_include(Puppet::Property)
-        end
-    end
-
-    parameters = [:pool, :raid_parity]
+    parameters = [:create_args, :install_args]
 
     parameters.each do |parameter|
         it "should have a %s parameter" % parameter do
-            zpool.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
+            zone.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
         end
     end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list