swi-prolog: update to 9.2.9
[oi-userland.git] / components / ruby / puppet / patches / puppet-02-zone-type.patch
blob1afa424ff25f3bf37a526b535a0f29bcf0188c4c
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
6 @@ -1,10 +1,9 @@
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."
20 module Puppet::Zone
21 class StateMachine
22 @@ -59,7 +58,7 @@
24 def self.fsm
25 return @fsm if @fsm
26 - @fsm = Puppet::Zone::StateMachine.new
27 + @fsm = Puppet::Zone::StateMachine.new
28 end
30 def self.alias_state(values)
31 @@ -75,7 +74,7 @@
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
40 @@ -104,10 +103,10 @@
41 sleep 1
42 end
43 provider.send(method)
44 - provider.flush()
45 end
47 def sync
49 method = nil
50 direction = up? ? :up : :down
52 @@ -131,132 +130,34 @@
54 newparam(:name) do
55 desc "The name of the zone."
57 isnamevar
58 end
60 - newparam(:id) do
61 - desc "The numerical ID of the zone. This number is autogenerated
62 - and cannot be changed."
63 - end
65 - newparam(:clone) do
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."
70 - end
72 - newproperty(:ip, :parent => Puppet::Property::List) do
73 - require 'ipaddr'
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
90 - def should
91 - @should
92 - end
94 - # overridden so that we match with self.should
95 - def insync?(is)
96 - is = [] if !is || is == :absent
97 - is.sort == self.should.sort
98 - end
99 - end
101 - newproperty(:iptype) do
102 - desc "The IP stack type of the zone."
103 - defaultto :shared
104 - newvalue :shared
105 - newvalue :exclusive
106 - end
108 - newproperty(:autoboot, :boolean => true) do
109 - desc "Whether the zone should automatically boot."
110 - defaultto true
111 - newvalues(:true, :false)
112 - end
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 =~ /^\//
122 - end
124 - munge do |value|
125 - if value =~ /%s/
126 - value % @resource[:name]
127 - else
128 - value
129 - end
130 - end
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."
156 - def should
157 - @should
158 - end
160 - # overridden so that we match with self.should
161 - def insync?(is)
162 - is = [] if !is || is == :absent
163 - is.sort == self.should.sort
164 - end
166 - validate do |value|
167 - unless value !~ /^\//
168 - raise ArgumentError, "Datasets must be the name of a zfs filesystem"
169 - end
170 - end
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."
179 - def should
180 - @should
181 - end
183 - # overridden so that we match with self.should
184 - def insync?(is)
185 - is = [] if !is || is == :absent
186 - is.sort == self.should.sort
187 - end
189 - validate do |value|
190 - unless value =~ /^\//
191 - raise ArgumentError, "Inherited filesystems must be fully qualified"
192 - end
193 - end
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."
209 - end
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."
217 - end
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)]
224 - else
225 - nil
226 - end
227 - end
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
236 - end
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}", $!
242 - end
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}"
247 - end
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?
252 - end
253 - end
255 - validate do
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)
263 - else
264 - validate_exclusive(interface, address, router)
265 - end
266 - end
267 - end
269 def retrieve
270 - provider.flush
271 hash = provider.properties
272 return setstatus(hash) unless hash.nil? or hash[:ensure] == :absent
273 # Return all properties as absent.
274 @@ -379,4 +221,25 @@
276 prophash
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."
286 + end
288 + newproperty(:zonepath) do
289 + desc "The path to zone's file system."
290 + end
292 + newproperty(:iptype) do
293 + desc "Displays exclusive or shared instance of IP."
294 + end
296 + newproperty(:brand) do
297 + desc "The zone's brand type"
298 + end