1 Enhance the zone type to configure zones using a zonecfg export file format.
2 Enhance the output of the puppet resource zone.
4 --- puppet-3.8.6/lib/puppet/type/zone.rb.orig 2016-04-19 14:14:44.165798357 -0700
5 +++ puppet-3.8.6/lib/puppet/type/zone.rb 2016-04-19 14:15:24.531067353 -0700
7 -require 'puppet/property/list'
8 -Puppet::Type.newtype(:zone) do
9 - @doc = "Manages Solaris zones.
10 +#######################################################################
11 +# Oracle has modified the originally distributed contents of this file.
12 +#######################################################################
14 -**Autorequires:** If Puppet is managing the directory specified as the root of
15 -the zone's filesystem (with the `path` attribute), the zone resource will
16 -autorequire that directory."
17 +Puppet::Type.newtype(:zone) do
18 + @doc = "Manages Solaris zones."
26 - @fsm = Puppet::Zone::StateMachine.new
27 + @fsm = Puppet::Zone::StateMachine.new
30 def self.alias_state(values)
33 # This is seq value because the order of declaration is important.
34 # i.e we go linearly from :absent -> :configured -> :installed -> :running
35 - seqvalue :absent, :down => :destroy
36 + seqvalue :absent, :down => :unconfigure
37 seqvalue :configured, :up => :configure, :down => :uninstall
38 seqvalue :installed, :up => :install, :down => :stop
39 seqvalue :running, :up => :start
50 direction = up? ? :up : :down
52 @@ -131,132 +130,34 @@
55 desc "The name of the zone."
61 - desc "The numerical ID of the zone. This number is autogenerated
62 - and cannot be changed."
66 - desc "Instead of installing the zone, clone it from another zone.
67 - If the zone root resides on a zfs file system, a snapshot will be
68 - used to create the clone; if it resides on a ufs filesystem, a copy of the
69 - zone will be used. The zone from which you clone must not be running."
72 - newproperty(:ip, :parent => Puppet::Property::List) do
75 - desc "The IP address of the zone. IP addresses **must** be specified
76 - with an interface, and may optionally be specified with a default router
77 - (sometimes called a defrouter). The interface, IP address, and default
78 - router should be separated by colons to form a complete IP address string.
79 - For example: `bge0:192.168.178.200` would be a valid IP address string
80 - without a default router, and `bge0:192.168.178.200:192.168.178.1` adds a
81 - default router to it.
83 - For zones with multiple interfaces, the value of this attribute should be
84 - an array of IP address strings (each of which must include an interface
85 - and may include a default router)."
87 - # The default action of list should is to lst.join(' '). By specifying
88 - # @should, we ensure the should remains an array. If we override should, we
89 - # should also override insync?() -- property/list.rb
94 - # overridden so that we match with self.should
96 - is = [] if !is || is == :absent
97 - is.sort == self.should.sort
101 - newproperty(:iptype) do
102 - desc "The IP stack type of the zone."
105 - newvalue :exclusive
108 - newproperty(:autoboot, :boolean => true) do
109 - desc "Whether the zone should automatically boot."
111 - newvalues(:true, :false)
114 - newproperty(:path) do
115 - desc "The root of the zone's filesystem. Must be a fully qualified
116 - file name. If you include `%s` in the path, then it will be
117 - replaced with the zone's name. Currently, you cannot use
118 - Puppet to move a zone. Consequently this is a readonly property."
120 - validate do |value|
121 - raise ArgumentError, "The zone base must be fully qualified" unless value =~ /^\//
126 - value % @resource[:name]
131 + newparam(:config_profile) do
132 + desc "Path to the config_profile to use to configure a solaris zone.
133 + This is set when providing a sysconfig profile instead of running the
134 + sysconfig SCI tool on first boot of the zone."
137 - newproperty(:pool) do
138 - desc "The resource pool for this zone."
139 + newparam(:zonecfg_export) do
140 + desc "Contains the zone configuration information. This can be passed in
141 + in the form of a file generated by the zonecfg command, in the form
142 + of a template, or a string."
145 - newproperty(:shares) do
146 - desc "Number of FSS CPU shares allocated to the zone."
147 + newparam(:archive) do
148 + desc "The archive file containing an archived zone."
151 - newproperty(:dataset, :parent => Puppet::Property::List ) do
152 - desc "The list of datasets delegated to the non-global zone from the
153 - global zone. All datasets must be zfs filesystem names which are
154 - different from the mountpoint."
160 - # overridden so that we match with self.should
162 - is = [] if !is || is == :absent
163 - is.sort == self.should.sort
166 - validate do |value|
167 - unless value !~ /^\//
168 - raise ArgumentError, "Datasets must be the name of a zfs filesystem"
171 + newparam(:archived_zonename) do
172 + desc "The archived zone to configure and install"
175 - newproperty(:inherit, :parent => Puppet::Property::List) do
176 - desc "The list of directories that the zone inherits from the global
177 - zone. All directories must be fully qualified."
183 - # overridden so that we match with self.should
185 - is = [] if !is || is == :absent
186 - is.sort == self.should.sort
189 - validate do |value|
190 - unless value =~ /^\//
191 - raise ArgumentError, "Inherited filesystems must be fully qualified"
195 + newparam(:clone) do
196 + desc "Instead of installing the zone, clone it from another zone.
197 + If the zone root resides on a zfs file system, a snapshot will be
198 + used to create the clone; if it resides on a ufs filesystem, a copy of the
199 + zone will be used. The zone from which you clone must not be running."
202 # Specify the sysidcfg file. This is pretty hackish, because it's
203 @@ -293,70 +194,11 @@
204 so Puppet only checks for it at that time.}
207 - newparam(:create_args) do
208 - desc "Arguments to the `zonecfg` create command. This can be used to create branded zones."
211 newparam(:install_args) do
212 desc "Arguments to the `zoneadm` install command. This can be used to create branded zones."
215 - newparam(:realhostname) do
216 - desc "The actual hostname of the zone."
219 - # If Puppet is also managing the base dir or its parent dir, list them
220 - # both as prerequisites.
221 - autorequire(:file) do
222 - if @parameters.include? :path
223 - [@parameters[:path].value, ::File.dirname(@parameters[:path].value)]
229 - # If Puppet is also managing the zfs filesystem which is the zone dataset
230 - # then list it as a prerequisite. Zpool's get autorequired by the zfs
231 - # type. We just need to autorequire the dataset zfs itself as the zfs type
232 - # will autorequire all of the zfs parents and zpool.
233 - autorequire(:zfs) do
234 - # Check if we have datasets in our zone configuration and autorequire each dataset
235 - self[:dataset] if @parameters.include? :dataset
238 - def validate_ip(ip, name)
239 - IPAddr.new(ip) if ip
240 - rescue ArgumentError
241 - self.fail Puppet::Error, "'#{ip}' is an invalid #{name}", $!
244 - def validate_exclusive(interface, address, router)
245 - return if !interface.nil? and address.nil?
246 - self.fail "only interface may be specified when using exclusive IP stack: #{interface}:#{address}"
248 - def validate_shared(interface, address, router)
249 - self.fail "ip must contain interface name and ip address separated by a \":\"" if interface.nil? or address.nil?
250 - [address, router].each do |ip|
251 - validate_ip(address, "IP address") unless ip.nil?
256 - return unless self[:ip]
257 - # self[:ip] reflects the type passed from proeprty:ip.should. If we
258 - # override it and pass @should, then we get an array here back.
259 - self[:ip].each do |ip|
260 - interface, address, router = ip.split(':')
261 - if self[:iptype] == :shared
262 - validate_shared(interface, address, router)
264 - validate_exclusive(interface, address, router)
271 hash = provider.properties
272 return setstatus(hash) unless hash.nil? or hash[:ensure] == :absent
273 # Return all properties as absent.
279 + # Private Properties
280 + # The following properties are used in conjunction with the "puppet resource zone"
281 + # output. They are valid properties for configuring a zone.
283 + newproperty(:id) do
284 + desc "The numerical ID of the zone. This number is autogenerated
285 + and cannot be changed."
288 + newproperty(:zonepath) do
289 + desc "The path to zone's file system."
292 + newproperty(:iptype) do
293 + desc "Displays exclusive or shared instance of IP."
296 + newproperty(:brand) do
297 + desc "The zone's brand type"