summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/feature/base.rb2
-rw-r--r--lib/puppet/provider.rb1
-rw-r--r--lib/puppet/provider/zone/solaris.rb91
-rw-r--r--lib/puppet/type.rb5
-rw-r--r--lib/puppet/type/pfile.rb2
5 files changed, 72 insertions, 29 deletions
diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb
index 98c285148..97200cb39 100644
--- a/lib/puppet/feature/base.rb
+++ b/lib/puppet/feature/base.rb
@@ -18,6 +18,6 @@ Puppet.features.add(:libshadow, :libs => ["shadow"])
Puppet.features.add(:root) { require 'puppet/util/suidmanager'; Puppet::Util::SUIDManager.uid == 0 }
# We've got mongrel available
-Puppet.features.add(:mongrel, :libs => %w{rubygems mongrel})
+Puppet.features.add(:mongrel, :libs => %w{rubygems mongrel puppet/network/server/mongrel})
# $Id$
diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb
index 3e23bf08a..612d8adc6 100644
--- a/lib/puppet/provider.rb
+++ b/lib/puppet/provider.rb
@@ -157,6 +157,7 @@ class Puppet::Provider
def self.mk_resource_methods
[resource_type.validproperties, resource_type.parameters].flatten.each do |attr|
attr = symbolize(attr)
+ next if attr == :name
define_method(attr) do
@property_hash[attr] || :absent
end
diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb
index d178679fe..5c89b86d9 100644
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@ -4,28 +4,30 @@ Puppet::Type.type(:zone).provide(:solaris) do
commands :adm => "/usr/sbin/zoneadm", :cfg => "/usr/sbin/zonecfg"
defaultfor :operatingsystem => :solaris
+ mk_resource_methods
+
# Convert the output of a list into a hash
def self.line2hash(line)
fields = [:id, :name, :ensure, :path]
- hash = {}
+ properties = {}
line.split(":").each_with_index { |value, index|
- hash[fields[index]] = value
+ properties[fields[index]] = value
}
# Configured but not installed zones do not have IDs
- if hash[:id] == "-"
- hash.delete(:id)
+ if properties[:id] == "-"
+ properties.delete(:id)
end
- return hash
+ properties[:ensure] = symbolize(properties[:ensure])
+
+ return properties
end
def self.instances
adm(:list, "-cp").split("\n").collect do |line|
- hash = line2hash(line)
-
- new(hash)
+ new(line2hash(line))
end
end
@@ -39,7 +41,7 @@ set zonepath=%s
# Then perform all of our configuration steps. It's annoying
# that we need this much internal info on the resource.
@resource.send(:properties).each do |property|
- if property.is_a? ZoneConfigProperty and ! property.insync?
+ if property.is_a? ZoneConfigProperty and ! property.insync?(properties[property.name])
str += property.configtext + "\n"
end
end
@@ -52,14 +54,39 @@ set zonepath=%s
zonecfg :delete, "-F"
end
+ def exists?
+ properties[:ensure] != :absent
+ end
+
+ # Clear out the cached values.
+ def flush
+ @property_hash.clear
+ end
+
def install
zoneadm :install
end
+ # Look up the current status.
+ def properties
+ if @property_hash.empty?
+ @property_hash = status || {}
+ if @property_hash.empty?
+ @property_hash[:ensure] = :absent
+ else
+ @resource.class.validproperties.each do |name|
+ @property_hash[name] ||= :absent
+ end
+ end
+
+ end
+ @property_hash.dup
+ end
+
# We need a way to test whether a zone is in process. Our 'ensure'
# property models the static states, but we need to handle the temporary ones.
def processing?
- if hash = statushash()
+ if hash = status()
case hash[:ensure]
when "incomplete", "ready", "shutting_down"
true
@@ -103,16 +130,8 @@ set zonepath=%s
debug "Ignoring zone output '%s'" % line
end
end
- return hash
- end
- def retrieve
- if hash = statushash()
- setstatus(hash)
-
- # Now retrieve the configuration itself and set appropriately.
- getconfig()
- end
+ return hash
end
# Execute a configuration string. Can't be private because it's called
@@ -152,14 +171,21 @@ set zonepath=%s
end
# Return a hash of the current status of this zone.
- def statushash
+ def status
begin
output = adm "-z", @resource[:name], :list, "-p"
rescue Puppet::ExecutionFailure
return nil
end
- return self.class.line2hash(output.chomp)
+ main = self.class.line2hash(output.chomp)
+
+ # Now add in the configuration information
+ config_status.each do |name, value|
+ main[name] = value
+ end
+
+ main
end
def stop
@@ -176,6 +202,24 @@ set zonepath=%s
private
+ # Turn the results of getconfig into status information.
+ def config_status
+ config = getconfig()
+ result = {}
+
+ result[:autoboot] = config[:autoboot] ? config[:autoboot].intern : :absent
+ result[:pool] = config[:pool]
+ result[:shares] = config[:shares]
+ if dir = config["inherit-pkg-dir"]
+ result[:inherit] = dir.collect { |dirs| dirs[:dir] }
+ end
+ if net = config["net"]
+ result[:ip] = net.collect { |params| "%s:%s" % [params[:physical], params[:address]] }
+ end
+
+ result
+ end
+
def zoneadm(*cmd)
begin
adm("-z", @resource[:name], *cmd)
@@ -185,8 +229,11 @@ set zonepath=%s
end
def zonecfg(*cmd)
+ # You apparently can't get the configuration of the global zone
+ return "" if self.name == "global"
+
begin
- cfg("-z", @resource[:name], *cmd)
+ cfg("-z", self.name, *cmd)
rescue Puppet::ExecutionFailure => detail
self.fail "Could not %s zone: %s" % [cmd[0], detail]
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index d8e03ceca..fe0fc2810 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -346,11 +346,6 @@ class Type < Puppet::Element
# Convert to a transportable object
def to_trans(ret = true)
- # Retrieve the object, if they tell use to.
- if ret
- retrieve()
- end
-
trans = TransObject.new(self.title, self.class.name)
values = retrieve()
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index 3a07a9342..374cde3e8 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -968,7 +968,7 @@ module Puppet
# We have to hack this just a little bit, because otherwise we'll get
# an error when the target and the contents are created as properties on
# the far side.
- def to_trans
+ def to_trans(retrieve = true)
obj = super
if obj[:target] == :notlink
obj.delete(:target)