summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Shafer <andrew@reductivelabs.com>2008-12-01 02:58:09 -0700
committerJames Turnbull <james@lovedthanlost.net>2008-12-01 21:00:27 +1100
commit3eff2254e69cf66b6e9f94631900fba26172c850 (patch)
treef7a994f9f3d9f7338993e7aa3bf01da09bebcd2d
parentfa9820baaebe29675defb14bc9d64f6cb9b75211 (diff)
downloadpuppet-3eff2254e69cf66b6e9f94631900fba26172c850.tar.gz
puppet-3eff2254e69cf66b6e9f94631900fba26172c850.tar.xz
puppet-3eff2254e69cf66b6e9f94631900fba26172c850.zip
Feature 1696 Add support for branded zones
Applied the patch from the ticket and wrote tests with the changes
-rw-r--r--lib/puppet/provider/zone/solaris.rb11
-rw-r--r--lib/puppet/type/zone.rb8
-rwxr-xr-xspec/unit/provider/zone/solaris.rb42
-rwxr-xr-xspec/unit/type/zone.rb20
4 files changed, 77 insertions, 4 deletions
diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb
index 24bbb99ec..a5a18198c 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 7601ec47b..8c4261241 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 000000000..b7dd74705
--- /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/zone.rb b/spec/unit/type/zone.rb
new file mode 100755
index 000000000..c99302644
--- /dev/null
+++ b/spec/unit/type/zone.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+zone = Puppet::Type.type(:zone)
+
+describe zone do
+ before do
+ @provider = stub 'provider'
+ @resource = stub 'resource', :resource => nil, :provider => @provider, :line => nil, :file => nil
+ end
+
+ parameters = [:create_args, :install_args]
+
+ parameters.each do |parameter|
+ it "should have a %s parameter" % parameter do
+ zone.attrclass(parameter).ancestors.should be_include(Puppet::Parameter)
+ end
+ end
+end