components/puppet/patches/puppet-02-zone-type.patch
author Virginia Wray <virginia.wray@oracle.com>
Mon, 23 Sep 2013 10:03:20 -0700
branchs11-update
changeset 2771 8e4227dc2fc4
child 2928 43b3da52b84a
permissions -rw-r--r--
16453463 Update Puppet's offerings on Solaris 16979551 Update Puppet to 3.2.2 17242868 Need to set the start method for the Puppet service to default to disabled. 17243548 The puppet.xml template entry needs updating 17257851 nameservice resource types need to stop calling svccfg refresh so much 17263808 Unable to initialize LDAP configuration using profile name 17263843 LDAP parameters do not match expected parameters 17270555 NIS provider returns an error when attempting to set securenets parameter 17271383 NIS provider is not updating domainname property 17277145 nsswitch provider object error and missing parameter 17284016 nis, ldap, and dns refreshed on every Puppet run 17284583 puppet service needs dependency on identity:node 17307127 LDAP provider has an invalid parameter. 17307412 clobber/clean can fail in puppet/ext 17318366 Update Puppet to 3.2.4 17318398 problem in UTILITY/PUPPET

Enhance the zone type to configure zones using a zonecfg export file format.
Enhance the output of the puppet resource zone.

--- puppet-3.2.4/lib/puppet/type/zone.rb.orig	2013-07-16 16:44:01.005467245 -0600
+++ puppet-3.2.4/lib/puppet/type/zone.rb	2013-07-16 16:45:04.216692249 -0600
@@ -1,10 +1,5 @@
-require 'puppet/property/list'
 Puppet::Type.newtype(:zone) do
-  @doc = "Manages Solaris zones.
-
-**Autorequires:** If Puppet is managing the directory specified as the root of
-the zone's filesystem (with the `path` attribute), the zone resource will
-autorequire that directory."
+  @doc = "Manages Solaris zones."
 
   class StateMachine
     # A silly little state machine.
@@ -73,7 +68,7 @@
 
     # This is seq value because the order of declaration is important.
     # i.e we go linearly from :absent -> :configured -> :installed -> :running
-    seqvalue :absent, :down => :destroy
+    seqvalue :absent, :down => :unconfigure
     seqvalue :configured, :up => :configure, :down => :uninstall
     seqvalue :installed, :up => :install, :down => :stop
     seqvalue :running, :up => :start
@@ -102,10 +97,10 @@
         sleep 1
       end
       provider.send(method)
-      provider.flush()
     end
 
     def sync
+
       method = nil
       direction = up? ? :up : :down
 
@@ -129,127 +124,34 @@
 
   newparam(:name) do
     desc "The name of the zone."
-
     isnamevar
   end
 
-  newparam(:id) do
-    desc "The numerical ID of the zone.  This number is autogenerated
-      and cannot be changed."
-  end
-
-  newparam(:clone) do
-    desc "Instead of installing the zone, clone it from another zone.
-      If the zone root resides on a zfs file system, a snapshot will be
-      used to create the clone; if it resides on a ufs filesystem, a copy of the
-      zone will be used. The zone from which you clone must not be running."
-  end
-
-  newproperty(:ip, :parent => Puppet::Property::List) do
-    require 'ipaddr'
-
-    desc "The IP address of the zone.  IP addresses must be specified
-      with the interface, separated by a colon, e.g.: bge0:192.168.0.1.
-      For multiple interfaces, specify them in an array."
-
-    # The default action of list should is to lst.join(' '). By specifying
-    # @should, we ensure the should remains an array. If we override should, we
-    # should also override insync?() -- property/list.rb
-    def should
-      @should
-    end
-
-    # overridden so that we match with self.should
-    def insync?(is)
-      return true unless is
-      is = [] if is == :absent
-      is.sort == self.should.sort
-    end
-  end
-
-  newproperty(:iptype) do
-    desc "The IP stack type of the zone."
-    defaultto :shared
-    newvalue :shared
-    newvalue :exclusive
-  end
-
-  newproperty(:autoboot, :boolean => true) do
-    desc "Whether the zone should automatically boot."
-    defaultto true
-    newvalues(:true, :false)
+  newparam(:config_profile) do
+    desc "Path to the config_profile to use to configure a solaris zone.
+          This is set when providing a sysconfig profile instead of running the
+	  sysconfig SCI tool on first boot of the zone."
   end
 
-  newproperty(:path) do
-    desc "The root of the zone's filesystem.  Must be a fully qualified
-      file name.  If you include `%s` in the path, then it will be
-      replaced with the zone's name.  Currently, you cannot use
-      Puppet to move a zone. Consequently this is a readonly property."
-
-    validate do |value|
-      raise ArgumentError, "The zone base must be fully qualified" unless value =~ /^\//
-    end
-
-    munge do |value|
-      if value =~ /%s/
-        value % @resource[:name]
-      else
-        value
-      end
-    end
-  end
-
-  newproperty(:pool) do
-    desc "The resource pool for this zone."
+  newparam(:zonecfg_export) do
+    desc "Contains the zone configuration information. This can be passed in
+    in the form of a file generated by the zonecfg command, in the form
+    of a template, or a string."
   end
 
-  newproperty(:shares) do
-    desc "Number of FSS CPU shares allocated to the zone."
+  newparam(:archive) do
+    desc "The archive file containing an archived zone."
   end
 
-  newproperty(:dataset, :parent => Puppet::Property::List ) do
-    desc "The list of datasets delegated to the non-global zone from the
-      global zone.  All datasets must be zfs filesystem names which are
-      different from the mountpoint."
-
-    def should
-      @should
-    end
-
-    # overridden so that we match with self.should
-    def insync?(is)
-      return true unless is
-      is = [] if is == :absent
-      is.sort == self.should.sort
-    end
-
-    validate do |value|
-      unless value !~ /^\//
-        raise ArgumentError, "Datasets must be the name of a zfs filesystem"
-      end
-    end
+  newparam(:archived_zonename) do
+    desc "The archived zone to configure and install"
   end
-
-  newproperty(:inherit, :parent => Puppet::Property::List) do
-    desc "The list of directories that the zone inherits from the global
-      zone.  All directories must be fully qualified."
-
-    def should
-      @should
-    end
-
-    # overridden so that we match with self.should
-    def insync?(is)
-      return true unless is
-      is = [] if is == :absent
-      is.sort == self.should.sort
-    end
-
-    validate do |value|
-      unless value =~ /^\//
-        raise ArgumentError, "Inherited filesystems must be fully qualified"
-      end
-    end
+  
+  newparam(:clone) do
+    desc "Instead of installing the zone, clone it from another zone.
+      If the zone root resides on a zfs file system, a snapshot will be
+      used to create the clone; if it resides on a ufs filesystem, a copy of the
+      zone will be used. The zone from which you clone must not be running."
   end
 
   # Specify the sysidcfg file.  This is pretty hackish, because it's
@@ -286,70 +188,11 @@
       so Puppet only checks for it at that time.}
   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
-
-  # If Puppet is also managing the base dir or its parent dir, list them
-  # both as prerequisites.
-  autorequire(:file) do
-    if @parameters.include? :path
-      [@parameters[:path].value, ::File.dirname(@parameters[:path].value)]
-    else
-      nil
-    end
-  end
-
-  # If Puppet is also managing the zfs filesystem which is the zone dataset
-  # then list it as a prerequisite.  Zpool's get autorequired by the zfs
-  # type.  We just need to autorequire the dataset zfs itself as the zfs type
-  # will autorequire all of the zfs parents and zpool.
-  autorequire(:zfs) do
-    # Check if we have datasets in our zone configuration and autorequire each dataset
-    self[:dataset] if @parameters.include? :dataset
-  end
-
-  def validate_ip(ip, name)
-    IPAddr.new(ip) if ip
-  rescue ArgumentError
-    self.fail "'#{ip}' is an invalid #{name}"
-  end
-
-  def validate_exclusive(interface, address, router)
-    return if !interface.nil? and address.nil?
-    self.fail "only interface may be specified when using exclusive IP stack: #{interface}:#{address}"
-  end
-  def validate_shared(interface, address, router)
-    self.fail "ip must contain interface name and ip address separated by a \":\"" if interface.nil? or address.nil?
-    [address, router].each do |ip|
-      validate_ip(address, "IP address") unless ip.nil?
-    end
-  end
-
-  validate do
-    return unless self[:ip]
-    # self[:ip] reflects the type passed from proeprty:ip.should. If we
-    # override it and pass @should, then we get an array here back.
-    self[:ip].each do |ip|
-      interface, address, router = ip.split(':')
-      if self[:iptype] == :shared
-        validate_shared(interface, address, router)
-      else
-        validate_exclusive(interface, address, router)
-      end
-    end
-  end
-
   def retrieve
-    provider.flush
     hash = provider.properties
     return setstatus(hash) unless hash.nil? or hash[:ensure] == :absent
     # Return all properties as absent.
@@ -372,4 +215,25 @@
     end
     prophash
   end
+
+  # Private Properties
+  # The following properties are used in conjunction with the "puppet resource zone"
+  # output. They are valid properties for configuring a zone.
+
+  newproperty(:id) do
+    desc "The numerical ID of the zone.  This number is autogenerated
+    and cannot be changed."
+  end
+
+  newproperty(:zonepath) do
+    desc "The path to zone's file system."
+  end
+
+  newproperty(:iptype) do
+    desc "Displays exclusive or shared instance of IP."
+  end
+
+  newproperty(:brand) do
+    desc "The zone's brand type"
+  end
 end