summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/__init__.py0
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/base.py466
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/__init__.py26
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/authconfig.py40
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/autopart.py119
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/autostep.py55
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py265
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py86
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/device.py125
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/deviceprobe.py40
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/displaymode.py68
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/dmraid.py91
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py184
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py114
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/firewall.py193
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/firstboot.py62
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/group.py88
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py139
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/interactive.py58
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/iscsi.py133
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/iscsiname.py54
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/key.py64
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/keyboard.py55
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/lang.py60
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/langsupport.py58
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/lilocheck.py54
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/logging.py66
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py304
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/mediacheck.py53
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/method.py186
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/monitor.py106
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/mouse.py70
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/multipath.py111
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/network.py363
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/partition.py353
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/raid.py365
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/reboot.py79
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/repo.py249
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/rescue.py68
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/rootpw.py93
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/selinux.py64
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/services.py71
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/skipx.py54
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/sshpw.py105
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/timezone.py86
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/updates.py60
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py106
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/user.py173
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py114
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/volgroup.py102
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/xconfig.py184
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/zerombr.py69
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py134
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/constants.py57
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/errors.py103
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/__init__.py0
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/control.py1307
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f10.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f11.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f12.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f13.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f14.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f15.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f16.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f7.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f8.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/f9.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/fc3.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/fc4.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/fc5.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/fc6.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/rhel3.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/rhel4.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/rhel5.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/handlers/rhel6.py24
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/ko.py37
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/options.py204
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/parser.py702
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/sections.py244
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/urlgrabber/__init__.py53
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/urlgrabber/byterange.py463
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/urlgrabber/grabber.py1477
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/urlgrabber/keepalive.py617
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/urlgrabber/mirror.py458
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/urlgrabber/progress.py530
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/urlgrabber/sslfactory.py90
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/version.py197
87 files changed, 13456 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/__init__.py b/scripts/lib/mic/3rdparty/pykickstart/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/__init__.py
diff --git a/scripts/lib/mic/3rdparty/pykickstart/base.py b/scripts/lib/mic/3rdparty/pykickstart/base.py
new file mode 100644
index 0000000000..e6c8f56f9d
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/base.py
@@ -0,0 +1,466 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20"""
21Base classes for creating commands and syntax version object.
22
23This module exports several important base classes:
24
25 BaseData - The base abstract class for all data objects. Data objects
26 are contained within a BaseHandler object.
27
28 BaseHandler - The base abstract class from which versioned kickstart
29 handler are derived. Subclasses of BaseHandler hold
30 BaseData and KickstartCommand objects.
31
32 DeprecatedCommand - An abstract subclass of KickstartCommand that should
33 be further subclassed by users of this module. When
34 a subclass is used, a warning message will be
35 printed.
36
37 KickstartCommand - The base abstract class for all kickstart commands.
38 Command objects are contained within a BaseHandler
39 object.
40"""
41import gettext
42gettext.textdomain("pykickstart")
43_ = lambda x: gettext.ldgettext("pykickstart", x)
44
45import types
46import warnings
47from pykickstart.errors import *
48from pykickstart.ko import *
49from pykickstart.parser import Packages
50from pykickstart.version import versionToString
51
52###
53### COMMANDS
54###
55class KickstartCommand(KickstartObject):
56 """The base class for all kickstart commands. This is an abstract class."""
57 removedKeywords = []
58 removedAttrs = []
59
60 def __init__(self, writePriority=0, *args, **kwargs):
61 """Create a new KickstartCommand instance. This method must be
62 provided by all subclasses, but subclasses must call
63 KickstartCommand.__init__ first. Instance attributes:
64
65 currentCmd -- The name of the command in the input file that
66 caused this handler to be run.
67 currentLine -- The current unprocessed line from the input file
68 that caused this handler to be run.
69 handler -- A reference to the BaseHandler subclass this
70 command is contained withing. This is needed to
71 allow referencing of Data objects.
72 lineno -- The current line number in the input file.
73 writePriority -- An integer specifying when this command should be
74 printed when iterating over all commands' __str__
75 methods. The higher the number, the later this
76 command will be written. All commands with the
77 same priority will be written alphabetically.
78 """
79
80 # We don't want people using this class by itself.
81 if self.__class__ is KickstartCommand:
82 raise TypeError, "KickstartCommand is an abstract class."
83
84 KickstartObject.__init__(self, *args, **kwargs)
85
86 self.writePriority = writePriority
87
88 # These will be set by the dispatcher.
89 self.currentCmd = ""
90 self.currentLine = ""
91 self.handler = None
92 self.lineno = 0
93
94 # If a subclass provides a removedKeywords list, remove all the
95 # members from the kwargs list before we start processing it. This
96 # ensures that subclasses don't continue to recognize arguments that
97 # were removed.
98 for arg in filter(kwargs.has_key, self.removedKeywords):
99 kwargs.pop(arg)
100
101 def __call__(self, *args, **kwargs):
102 """Set multiple attributes on a subclass of KickstartCommand at once
103 via keyword arguments. Valid attributes are anything specified in
104 a subclass, but unknown attributes will be ignored.
105 """
106 for (key, val) in kwargs.items():
107 # Ignore setting attributes that were removed in a subclass, as
108 # if they were unknown attributes.
109 if key in self.removedAttrs:
110 continue
111
112 if hasattr(self, key):
113 setattr(self, key, val)
114
115 def __str__(self):
116 """Return a string formatted for output to a kickstart file. This
117 method must be provided by all subclasses.
118 """
119 return KickstartObject.__str__(self)
120
121 def parse(self, args):
122 """Parse the list of args and set data on the KickstartCommand object.
123 This method must be provided by all subclasses.
124 """
125 raise TypeError, "parse() not implemented for KickstartCommand"
126
127 def apply(self, instroot="/"):
128 """Write out the configuration related to the KickstartCommand object.
129 Subclasses which do not provide this method will not have their
130 configuration written out.
131 """
132 return
133
134 def dataList(self):
135 """For commands that can occur multiple times in a single kickstart
136 file (like network, part, etc.), return the list that we should
137 append more data objects to.
138 """
139 return None
140
141 def deleteRemovedAttrs(self):
142 """Remove all attributes from self that are given in the removedAttrs
143 list. This method should be called from __init__ in a subclass,
144 but only after the superclass's __init__ method has been called.
145 """
146 for attr in filter(lambda k: hasattr(self, k), self.removedAttrs):
147 delattr(self, attr)
148
149 # Set the contents of the opts object (an instance of optparse.Values
150 # returned by parse_args) as attributes on the KickstartCommand object.
151 # It's useful to call this from KickstartCommand subclasses after parsing
152 # the arguments.
153 def _setToSelf(self, optParser, opts):
154 self._setToObj(optParser, opts, self)
155
156 # Sets the contents of the opts object (an instance of optparse.Values
157 # returned by parse_args) as attributes on the provided object obj. It's
158 # useful to call this from KickstartCommand subclasses that handle lists
159 # of objects (like partitions, network devices, etc.) and need to populate
160 # a Data object.
161 def _setToObj(self, optParser, opts, obj):
162 for key in filter (lambda k: getattr(opts, k) != None, optParser.keys()):
163 setattr(obj, key, getattr(opts, key))
164
165class DeprecatedCommand(KickstartCommand):
166 """Specify that a command is deprecated and no longer has any function.
167 Any command that is deprecated should be subclassed from this class,
168 only specifying an __init__ method that calls the superclass's __init__.
169 This is an abstract class.
170 """
171 def __init__(self, writePriority=None, *args, **kwargs):
172 # We don't want people using this class by itself.
173 if self.__class__ is KickstartCommand:
174 raise TypeError, "DeprecatedCommand is an abstract class."
175
176 # Create a new DeprecatedCommand instance.
177 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
178
179 def __str__(self):
180 """Placeholder since DeprecatedCommands don't work anymore."""
181 return ""
182
183 def parse(self, args):
184 """Print a warning message if the command is seen in the input file."""
185 mapping = {"lineno": self.lineno, "cmd": self.currentCmd}
186 warnings.warn(_("Ignoring deprecated command on line %(lineno)s: The %(cmd)s command has been deprecated and no longer has any effect. It may be removed from future releases, which will result in a fatal error from kickstart. Please modify your kickstart file to remove this command.") % mapping, DeprecationWarning)
187
188
189###
190### HANDLERS
191###
192class BaseHandler(KickstartObject):
193 """Each version of kickstart syntax is provided by a subclass of this
194 class. These subclasses are what users will interact with for parsing,
195 extracting data, and writing out kickstart files. This is an abstract
196 class.
197
198 version -- The version this syntax handler supports. This is set by
199 a class attribute of a BaseHandler subclass and is used to
200 set up the command dict. It is for read-only use.
201 """
202 version = None
203
204 def __init__(self, mapping=None, dataMapping=None, commandUpdates=None,
205 dataUpdates=None, *args, **kwargs):
206 """Create a new BaseHandler instance. This method must be provided by
207 all subclasses, but subclasses must call BaseHandler.__init__ first.
208
209 mapping -- A custom map from command strings to classes,
210 useful when creating your own handler with
211 special command objects. It is otherwise unused
212 and rarely needed. If you give this argument,
213 the mapping takes the place of the default one
214 and so must include all commands you want
215 recognized.
216 dataMapping -- This is the same as mapping, but for data
217 objects. All the same comments apply.
218 commandUpdates -- This is similar to mapping, but does not take
219 the place of the defaults entirely. Instead,
220 this mapping is applied after the defaults and
221 updates it with just the commands you want to
222 modify.
223 dataUpdates -- This is the same as commandUpdates, but for
224 data objects.
225
226
227 Instance attributes:
228
229 commands -- A mapping from a string command to a KickstartCommand
230 subclass object that handles it. Multiple strings can
231 map to the same object, but only one instance of the
232 command object should ever exist. Most users should
233 never have to deal with this directly, as it is
234 manipulated internally and called through dispatcher.
235 currentLine -- The current unprocessed line from the input file
236 that caused this handler to be run.
237 packages -- An instance of pykickstart.parser.Packages which
238 describes the packages section of the input file.
239 platform -- A string describing the hardware platform, which is
240 needed only by system-config-kickstart.
241 scripts -- A list of pykickstart.parser.Script instances, which is
242 populated by KickstartParser.addScript and describes the
243 %pre/%post/%traceback script section of the input file.
244 """
245
246 # We don't want people using this class by itself.
247 if self.__class__ is BaseHandler:
248 raise TypeError, "BaseHandler is an abstract class."
249
250 KickstartObject.__init__(self, *args, **kwargs)
251
252 # This isn't really a good place for these, but it's better than
253 # everything else I can think of.
254 self.scripts = []
255 self.packages = Packages()
256 self.platform = ""
257
258 # These will be set by the dispatcher.
259 self.commands = {}
260 self.currentLine = 0
261
262 # A dict keyed by an integer priority number, with each value being a
263 # list of KickstartCommand subclasses. This dict is maintained by
264 # registerCommand and used in __str__. No one else should be touching
265 # it.
266 self._writeOrder = {}
267
268 self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates)
269
270 def __str__(self):
271 """Return a string formatted for output to a kickstart file."""
272 retval = ""
273
274 if self.platform != "":
275 retval += "#platform=%s\n" % self.platform
276
277 retval += "#version=%s\n" % versionToString(self.version)
278
279 lst = self._writeOrder.keys()
280 lst.sort()
281
282 for prio in lst:
283 for obj in self._writeOrder[prio]:
284 retval += obj.__str__()
285
286 for script in self.scripts:
287 retval += script.__str__()
288
289 retval += self.packages.__str__()
290
291 return retval
292
293 def _insertSorted(self, lst, obj):
294 length = len(lst)
295 i = 0
296
297 while i < length:
298 # If the two classes have the same name, it's because we are
299 # overriding an existing class with one from a later kickstart
300 # version, so remove the old one in favor of the new one.
301 if obj.__class__.__name__ > lst[i].__class__.__name__:
302 i += 1
303 elif obj.__class__.__name__ == lst[i].__class__.__name__:
304 lst[i] = obj
305 return
306 elif obj.__class__.__name__ < lst[i].__class__.__name__:
307 break
308
309 if i >= length:
310 lst.append(obj)
311 else:
312 lst.insert(i, obj)
313
314 def _setCommand(self, cmdObj):
315 # Add an attribute on this version object. We need this to provide a
316 # way for clients to access the command objects. We also need to strip
317 # off the version part from the front of the name.
318 if cmdObj.__class__.__name__.find("_") != -1:
319 name = unicode(cmdObj.__class__.__name__.split("_", 1)[1])
320 else:
321 name = unicode(cmdObj.__class__.__name__).lower()
322
323 setattr(self, name.lower(), cmdObj)
324
325 # Also, add the object into the _writeOrder dict in the right place.
326 if cmdObj.writePriority is not None:
327 if self._writeOrder.has_key(cmdObj.writePriority):
328 self._insertSorted(self._writeOrder[cmdObj.writePriority], cmdObj)
329 else:
330 self._writeOrder[cmdObj.writePriority] = [cmdObj]
331
332 def _registerCommands(self, mapping=None, dataMapping=None, commandUpdates=None,
333 dataUpdates=None):
334 if mapping == {} or mapping == None:
335 from pykickstart.handlers.control import commandMap
336 cMap = commandMap[self.version]
337 else:
338 cMap = mapping
339
340 if dataMapping == {} or dataMapping == None:
341 from pykickstart.handlers.control import dataMap
342 dMap = dataMap[self.version]
343 else:
344 dMap = dataMapping
345
346 if type(commandUpdates) == types.DictType:
347 cMap.update(commandUpdates)
348
349 if type(dataUpdates) == types.DictType:
350 dMap.update(dataUpdates)
351
352 for (cmdName, cmdClass) in cMap.iteritems():
353 # First make sure we haven't instantiated this command handler
354 # already. If we have, we just need to make another mapping to
355 # it in self.commands.
356 cmdObj = None
357
358 for (key, val) in self.commands.iteritems():
359 if val.__class__.__name__ == cmdClass.__name__:
360 cmdObj = val
361 break
362
363 # If we didn't find an instance in self.commands, create one now.
364 if cmdObj == None:
365 cmdObj = cmdClass()
366 self._setCommand(cmdObj)
367
368 # Finally, add the mapping to the commands dict.
369 self.commands[cmdName] = cmdObj
370 self.commands[cmdName].handler = self
371
372 # We also need to create attributes for the various data objects.
373 # No checks here because dMap is a bijection. At least, that's what
374 # the comment says. Hope no one screws that up.
375 for (dataName, dataClass) in dMap.iteritems():
376 setattr(self, dataName, dataClass)
377
378 def dispatcher(self, args, lineno):
379 """Call the appropriate KickstartCommand handler for the current line
380 in the kickstart file. A handler for the current command should
381 be registered, though a handler of None is not an error. Returns
382 the data object returned by KickstartCommand.parse.
383
384 args -- A list of arguments to the current command
385 lineno -- The line number in the file, for error reporting
386 """
387 cmd = args[0]
388
389 if not self.commands.has_key(cmd):
390 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown command: %s" % cmd))
391 elif self.commands[cmd] != None:
392 self.commands[cmd].currentCmd = cmd
393 self.commands[cmd].currentLine = self.currentLine
394 self.commands[cmd].lineno = lineno
395
396 # The parser returns the data object that was modified. This could
397 # be a BaseData subclass that should be put into a list, or it
398 # could be the command handler object itself.
399 obj = self.commands[cmd].parse(args[1:])
400 lst = self.commands[cmd].dataList()
401 if lst is not None:
402 lst.append(obj)
403
404 return obj
405
406 def maskAllExcept(self, lst):
407 """Set all entries in the commands dict to None, except the ones in
408 the lst. All other commands will not be processed.
409 """
410 self._writeOrder = {}
411
412 for (key, val) in self.commands.iteritems():
413 if not key in lst:
414 self.commands[key] = None
415
416 def hasCommand(self, cmd):
417 """Return true if there is a handler for the string cmd."""
418 return hasattr(self, cmd)
419
420
421###
422### DATA
423###
424class BaseData(KickstartObject):
425 """The base class for all data objects. This is an abstract class."""
426 removedKeywords = []
427 removedAttrs = []
428
429 def __init__(self, *args, **kwargs):
430 """Create a new BaseData instance.
431
432 lineno -- Line number in the ks-file where this object was defined
433 """
434
435 # We don't want people using this class by itself.
436 if self.__class__ is BaseData:
437 raise TypeError, "BaseData is an abstract class."
438
439 KickstartObject.__init__(self, *args, **kwargs)
440 self.lineno = 0
441
442 def __str__(self):
443 """Return a string formatted for output to a kickstart file."""
444 return ""
445
446 def __call__(self, *args, **kwargs):
447 """Set multiple attributes on a subclass of BaseData at once via
448 keyword arguments. Valid attributes are anything specified in a
449 subclass, but unknown attributes will be ignored.
450 """
451 for (key, val) in kwargs.items():
452 # Ignore setting attributes that were removed in a subclass, as
453 # if they were unknown attributes.
454 if key in self.removedAttrs:
455 continue
456
457 if hasattr(self, key):
458 setattr(self, key, val)
459
460 def deleteRemovedAttrs(self):
461 """Remove all attributes from self that are given in the removedAttrs
462 list. This method should be called from __init__ in a subclass,
463 but only after the superclass's __init__ method has been called.
464 """
465 for attr in filter(lambda k: hasattr(self, k), self.removedAttrs):
466 delattr(self, attr)
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/__init__.py b/scripts/lib/mic/3rdparty/pykickstart/commands/__init__.py
new file mode 100644
index 0000000000..da48ff50d5
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/__init__.py
@@ -0,0 +1,26 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20import authconfig, autopart, autostep, bootloader, clearpart, device
21import deviceprobe, displaymode, dmraid, driverdisk, fcoe, firewall, firstboot
22import group, ignoredisk, interactive, iscsi, iscsiname, key, keyboard, lang
23import langsupport, lilocheck, logging, logvol, mediacheck, method, monitor
24import mouse, multipath, network, partition, raid, reboot, repo, rescue, rootpw
25import selinux, services, skipx, sshpw, timezone, updates, upgrade, user, vnc
26import volgroup, xconfig, zerombr, zfcp
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/authconfig.py b/scripts/lib/mic/3rdparty/pykickstart/commands/authconfig.py
new file mode 100644
index 0000000000..9af9c0ff14
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/authconfig.py
@@ -0,0 +1,40 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21
22class FC3_Authconfig(KickstartCommand):
23 removedKeywords = KickstartCommand.removedKeywords
24 removedAttrs = KickstartCommand.removedAttrs
25
26 def __init__(self, writePriority=0, *args, **kwargs):
27 KickstartCommand.__init__(self, *args, **kwargs)
28 self.authconfig = kwargs.get("authconfig", "")
29
30 def __str__(self):
31 retval = KickstartCommand.__str__(self)
32
33 if self.authconfig:
34 retval += "# System authorization information\nauth %s\n" % self.authconfig
35
36 return retval
37
38 def parse(self, args):
39 self.authconfig = self.currentLine[len(self.currentCmd):].strip()
40 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/autopart.py b/scripts/lib/mic/3rdparty/pykickstart/commands/autopart.py
new file mode 100644
index 0000000000..cf28b5c7f7
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/autopart.py
@@ -0,0 +1,119 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_AutoPart(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=100, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.autopart = kwargs.get("autopart", False)
34
35 def __str__(self):
36 retval = KickstartCommand.__str__(self)
37
38 if self.autopart:
39 retval += "autopart\n"
40
41 return retval
42
43 def parse(self, args):
44 if len(args) > 0:
45 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "autopart")
46
47 self.autopart = True
48 return self
49
50class F9_AutoPart(FC3_AutoPart):
51 removedKeywords = FC3_AutoPart.removedKeywords
52 removedAttrs = FC3_AutoPart.removedAttrs
53
54 def __init__(self, writePriority=100, *args, **kwargs):
55 FC3_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs)
56 self.encrypted = kwargs.get("encrypted", False)
57 self.passphrase = kwargs.get("passphrase", "")
58
59 self.op = self._getParser()
60
61 def __str__(self):
62 retval = KickstartCommand.__str__(self)
63
64 if self.autopart:
65 retval += "autopart"
66
67 if self.encrypted:
68 retval += " --encrypted"
69
70 if self.passphrase != "":
71 retval += " --passphrase=\"%s\""% self.passphrase
72
73 if retval != "":
74 retval += "\n"
75
76 return retval
77
78 def _getParser(self):
79 op = KSOptionParser()
80 op.add_option("--encrypted", action="store_true", default=False)
81 op.add_option("--passphrase")
82 return op
83
84 def parse(self, args):
85 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
86 self._setToSelf(self.op, opts)
87 self.autopart = True
88 return self
89
90class F12_AutoPart(F9_AutoPart):
91 removedKeywords = F9_AutoPart.removedKeywords
92 removedAttrs = F9_AutoPart.removedAttrs
93
94 def __init__(self, writePriority=100, *args, **kwargs):
95 F9_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs)
96
97 self.escrowcert = kwargs.get("escrowcert", "")
98 self.backuppassphrase = kwargs.get("backuppassphrase", False)
99
100 def __str__(self):
101 retval = F9_AutoPart.__str__(self)
102
103 if self.encrypted and self.escrowcert != "":
104 retval = retval.strip()
105
106 retval += " --escrowcert=\"%s\"" % self.escrowcert
107
108 if self.backuppassphrase:
109 retval += " --backuppassphrase"
110
111 retval += "\n"
112
113 return retval
114
115 def _getParser(self):
116 op = F9_AutoPart._getParser(self)
117 op.add_option("--escrowcert")
118 op.add_option("--backuppassphrase", action="store_true", default=False)
119 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/autostep.py b/scripts/lib/mic/3rdparty/pykickstart/commands/autostep.py
new file mode 100644
index 0000000000..e6ae71cefc
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/autostep.py
@@ -0,0 +1,55 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23class FC3_AutoStep(KickstartCommand):
24 removedKeywords = KickstartCommand.removedKeywords
25 removedAttrs = KickstartCommand.removedAttrs
26
27 def __init__(self, writePriority=0, *args, **kwargs):
28 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
29 self.op = self._getParser()
30
31 self.autostep = kwargs.get("autostep", False)
32 self.autoscreenshot = kwargs.get("autoscreenshot", False)
33
34 def __str__(self):
35 retval = KickstartCommand.__str__(self)
36
37 if self.autostep:
38 if self.autoscreenshot:
39 retval += "autostep --autoscreenshot\n"
40 else:
41 retval += "autostep\n"
42
43 return retval
44
45 def _getParser(self):
46 op = KSOptionParser()
47 op.add_option("--autoscreenshot", dest="autoscreenshot",
48 action="store_true", default=False)
49 return op
50
51 def parse(self, args):
52 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
53 self._setToSelf(self.op, opts)
54 self.autostep = True
55 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py b/scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py
new file mode 100644
index 0000000000..b227fac3be
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/bootloader.py
@@ -0,0 +1,265 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23class FC3_Bootloader(KickstartCommand):
24 removedKeywords = KickstartCommand.removedKeywords
25 removedAttrs = KickstartCommand.removedAttrs
26
27 def __init__(self, writePriority=10, *args, **kwargs):
28 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
29 self.op = self._getParser()
30
31 self.driveorder = kwargs.get("driveorder", [])
32 self.appendLine = kwargs.get("appendLine", "")
33 self.forceLBA = kwargs.get("forceLBA", False)
34 self.linear = kwargs.get("linear", True)
35 self.location = kwargs.get("location", "")
36 self.md5pass = kwargs.get("md5pass", "")
37 self.password = kwargs.get("password", "")
38 self.upgrade = kwargs.get("upgrade", False)
39 self.useLilo = kwargs.get("useLilo", False)
40
41 self.deleteRemovedAttrs()
42
43 def _getArgsAsStr(self):
44 retval = ""
45
46 if self.appendLine != "":
47 retval += " --append=\"%s\"" % self.appendLine
48 if self.linear:
49 retval += " --linear"
50 if self.location:
51 retval += " --location=%s" % self.location
52 if hasattr(self, "forceLBA") and self.forceLBA:
53 retval += " --lba32"
54 if self.password != "":
55 retval += " --password=\"%s\"" % self.password
56 if self.md5pass != "":
57 retval += " --md5pass=\"%s\"" % self.md5pass
58 if self.upgrade:
59 retval += " --upgrade"
60 if self.useLilo:
61 retval += " --useLilo"
62 if len(self.driveorder) > 0:
63 retval += " --driveorder=\"%s\"" % ",".join(self.driveorder)
64
65 return retval
66
67 def __str__(self):
68 retval = KickstartCommand.__str__(self)
69
70 if self.location != "":
71 retval += "# System bootloader configuration\nbootloader"
72 retval += self._getArgsAsStr() + "\n"
73
74 return retval
75
76 def _getParser(self):
77 def driveorder_cb (option, opt_str, value, parser):
78 for d in value.split(','):
79 parser.values.ensure_value(option.dest, []).append(d)
80
81 op = KSOptionParser()
82 op.add_option("--append", dest="appendLine")
83 op.add_option("--linear", dest="linear", action="store_true",
84 default=True)
85 op.add_option("--nolinear", dest="linear", action="store_false")
86 op.add_option("--location", dest="location", type="choice",
87 default="mbr",
88 choices=["mbr", "partition", "none", "boot"])
89 op.add_option("--lba32", dest="forceLBA", action="store_true",
90 default=False)
91 op.add_option("--password", dest="password", default="")
92 op.add_option("--md5pass", dest="md5pass", default="")
93 op.add_option("--upgrade", dest="upgrade", action="store_true",
94 default=False)
95 op.add_option("--useLilo", dest="useLilo", action="store_true",
96 default=False)
97 op.add_option("--driveorder", dest="driveorder", action="callback",
98 callback=driveorder_cb, nargs=1, type="string")
99 return op
100
101 def parse(self, args):
102 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
103 self._setToSelf(self.op, opts)
104
105 if self.currentCmd == "lilo":
106 self.useLilo = True
107
108 return self
109
110class FC4_Bootloader(FC3_Bootloader):
111 removedKeywords = FC3_Bootloader.removedKeywords + ["linear", "useLilo"]
112 removedAttrs = FC3_Bootloader.removedAttrs + ["linear", "useLilo"]
113
114 def __init__(self, writePriority=10, *args, **kwargs):
115 FC3_Bootloader.__init__(self, writePriority, *args, **kwargs)
116
117 def _getArgsAsStr(self):
118 retval = ""
119 if self.appendLine != "":
120 retval += " --append=\"%s\"" % self.appendLine
121 if self.location:
122 retval += " --location=%s" % self.location
123 if hasattr(self, "forceLBA") and self.forceLBA:
124 retval += " --lba32"
125 if self.password != "":
126 retval += " --password=\"%s\"" % self.password
127 if self.md5pass != "":
128 retval += " --md5pass=\"%s\"" % self.md5pass
129 if self.upgrade:
130 retval += " --upgrade"
131 if len(self.driveorder) > 0:
132 retval += " --driveorder=\"%s\"" % ",".join(self.driveorder)
133 return retval
134
135 def _getParser(self):
136 op = FC3_Bootloader._getParser(self)
137 op.remove_option("--linear")
138 op.remove_option("--nolinear")
139 op.remove_option("--useLilo")
140 return op
141
142 def parse(self, args):
143 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
144 self._setToSelf(self.op, opts)
145 return self
146
147class F8_Bootloader(FC4_Bootloader):
148 removedKeywords = FC4_Bootloader.removedKeywords
149 removedAttrs = FC4_Bootloader.removedAttrs
150
151 def __init__(self, writePriority=10, *args, **kwargs):
152 FC4_Bootloader.__init__(self, writePriority, *args, **kwargs)
153
154 self.timeout = kwargs.get("timeout", None)
155 self.default = kwargs.get("default", "")
156
157 def _getArgsAsStr(self):
158 ret = FC4_Bootloader._getArgsAsStr(self)
159
160 if self.timeout is not None:
161 ret += " --timeout=%d" %(self.timeout,)
162 if self.default:
163 ret += " --default=%s" %(self.default,)
164
165 return ret
166
167 def _getParser(self):
168 op = FC4_Bootloader._getParser(self)
169 op.add_option("--timeout", dest="timeout", type="int")
170 op.add_option("--default", dest="default")
171 return op
172
173class F12_Bootloader(F8_Bootloader):
174 removedKeywords = F8_Bootloader.removedKeywords
175 removedAttrs = F8_Bootloader.removedAttrs
176
177 def _getParser(self):
178 op = F8_Bootloader._getParser(self)
179 op.add_option("--lba32", dest="forceLBA", deprecated=1, action="store_true")
180 return op
181
182class F14_Bootloader(F12_Bootloader):
183 removedKeywords = F12_Bootloader.removedKeywords + ["forceLBA"]
184 removedAttrs = F12_Bootloader.removedKeywords + ["forceLBA"]
185
186 def _getParser(self):
187 op = F12_Bootloader._getParser(self)
188 op.remove_option("--lba32")
189 return op
190
191class F15_Bootloader(F14_Bootloader):
192 removedKeywords = F14_Bootloader.removedKeywords
193 removedAttrs = F14_Bootloader.removedAttrs
194
195 def __init__(self, writePriority=10, *args, **kwargs):
196 F14_Bootloader.__init__(self, writePriority, *args, **kwargs)
197
198 self.isCrypted = kwargs.get("isCrypted", False)
199
200 def _getArgsAsStr(self):
201 ret = F14_Bootloader._getArgsAsStr(self)
202
203 if self.isCrypted:
204 ret += " --iscrypted"
205
206 return ret
207
208 def _getParser(self):
209 def password_cb(option, opt_str, value, parser):
210 parser.values.isCrypted = True
211 parser.values.password = value
212
213 op = F14_Bootloader._getParser(self)
214 op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False)
215 op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string")
216 return op
217
218class RHEL5_Bootloader(FC4_Bootloader):
219 removedKeywords = FC4_Bootloader.removedKeywords
220 removedAttrs = FC4_Bootloader.removedAttrs
221
222 def __init__(self, writePriority=10, *args, **kwargs):
223 FC4_Bootloader.__init__(self, writePriority, *args, **kwargs)
224
225 self.hvArgs = kwargs.get("hvArgs", "")
226
227 def _getArgsAsStr(self):
228 ret = FC4_Bootloader._getArgsAsStr(self)
229
230 if self.hvArgs:
231 ret += " --hvargs=\"%s\"" %(self.hvArgs,)
232
233 return ret
234
235 def _getParser(self):
236 op = FC4_Bootloader._getParser(self)
237 op.add_option("--hvargs", dest="hvArgs", type="string")
238 return op
239
240class RHEL6_Bootloader(F12_Bootloader):
241 removedKeywords = F12_Bootloader.removedKeywords
242 removedAttrs = F12_Bootloader.removedAttrs
243
244 def __init__(self, writePriority=10, *args, **kwargs):
245 F12_Bootloader.__init__(self, writePriority, *args, **kwargs)
246
247 self.isCrypted = kwargs.get("isCrypted", False)
248
249 def _getArgsAsStr(self):
250 ret = F12_Bootloader._getArgsAsStr(self)
251
252 if self.isCrypted:
253 ret += " --iscrypted"
254
255 return ret
256
257 def _getParser(self):
258 def password_cb(option, opt_str, value, parser):
259 parser.values.isCrypted = True
260 parser.values.password = value
261
262 op = F12_Bootloader._getParser(self)
263 op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False)
264 op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string")
265 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py b/scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py
new file mode 100644
index 0000000000..a8089fcb99
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py
@@ -0,0 +1,86 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25class FC3_ClearPart(KickstartCommand):
26 removedKeywords = KickstartCommand.removedKeywords
27 removedAttrs = KickstartCommand.removedAttrs
28
29 def __init__(self, writePriority=120, *args, **kwargs):
30 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
31 self.op = self._getParser()
32
33 self.drives = kwargs.get("drives", [])
34 self.initAll = kwargs.get("initAll", False)
35 self.type = kwargs.get("type", None)
36
37 def __str__(self):
38 retval = KickstartCommand.__str__(self)
39
40 if self.type is None:
41 return retval
42
43 if self.type == CLEARPART_TYPE_NONE:
44 clearstr = "--none"
45 elif self.type == CLEARPART_TYPE_LINUX:
46 clearstr = "--linux"
47 elif self.type == CLEARPART_TYPE_ALL:
48 clearstr = "--all"
49 else:
50 clearstr = ""
51
52 if self.initAll:
53 initstr = "--initlabel"
54 else:
55 initstr = ""
56
57 if len(self.drives) > 0:
58 drivestr = "--drives=" + ",".join(self.drives)
59 else:
60 drivestr = ""
61
62 retval += "# Partition clearing information\nclearpart %s %s %s\n" % (clearstr, initstr, drivestr)
63 return retval
64
65 def _getParser(self):
66 def drive_cb (option, opt_str, value, parser):
67 for d in value.split(','):
68 parser.values.ensure_value(option.dest, []).append(d)
69
70 op = KSOptionParser()
71 op.add_option("--all", dest="type", action="store_const",
72 const=CLEARPART_TYPE_ALL)
73 op.add_option("--drives", dest="drives", action="callback",
74 callback=drive_cb, nargs=1, type="string")
75 op.add_option("--initlabel", dest="initAll", action="store_true",
76 default=False)
77 op.add_option("--linux", dest="type", action="store_const",
78 const=CLEARPART_TYPE_LINUX)
79 op.add_option("--none", dest="type", action="store_const",
80 const=CLEARPART_TYPE_NONE)
81 return op
82
83 def parse(self, args):
84 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
85 self._setToSelf(self.op, opts)
86 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/device.py b/scripts/lib/mic/3rdparty/pykickstart/commands/device.py
new file mode 100644
index 0000000000..321410e2e2
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/device.py
@@ -0,0 +1,125 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23import gettext
24import warnings
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class F8_DeviceData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
30
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.moduleName = kwargs.get("moduleName", "")
34 self.moduleOpts = kwargs.get("moduleOpts", "")
35
36 def __eq__(self, y):
37 return self.moduleName == y.moduleName
38
39 def __str__(self):
40 retval = BaseData.__str__(self)
41
42 if self.moduleName != "":
43 retval += "device %s" % self.moduleName
44
45 if self.moduleOpts != "":
46 retval += " --opts=\"%s\"" % self.moduleOpts
47
48 return retval + "\n"
49
50class FC3_Device(KickstartCommand):
51 removedKeywords = KickstartCommand.removedKeywords
52 removedAttrs = KickstartCommand.removedAttrs
53
54 def __init__(self, writePriority=0, *args, **kwargs):
55 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
56 self.op = self._getParser()
57
58 self.type = kwargs.get("type", "")
59 self.moduleName = kwargs.get("moduleName", "")
60 self.moduleOpts = kwargs.get("moduleOpts", "")
61
62 def __eq__(self, y):
63 return self.moduleName == y.moduleName
64
65 def __str__(self):
66 retval = KickstartCommand.__str__(self)
67
68 if self.moduleName != "":
69 retval += "device %s %s" % (self.type, self.moduleName)
70
71 if self.moduleOpts != "":
72 retval += " --opts=\"%s\"" % self.moduleOpts
73
74 return retval + "\n"
75
76 def _getParser(self):
77 op = KSOptionParser()
78 op.add_option("--opts", dest="moduleOpts", default="")
79 return op
80
81 def parse(self, args):
82 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
83
84 if len(extra) != 2:
85 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name"))
86
87 self.moduleOpts = opts.moduleOpts
88 self.type = extra[0]
89 self.moduleName = extra[1]
90 return self
91
92class F8_Device(FC3_Device):
93 removedKeywords = FC3_Device.removedKeywords
94 removedAttrs = FC3_Device.removedAttrs
95
96 def __init__(self, writePriority=0, *args, **kwargs):
97 FC3_Device.__init__(self, writePriority, *args, **kwargs)
98 self.deviceList = kwargs.get("deviceList", [])
99
100 def __str__(self):
101 retval = ""
102 for device in self.deviceList:
103 retval += device.__str__()
104
105 return retval
106
107 def parse(self, args):
108 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
109
110 if len(extra) != 1:
111 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name"))
112
113 dd = F8_DeviceData()
114 self._setToObj(self.op, opts, dd)
115 dd.lineno = self.lineno
116 dd.moduleName = extra[0]
117
118 # Check for duplicates in the data list.
119 if dd in self.dataList():
120 warnings.warn(_("A module with the name %s has already been defined.") % dd.moduleName)
121
122 return dd
123
124 def dataList(self):
125 return self.deviceList
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/deviceprobe.py b/scripts/lib/mic/3rdparty/pykickstart/commands/deviceprobe.py
new file mode 100644
index 0000000000..9f462fdff7
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/deviceprobe.py
@@ -0,0 +1,40 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21
22class FC3_DeviceProbe(KickstartCommand):
23 removedKeywords = KickstartCommand.removedKeywords
24 removedAttrs = KickstartCommand.removedAttrs
25
26 def __init__(self, writePriority=0, *args, **kwargs):
27 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
28 self.deviceprobe = kwargs.get("deviceprobe", "")
29
30 def __str__(self):
31 retval = KickstartCommand.__str__(self)
32
33 if self.deviceprobe != "":
34 retval += "deviceprobe %s\n" % self.deviceprobe
35
36 return retval
37
38 def parse(self, args):
39 self.deviceprobe = " ".join(args)
40 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/displaymode.py b/scripts/lib/mic/3rdparty/pykickstart/commands/displaymode.py
new file mode 100644
index 0000000000..6a12d58ec2
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/displaymode.py
@@ -0,0 +1,68 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_DisplayMode(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.displayMode = kwargs.get("displayMode", None)
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.displayMode is None:
40 return retval
41
42 if self.displayMode == DISPLAY_MODE_CMDLINE:
43 retval += "cmdline\n"
44 elif self.displayMode == DISPLAY_MODE_GRAPHICAL:
45 retval += "# Use graphical install\ngraphical\n"
46 elif self.displayMode == DISPLAY_MODE_TEXT:
47 retval += "# Use text mode install\ntext\n"
48
49 return retval
50
51 def _getParser(self):
52 op = KSOptionParser()
53 return op
54
55 def parse(self, args):
56 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
57
58 if len(extra) > 0:
59 raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % self.currentCmd)
60
61 if self.currentCmd == "cmdline":
62 self.displayMode = DISPLAY_MODE_CMDLINE
63 elif self.currentCmd == "graphical":
64 self.displayMode = DISPLAY_MODE_GRAPHICAL
65 elif self.currentCmd == "text":
66 self.displayMode = DISPLAY_MODE_TEXT
67
68 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/dmraid.py b/scripts/lib/mic/3rdparty/pykickstart/commands/dmraid.py
new file mode 100644
index 0000000000..993575a041
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/dmraid.py
@@ -0,0 +1,91 @@
1#
2# Chris Lumens <clumens@redhat.com>
3# Peter Jones <pjones@redhat.com>
4#
5# Copyright 2006, 2007 Red Hat, Inc.
6#
7# This copyrighted material is made available to anyone wishing to use, modify,
8# copy, or redistribute it subject to the terms and conditions of the GNU
9# General Public License v.2. This program is distributed in the hope that it
10# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12# See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# this program; if not, write to the Free Software Foundation, Inc., 51
16# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
17# trademarks that are incorporated in the source code or documentation are not
18# subject to the GNU General Public License and may only be used or replicated
19# with the express permission of Red Hat, Inc.
20#
21from pykickstart.base import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26import warnings
27_ = lambda x: gettext.ldgettext("pykickstart", x)
28
29class FC6_DmRaidData(BaseData):
30 removedKeywords = BaseData.removedKeywords
31 removedAttrs = BaseData.removedAttrs
32
33 def __init__(self, *args, **kwargs):
34 BaseData.__init__(self, *args, **kwargs)
35
36 self.name = kwargs.get("name", "")
37 self.devices = kwargs.get("devices", [])
38 self.dmset = kwargs.get("dmset", None)
39
40 def __eq__(self, y):
41 return self.name == y.name and self.devices == y.devices
42
43 def __str__(self):
44 retval = BaseData.__str__(self)
45 retval += "dmraid --name=%s" % self.name
46
47 for dev in self.devices:
48 retval += " --dev=\"%s\"" % dev
49
50 return retval + "\n"
51
52class FC6_DmRaid(KickstartCommand):
53 removedKeywords = KickstartCommand.removedKeywords
54 removedAttrs = KickstartCommand.removedAttrs
55
56 def __init__(self, writePriority=60, *args, **kwargs):
57 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
58 self.op = self._getParser()
59
60 self.dmraids = kwargs.get("dmraids", [])
61
62 def __str__(self):
63 retval = ""
64 for dm in self.dmraids:
65 retval += dm.__str__()
66
67 return retval
68
69 def _getParser(self):
70 op = KSOptionParser()
71 op.add_option("--name", dest="name", action="store", type="string",
72 required=1)
73 op.add_option("--dev", dest="devices", action="append", type="string",
74 required=1)
75 return op
76
77 def parse(self, args):
78 dm = FC6_DmRaidData()
79 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
80 dm.name = dm.name.split('/')[-1]
81 self._setToObj(self.op, opts, dm)
82 dm.lineno = self.lineno
83
84 # Check for duplicates in the data list.
85 if dm in self.dataList():
86 warnings.warn(_("A DM RAID device with the name %s and devices %s has already been defined.") % (dm.name, dm.devices))
87
88 return dm
89
90 def dataList(self):
91 return self.dmraids
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py b/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py
new file mode 100644
index 0000000000..82a58c0e28
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/driverdisk.py
@@ -0,0 +1,184 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23import gettext
24_ = lambda x: gettext.ldgettext("pykickstart", x)
25
26class FC3_DriverDiskData(BaseData):
27 removedKeywords = BaseData.removedKeywords
28 removedAttrs = BaseData.removedAttrs
29
30 def __init__(self, writePriority=0, *args, **kwargs):
31 BaseData.__init__(self, *args, **kwargs)
32
33 self.partition = kwargs.get("partition", "")
34 self.source = kwargs.get("source", "")
35 self.type = kwargs.get("type", "")
36
37 def _getArgsAsStr(self):
38 retval = ""
39
40 if self.partition:
41 retval += "%s" % self.partition
42
43 if hasattr(self, "type") and self.type:
44 retval += " --type=%s" % self.type
45 elif self.source:
46 retval += "--source=%s" % self.source
47 return retval
48
49 def __str__(self):
50 retval = BaseData.__str__(self)
51 retval += "driverdisk %s\n" % self._getArgsAsStr()
52 return retval
53
54class FC4_DriverDiskData(FC3_DriverDiskData):
55 removedKeywords = FC3_DriverDiskData.removedKeywords
56 removedAttrs = FC3_DriverDiskData.removedAttrs
57
58 def __init__(self, writePriority=0, *args, **kwargs):
59 FC3_DriverDiskData.__init__(self, *args, **kwargs)
60 self.deleteRemovedAttrs()
61
62 self.biospart = kwargs.get("biospart", "")
63
64 def _getArgsAsStr(self):
65 retval = ""
66
67 if self.partition:
68 retval += "%s" % self.partition
69
70 if hasattr(self, "type") and self.type:
71 retval += " --type=%s" % self.type
72 elif self.source:
73 retval += "--source=%s" % self.source
74 elif self.biospart:
75 retval += "--biospart=%s" % self.biospart
76
77 return retval
78
79class F12_DriverDiskData(FC4_DriverDiskData):
80 removedKeywords = FC4_DriverDiskData.removedKeywords + ["type"]
81 removedAttrs = FC4_DriverDiskData.removedAttrs + ["type"]
82
83 def __init__(self, *args, **kwargs):
84 FC4_DriverDiskData.__init__(self, *args, **kwargs)
85 self.deleteRemovedAttrs()
86
87F14_DriverDiskData = F12_DriverDiskData
88
89class FC3_DriverDisk(KickstartCommand):
90 removedKeywords = KickstartCommand.removedKeywords
91 removedAttrs = KickstartCommand.removedAttrs
92
93 def __init__(self, writePriority=0, *args, **kwargs):
94 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
95 self.op = self._getParser()
96
97 self.driverdiskList = kwargs.get("driverdiskList", [])
98
99 def __str__(self):
100 retval = ""
101 for dd in self.driverdiskList:
102 retval += dd.__str__()
103
104 return retval
105
106 def _getParser(self):
107 op = KSOptionParser()
108 op.add_option("--source")
109 op.add_option("--type")
110 return op
111
112 def parse(self, args):
113 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
114
115 if len(extra) > 1:
116 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))
117
118 if len(extra) == 1 and opts.source:
119 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))
120
121 if not extra and not opts.source:
122 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command."))
123
124 ddd = self.handler.DriverDiskData()
125 self._setToObj(self.op, opts, ddd)
126 ddd.lineno = self.lineno
127 if len(extra) == 1:
128 ddd.partition = extra[0]
129
130 return ddd
131
132 def dataList(self):
133 return self.driverdiskList
134
135class FC4_DriverDisk(FC3_DriverDisk):
136 removedKeywords = FC3_DriverDisk.removedKeywords
137 removedAttrs = FC3_DriverDisk.removedKeywords
138
139 def _getParser(self):
140 op = FC3_DriverDisk._getParser(self)
141 op.add_option("--biospart")
142 return op
143
144 def parse(self, args):
145 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
146
147 if len(extra) > 1:
148 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))
149
150 if len(extra) == 1 and opts.source:
151 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))
152 elif len(extra) == 1 and opts.biospart:
153 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command."))
154 elif opts.source and opts.biospart:
155 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command."))
156
157 if not extra and not opts.source and not opts.biospart:
158 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command."))
159
160 ddd = self.handler.DriverDiskData()
161 self._setToObj(self.op, opts, ddd)
162 ddd.lineno = self.lineno
163 if len(extra) == 1:
164 ddd.partition = extra[0]
165
166 return ddd
167
168class F12_DriverDisk(FC4_DriverDisk):
169 removedKeywords = FC4_DriverDisk.removedKeywords
170 removedAttrs = FC4_DriverDisk.removedKeywords
171
172 def _getParser(self):
173 op = FC4_DriverDisk._getParser(self)
174 op.add_option("--type", deprecated=1)
175 return op
176
177class F14_DriverDisk(F12_DriverDisk):
178 removedKeywords = F12_DriverDisk.removedKeywords
179 removedAttrs = F12_DriverDisk.removedKeywords
180
181 def _getParser(self):
182 op = F12_DriverDisk._getParser(self)
183 op.remove_option("--type")
184 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py b/scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py
new file mode 100644
index 0000000000..33208499b3
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py
@@ -0,0 +1,114 @@
1#
2# Hans de Goede <hdegoede@redhat.com>
3#
4# Copyright 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23import gettext
24import warnings
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class F12_FcoeData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
30
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.nic = kwargs.get("nic", None)
34
35 def __eq__(self, y):
36 return self.nic == y.nic
37
38 def _getArgsAsStr(self):
39 retval = ""
40
41 if self.nic:
42 retval += " --nic=%s" % self.nic
43
44 return retval
45
46 def __str__(self):
47 retval = BaseData.__str__(self)
48 retval += "fcoe%s\n" % self._getArgsAsStr()
49 return retval
50
51class F13_FcoeData(F12_FcoeData):
52 removedKeywords = F12_FcoeData.removedKeywords
53 removedAttrs = F12_FcoeData.removedAttrs
54
55 def __init__(self, *args, **kwargs):
56 F12_FcoeData.__init__(self, *args, **kwargs)
57 self.dcb = kwargs.get("dcb", False)
58
59 def _getArgsAsStr(self):
60 retval = F12_FcoeData._getArgsAsStr(self)
61
62 if self.dcb:
63 retval += " --dcb"
64
65 return retval
66
67class F12_Fcoe(KickstartCommand):
68 removedKeywords = KickstartCommand.removedKeywords
69 removedAttrs = KickstartCommand.removedAttrs
70
71 def __init__(self, writePriority=71, *args, **kwargs):
72 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
73 self.op = self._getParser()
74 self.fcoe = kwargs.get("fcoe", [])
75
76 def __str__(self):
77 retval = ""
78 for fcoe in self.fcoe:
79 retval += fcoe.__str__()
80
81 return retval
82
83 def _getParser(self):
84 op = KSOptionParser()
85 op.add_option("--nic", dest="nic", required=1)
86 return op
87
88 def parse(self, args):
89 zd = self.handler.FcoeData()
90 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
91 if len(extra) > 0:
92 mapping = {"command": "fcoe", "options": extra}
93 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
94
95 self._setToObj(self.op, opts, zd)
96 zd.lineno = self.lineno
97
98 # Check for duplicates in the data list.
99 if zd in self.dataList():
100 warnings.warn(_("A FCOE device with the name %s has already been defined.") % zd.nic)
101
102 return zd
103
104 def dataList(self):
105 return self.fcoe
106
107class F13_Fcoe(F12_Fcoe):
108 removedKeywords = F12_Fcoe.removedKeywords
109 removedAttrs = F12_Fcoe.removedAttrs
110
111 def _getParser(self):
112 op = F12_Fcoe._getParser(self)
113 op.add_option("--dcb", dest="dcb", action="store_true", default=False)
114 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/firewall.py b/scripts/lib/mic/3rdparty/pykickstart/commands/firewall.py
new file mode 100644
index 0000000000..24a01bd610
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/firewall.py
@@ -0,0 +1,193 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Firewall(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.enabled = kwargs.get("enabled", None)
36 self.ports = kwargs.get("ports", [])
37 self.trusts = kwargs.get("trusts", [])
38
39 def __str__(self):
40 extra = []
41 filteredPorts = []
42
43 retval = KickstartCommand.__str__(self)
44
45 if self.enabled is None:
46 return retval
47
48 if self.enabled:
49 # It's possible we have words in the ports list instead of
50 # port:proto (s-c-kickstart may do this). So, filter those
51 # out into their own list leaving what we expect.
52 for port in self.ports:
53 if port == "ssh":
54 extra.append(" --ssh")
55 elif port == "telnet":
56 extra.append(" --telnet")
57 elif port == "smtp":
58 extra.append(" --smtp")
59 elif port == "http":
60 extra.append(" --http")
61 elif port == "ftp":
62 extra.append(" --ftp")
63 else:
64 filteredPorts.append(port)
65
66 # All the port:proto strings go into a comma-separated list.
67 portstr = ",".join(filteredPorts)
68 if len(portstr) > 0:
69 portstr = " --port=" + portstr
70 else:
71 portstr = ""
72
73 extrastr = "".join(extra)
74 truststr = ",".join(self.trusts)
75
76 if len(truststr) > 0:
77 truststr = " --trust=" + truststr
78
79 # The output port list consists only of port:proto for
80 # everything that we don't recognize, and special options for
81 # those that we do.
82 retval += "# Firewall configuration\nfirewall --enabled%s%s%s\n" % (extrastr, portstr, truststr)
83 else:
84 retval += "# Firewall configuration\nfirewall --disabled\n"
85
86 return retval
87
88 def _getParser(self):
89 def firewall_port_cb (option, opt_str, value, parser):
90 for p in value.split(","):
91 p = p.strip()
92 if p.find(":") == -1:
93 p = "%s:tcp" % p
94 parser.values.ensure_value(option.dest, []).append(p)
95
96 op = KSOptionParser(mapping={"ssh":["22:tcp"], "telnet":["23:tcp"],
97 "smtp":["25:tcp"], "http":["80:tcp", "443:tcp"],
98 "ftp":["21:tcp"]})
99
100 op.add_option("--disable", "--disabled", dest="enabled",
101 action="store_false")
102 op.add_option("--enable", "--enabled", dest="enabled",
103 action="store_true", default=True)
104 op.add_option("--ftp", "--http", "--smtp", "--ssh", "--telnet",
105 dest="ports", action="map_extend")
106 op.add_option("--high", deprecated=1)
107 op.add_option("--medium", deprecated=1)
108 op.add_option("--port", dest="ports", action="callback",
109 callback=firewall_port_cb, nargs=1, type="string")
110 op.add_option("--trust", dest="trusts", action="append")
111 return op
112
113 def parse(self, args):
114 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
115
116 if len(extra) != 0:
117 mapping = {"command": "firewall", "options": extra}
118 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
119
120 self._setToSelf(self.op, opts)
121 return self
122
123class F9_Firewall(FC3_Firewall):
124 removedKeywords = FC3_Firewall.removedKeywords
125 removedAttrs = FC3_Firewall.removedAttrs
126
127 def _getParser(self):
128 op = FC3_Firewall._getParser(self)
129 op.remove_option("--high")
130 op.remove_option("--medium")
131 return op
132
133class F10_Firewall(F9_Firewall):
134 removedKeywords = F9_Firewall.removedKeywords
135 removedAttrs = F9_Firewall.removedAttrs
136
137 def __init__(self, writePriority=0, *args, **kwargs):
138 F9_Firewall.__init__(self, writePriority, *args, **kwargs)
139 self.services = kwargs.get("services", [])
140
141 def __str__(self):
142 if self.enabled is None:
143 return ""
144
145 retval = F9_Firewall.__str__(self)
146 if self.enabled:
147 retval = retval.strip()
148
149 svcstr = ",".join(self.services)
150 if len(svcstr) > 0:
151 svcstr = " --service=" + svcstr
152 else:
153 svcstr = ""
154
155 return retval + "%s\n" % svcstr
156 else:
157 return retval
158
159 def _getParser(self):
160 def service_cb (option, opt_str, value, parser):
161 # python2.4 does not support action="append_const" that we were
162 # using for these options. Instead, we have to fake it by
163 # appending whatever the option string is to the service list.
164 if not value:
165 parser.values.ensure_value(option.dest, []).append(opt_str[2:])
166 return
167
168 for p in value.split(","):
169 p = p.strip()
170 parser.values.ensure_value(option.dest, []).append(p)
171
172 op = F9_Firewall._getParser(self)
173 op.add_option("--service", dest="services", action="callback",
174 callback=service_cb, nargs=1, type="string")
175 op.add_option("--ftp", dest="services", action="callback",
176 callback=service_cb)
177 op.add_option("--http", dest="services", action="callback",
178 callback=service_cb)
179 op.add_option("--smtp", dest="services", action="callback",
180 callback=service_cb)
181 op.add_option("--ssh", dest="services", action="callback",
182 callback=service_cb)
183 op.add_option("--telnet", deprecated=1)
184 return op
185
186class F14_Firewall(F10_Firewall):
187 removedKeywords = F10_Firewall.removedKeywords + ["telnet"]
188 removedAttrs = F10_Firewall.removedAttrs + ["telnet"]
189
190 def _getParser(self):
191 op = F10_Firewall._getParser(self)
192 op.remove_option("--telnet")
193 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/firstboot.py b/scripts/lib/mic/3rdparty/pykickstart/commands/firstboot.py
new file mode 100644
index 0000000000..05c0ac11c6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/firstboot.py
@@ -0,0 +1,62 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.options import *
23
24class FC3_Firstboot(KickstartCommand):
25 removedKeywords = KickstartCommand.removedKeywords
26 removedAttrs = KickstartCommand.removedAttrs
27
28 def __init__(self, writePriority=0, *args, **kwargs):
29 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
30 self.op = self._getParser()
31
32 self.firstboot = kwargs.get("firstboot", None)
33
34 def __str__(self):
35 retval = KickstartCommand.__str__(self)
36
37 if self.firstboot is None:
38 return retval
39
40 if self.firstboot == FIRSTBOOT_SKIP:
41 retval += "firstboot --disable\n"
42 elif self.firstboot == FIRSTBOOT_DEFAULT:
43 retval += "# Run the Setup Agent on first boot\nfirstboot --enable\n"
44 elif self.firstboot == FIRSTBOOT_RECONFIG:
45 retval += "# Run the Setup Agent on first boot\nfirstboot --reconfig\n"
46
47 return retval
48
49 def _getParser(self):
50 op = KSOptionParser()
51 op.add_option("--disable", "--disabled", dest="firstboot",
52 action="store_const", const=FIRSTBOOT_SKIP)
53 op.add_option("--enable", "--enabled", dest="firstboot",
54 action="store_const", const=FIRSTBOOT_DEFAULT)
55 op.add_option("--reconfig", dest="firstboot", action="store_const",
56 const=FIRSTBOOT_RECONFIG)
57 return op
58
59 def parse(self, args):
60 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
61 self.firstboot = opts.firstboot
62 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/group.py b/scripts/lib/mic/3rdparty/pykickstart/commands/group.py
new file mode 100644
index 0000000000..80ba5bdca6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/group.py
@@ -0,0 +1,88 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26import warnings
27_ = lambda x: gettext.ldgettext("pykickstart", x)
28
29class F12_GroupData(BaseData):
30 removedKeywords = BaseData.removedKeywords
31 removedAttrs = BaseData.removedAttrs
32
33 def __init__(self, *args, **kwargs):
34 BaseData.__init__(self, *args, **kwargs)
35 self.name = kwargs.get("name", "")
36 self.gid = kwargs.get("gid", None)
37
38 def __eq__(self, y):
39 return self.name == y.name
40
41 def __str__(self):
42 retval = BaseData.__str__(self)
43 retval += "group"
44
45 if self.name:
46 retval += " --name=%s" % self.name
47 if self.gid:
48 retval += " --gid=%s" % self.gid
49
50 return retval + "\n"
51
52class F12_Group(KickstartCommand):
53 removedKeywords = KickstartCommand.removedKeywords
54 removedAttrs = KickstartCommand.removedAttrs
55
56 def __init__(self, writePriority=0, *args, **kwargs):
57 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
58 self.op = self._getParser()
59
60 self.groupList = kwargs.get("groupList", [])
61
62 def __str__(self):
63 retval = ""
64 for user in self.groupList:
65 retval += user.__str__()
66
67 return retval
68
69 def _getParser(self):
70 op = KSOptionParser()
71 op.add_option("--name", required=1)
72 op.add_option("--gid", type="int")
73 return op
74
75 def parse(self, args):
76 gd = self.handler.GroupData()
77 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
78 self._setToObj(self.op, opts, gd)
79 gd.lineno = self.lineno
80
81 # Check for duplicates in the data list.
82 if gd in self.dataList():
83 warnings.warn(_("A group with the name %s has already been defined.") % gd.name)
84
85 return gd
86
87 def dataList(self):
88 return self.groupList
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py b/scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py
new file mode 100644
index 0000000000..676d080836
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/ignoredisk.py
@@ -0,0 +1,139 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23import gettext
24_ = lambda x: gettext.ldgettext("pykickstart", x)
25
26class FC3_IgnoreDisk(KickstartCommand):
27 removedKeywords = KickstartCommand.removedKeywords
28 removedAttrs = KickstartCommand.removedAttrs
29
30 def __init__(self, writePriority=0, *args, **kwargs):
31 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
32 self.op = self._getParser()
33
34 self.ignoredisk = kwargs.get("ignoredisk", [])
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if len(self.ignoredisk) > 0:
40 retval += "ignoredisk --drives=%s\n" % ",".join(self.ignoredisk)
41
42 return retval
43
44 def _getParser(self):
45 def drive_cb (option, opt_str, value, parser):
46 for d in value.split(','):
47 parser.values.ensure_value(option.dest, []).append(d)
48
49 op = KSOptionParser()
50 op.add_option("--drives", dest="ignoredisk", action="callback",
51 callback=drive_cb, nargs=1, type="string", required=1)
52 return op
53
54 def parse(self, args):
55 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
56 self._setToSelf(self.op, opts)
57 return self
58
59class F8_IgnoreDisk(FC3_IgnoreDisk):
60 removedKeywords = FC3_IgnoreDisk.removedKeywords
61 removedAttrs = FC3_IgnoreDisk.removedAttrs
62
63 def __init__(self, writePriority=0, *args, **kwargs):
64 FC3_IgnoreDisk.__init__(self, writePriority, *args, **kwargs)
65
66 self.onlyuse = kwargs.get("onlyuse", [])
67
68 def __str__(self):
69 retval = KickstartCommand.__str__(self)
70
71 if len(self.ignoredisk) > 0:
72 retval += "ignoredisk --drives=%s\n" % ",".join(self.ignoredisk)
73 elif len(self.onlyuse) > 0:
74 retval += "ignoredisk --only-use=%s\n" % ",".join(self.onlyuse)
75
76 return retval
77
78 def parse(self, args, errorCheck=True):
79 retval = FC3_IgnoreDisk.parse(self, args)
80
81 if errorCheck:
82 if (len(self.ignoredisk) == 0 and len(self.onlyuse) == 0) or (len(self.ignoredisk) > 0 and (len(self.onlyuse) > 0)):
83 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command."))
84
85 return retval
86
87 def _getParser(self):
88 def drive_cb (option, opt_str, value, parser):
89 for d in value.split(','):
90 parser.values.ensure_value(option.dest, []).append(d)
91
92 op = FC3_IgnoreDisk._getParser(self)
93 op.add_option("--drives", dest="ignoredisk", action="callback",
94 callback=drive_cb, nargs=1, type="string")
95 op.add_option("--only-use", dest="onlyuse", action="callback",
96 callback=drive_cb, nargs=1, type="string")
97 return op
98
99class RHEL6_IgnoreDisk(F8_IgnoreDisk):
100 removedKeywords = F8_IgnoreDisk.removedKeywords
101 removedAttrs = F8_IgnoreDisk.removedAttrs
102
103 def __init__(self, writePriority=0, *args, **kwargs):
104 F8_IgnoreDisk.__init__(self, writePriority, *args, **kwargs)
105
106 self.interactive = kwargs.get("interactive", False)
107 if self.interactive:
108 self.ignoredisk = []
109
110 def __str__(self):
111 retval = F8_IgnoreDisk.__str__(self)
112
113 if self.interactive:
114 retval = "ignoredisk --interactive\n"
115
116 return retval
117
118 def parse(self, args):
119 retval = F8_IgnoreDisk.parse(self, args, errorCheck=False)
120
121 howmany = 0
122 if len(self.ignoredisk) > 0:
123 howmany += 1
124 if len(self.onlyuse) > 0:
125 howmany += 1
126 if self.interactive:
127 howmany += 1
128 if howmany != 1:
129 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command."))
130
131 return retval
132
133 def _getParser(self):
134 op = F8_IgnoreDisk._getParser(self)
135 op.add_option("--interactive", dest="interactive", action="store_true",
136 default=False)
137 return op
138
139F14_IgnoreDisk = RHEL6_IgnoreDisk
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/interactive.py b/scripts/lib/mic/3rdparty/pykickstart/commands/interactive.py
new file mode 100644
index 0000000000..fa3dc025b1
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/interactive.py
@@ -0,0 +1,58 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Interactive(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.interactive = kwargs.get("interactive", False)
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.interactive:
40 retval += "# Use interactive kickstart installation method\ninteractive\n"
41
42 return retval
43
44 def _getParser(self):
45 op = KSOptionParser()
46 return op
47
48 def parse(self, args):
49 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
50 if len(extra) > 0:
51 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "interactive")
52
53 self.interactive = True
54 return self
55
56class F14_Interactive(DeprecatedCommand):
57 def __init__(self):
58 DeprecatedCommand.__init__(self)
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/iscsi.py b/scripts/lib/mic/3rdparty/pykickstart/commands/iscsi.py
new file mode 100644
index 0000000000..da5a544e86
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/iscsi.py
@@ -0,0 +1,133 @@
1#
2# Chris Lumens <clumens@redhat.com>
3# Peter Jones <pjones@redhat.com>
4#
5# Copyright 2005, 2006, 2007 Red Hat, Inc.
6#
7# This copyrighted material is made available to anyone wishing to use, modify,
8# copy, or redistribute it subject to the terms and conditions of the GNU
9# General Public License v.2. This program is distributed in the hope that it
10# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12# See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# this program; if not, write to the Free Software Foundation, Inc., 51
16# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
17# trademarks that are incorporated in the source code or documentation are not
18# subject to the GNU General Public License and may only be used or replicated
19# with the express permission of Red Hat, Inc.
20#
21from pykickstart.base import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC6_IscsiData(BaseData):
29 removedKeywords = BaseData.removedKeywords
30 removedAttrs = BaseData.removedAttrs
31
32 def __init__(self, *args, **kwargs):
33 BaseData.__init__(self, *args, **kwargs)
34 self.ipaddr = kwargs.get("ipaddr", "")
35 self.port = kwargs.get("port", "3260")
36 self.target = kwargs.get("target", "")
37 self.user = kwargs.get("user", None)
38 self.password = kwargs.get("password", None)
39
40 def _getArgsAsStr(self):
41 retval = ""
42
43 if self.target != "":
44 retval += " --target=%s" % self.target
45 if self.ipaddr != "":
46 retval += " --ipaddr=%s" % self.ipaddr
47 if self.port != "3260":
48 retval += " --port=%s" % self.port
49 if self.user is not None:
50 retval += " --user=%s" % self.user
51 if self.password is not None:
52 retval += " --password=%s" % self.password
53
54 return retval
55
56 def __str__(self):
57 retval = BaseData.__str__(self)
58 retval += "iscsi%s\n" % self._getArgsAsStr()
59 return retval
60
61class F10_IscsiData(FC6_IscsiData):
62 removedKeywords = FC6_IscsiData.removedKeywords
63 removedAttrs = FC6_IscsiData.removedAttrs
64
65 def __init__(self, *args, **kwargs):
66 FC6_IscsiData.__init__(self, *args, **kwargs)
67 self.user_in = kwargs.get("user_in", None)
68 self.password_in = kwargs.get("password_in", None)
69
70 def _getArgsAsStr(self):
71 retval = FC6_IscsiData._getArgsAsStr(self)
72
73 if self.user_in is not None:
74 retval += " --reverse-user=%s" % self.user_in
75 if self.password_in is not None:
76 retval += " --reverse-password=%s" % self.password_in
77
78 return retval
79
80class FC6_Iscsi(KickstartCommand):
81 removedKeywords = KickstartCommand.removedKeywords
82 removedAttrs = KickstartCommand.removedAttrs
83
84 def __init__(self, writePriority=71, *args, **kwargs):
85 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
86 self.op = self._getParser()
87
88 self.iscsi = kwargs.get("iscsi", [])
89
90 def __str__(self):
91 retval = ""
92 for iscsi in self.iscsi:
93 retval += iscsi.__str__()
94
95 return retval
96
97 def _getParser(self):
98 op = KSOptionParser()
99 op.add_option("--target", dest="target", action="store", type="string")
100 op.add_option("--ipaddr", dest="ipaddr", action="store", type="string",
101 required=1)
102 op.add_option("--port", dest="port", action="store", type="string")
103 op.add_option("--user", dest="user", action="store", type="string")
104 op.add_option("--password", dest="password", action="store",
105 type="string")
106 return op
107
108 def parse(self, args):
109 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
110
111 if len(extra) != 0:
112 mapping = {"command": "iscsi", "options": extra}
113 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
114
115 dd = self.handler.IscsiData()
116 self._setToObj(self.op, opts, dd)
117 dd.lineno = self.lineno
118 return dd
119
120 def dataList(self):
121 return self.iscsi
122
123class F10_Iscsi(FC6_Iscsi):
124 removedKeywords = FC6_Iscsi.removedKeywords
125 removedAttrs = FC6_Iscsi.removedAttrs
126
127 def _getParser(self):
128 op = FC6_Iscsi._getParser(self)
129 op.add_option("--reverse-user", dest="user_in", action="store",
130 type="string")
131 op.add_option("--reverse-password", dest="password_in", action="store",
132 type="string")
133 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/iscsiname.py b/scripts/lib/mic/3rdparty/pykickstart/commands/iscsiname.py
new file mode 100644
index 0000000000..a87d0637d6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/iscsiname.py
@@ -0,0 +1,54 @@
1#
2# Chris Lumens <clumens@redhat.com>
3# Peter Jones <pjones@redhat.com>
4#
5# Copyright 2006, 2007 Red Hat, Inc.
6#
7# This copyrighted material is made available to anyone wishing to use, modify,
8# copy, or redistribute it subject to the terms and conditions of the GNU
9# General Public License v.2. This program is distributed in the hope that it
10# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12# See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# this program; if not, write to the Free Software Foundation, Inc., 51
16# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
17# trademarks that are incorporated in the source code or documentation are not
18# subject to the GNU General Public License and may only be used or replicated
19# with the express permission of Red Hat, Inc.
20#
21from pykickstart.base import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC6_IscsiName(KickstartCommand):
29 removedKeywords = KickstartCommand.removedKeywords
30 removedAttrs = KickstartCommand.removedAttrs
31
32 def __init__(self, writePriority=70, *args, **kwargs):
33 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
34 self.op = self._getParser()
35 self.iscsiname = kwargs.get("iscsiname", "")
36
37 def __str__(self):
38 retval = KickstartCommand.__str__(self)
39
40 if self.iscsiname != "":
41 retval += "iscsiname %s\n" % self.iscsiname
42
43 return retval
44
45 def _getParser(self):
46 op = KSOptionParser()
47 return op
48
49 def parse(self, args):
50 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
51 if len(extra) != 1:
52 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "iscsiname")
53 self.iscsiname = extra[0]
54 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/key.py b/scripts/lib/mic/3rdparty/pykickstart/commands/key.py
new file mode 100644
index 0000000000..c20c4231f6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/key.py
@@ -0,0 +1,64 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class RHEL5_Key(KickstartCommand):
29 removedKeywords = KickstartCommand.removedKeywords
30 removedAttrs = KickstartCommand.removedAttrs
31
32 def __init__(self, writePriority=0, *args, **kwargs):
33 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
34 self.op = self._getParser()
35 self.key = kwargs.get("key", "")
36 self.skip = kwargs.get("skip", False)
37
38 def __str__(self):
39 retval = KickstartCommand.__str__(self)
40
41 if self.key == KS_INSTKEY_SKIP:
42 retval += "key --skip\n"
43 elif self.key != "":
44 retval += "key %s\n" % self.key
45
46 return retval
47
48 def _getParser(self):
49 op = KSOptionParser()
50 op.add_option("--skip", action="store_true", default=False)
51 return op
52
53 def parse(self, args):
54 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
55 self._setToSelf(self.op, opts)
56
57 if self.skip:
58 self.key = KS_INSTKEY_SKIP
59 elif len(extra) != 1:
60 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "key")
61 else:
62 self.key = extra[0]
63
64 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/keyboard.py b/scripts/lib/mic/3rdparty/pykickstart/commands/keyboard.py
new file mode 100644
index 0000000000..babc2acd4c
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/keyboard.py
@@ -0,0 +1,55 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Keyboard(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.keyboard = kwargs.get("keyboard", "")
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.keyboard != "":
40 retval += "# System keyboard\nkeyboard %s\n" % self.keyboard
41
42 return retval
43
44 def _getParser(self):
45 op = KSOptionParser()
46 return op
47
48 def parse(self, args):
49 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
50
51 if len(extra) != 1:
52 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "keyboard")
53
54 self.keyboard = extra[0]
55 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/lang.py b/scripts/lib/mic/3rdparty/pykickstart/commands/lang.py
new file mode 100644
index 0000000000..cf5e46cda7
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/lang.py
@@ -0,0 +1,60 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Lang(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.lang = kwargs.get("lang", "")
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.lang != "":
40 retval += "# System language\nlang %s\n" % self.lang
41
42 return retval
43
44 def _getParser(self):
45 op = KSOptionParser()
46 return op
47
48 def parse(self, args):
49 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
50 if len(extra) != 1:
51 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "lang")
52
53 self.lang = extra[0]
54 return self
55
56 def apply(self, instroot="/"):
57 if self.lang == "": return
58 f = open(instroot + "/etc/sysconfig/i18n", "w+")
59 f.write("LANG=\"%s\"\n" %(self.lang,))
60 f.close()
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/langsupport.py b/scripts/lib/mic/3rdparty/pykickstart/commands/langsupport.py
new file mode 100644
index 0000000000..73a9e537a9
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/langsupport.py
@@ -0,0 +1,58 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23class FC3_LangSupport(KickstartCommand):
24 removedKeywords = KickstartCommand.removedKeywords
25 removedAttrs = KickstartCommand.removedAttrs
26
27 def __init__(self, writePriority=0, *args, **kwargs):
28 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
29 self.op = self._getParser()
30
31 self.deflang = kwargs.get("deflang", "")
32 self.supported = kwargs.get("supported", [])
33
34 def __str__(self):
35 retval = KickstartCommand.__str__(self)
36
37 if self.deflang:
38 retval += "langsupport --default=%s" % self.deflang
39
40 if self.supported:
41 retval += " %s" % " ".join(self.supported)
42
43 return retval + "\n"
44
45 def _getParser(self):
46 op = KSOptionParser()
47 op.add_option("--default", dest="deflang", default="en_US.UTF-8")
48 return op
49
50 def parse(self, args):
51 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
52 self._setToSelf(self.op, opts)
53 self.supported = extra
54 return self
55
56class FC5_LangSupport(DeprecatedCommand):
57 def __init__(self):
58 DeprecatedCommand.__init__(self)
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/lilocheck.py b/scripts/lib/mic/3rdparty/pykickstart/commands/lilocheck.py
new file mode 100644
index 0000000000..92b3f930b6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/lilocheck.py
@@ -0,0 +1,54 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_LiloCheck(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.check = kwargs.get("check", False)
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.check:
40 retval += "lilocheck\n"
41
42 return retval
43
44 def _getParser(self):
45 op = KSOptionParser()
46 return op
47
48 def parse(self, args):
49 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
50 if len(extra) > 0:
51 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "lilocheck")
52
53 self.check = True
54 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/logging.py b/scripts/lib/mic/3rdparty/pykickstart/commands/logging.py
new file mode 100644
index 0000000000..698561994d
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/logging.py
@@ -0,0 +1,66 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007, 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC6_Logging(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.host = kwargs.get("host", "")
36 self.level = kwargs.get("level", "info")
37 self.port = kwargs.get("port", "")
38
39 def __str__(self):
40 retval = KickstartCommand.__str__(self)
41 retval += "# Installation logging level\nlogging --level=%s" % self.level
42
43 if self.host != "":
44 retval += " --host=%s" % self.host
45
46 if self.port != "":
47 retval += " --port=%s" % self.port
48
49 return retval + "\n"
50
51 def _getParser(self):
52 op = KSOptionParser()
53 op.add_option("--host")
54 op.add_option("--level", type="choice", default="info",
55 choices=["debug", "info", "warning", "error", "critical"])
56 op.add_option("--port")
57 return op
58
59 def parse(self, args):
60 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
61
62 if opts.port and not opts.host:
63 raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Can't specify --port without --host."))
64
65 self._setToSelf(self.op, opts)
66 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py b/scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
new file mode 100644
index 0000000000..c1b9cc3a61
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
@@ -0,0 +1,304 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25import warnings
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC3_LogVolData(BaseData):
29 removedKeywords = BaseData.removedKeywords
30 removedAttrs = BaseData.removedAttrs
31
32 def __init__(self, *args, **kwargs):
33 BaseData.__init__(self, *args, **kwargs)
34 self.fstype = kwargs.get("fstype", "")
35 self.grow = kwargs.get("grow", False)
36 self.maxSizeMB = kwargs.get("maxSizeMB", 0)
37 self.name = kwargs.get("name", "")
38 self.format = kwargs.get("format", True)
39 self.percent = kwargs.get("percent", 0)
40 self.recommended = kwargs.get("recommended", False)
41 self.size = kwargs.get("size", None)
42 self.preexist = kwargs.get("preexist", False)
43 self.vgname = kwargs.get("vgname", "")
44 self.mountpoint = kwargs.get("mountpoint", "")
45
46 def __eq__(self, y):
47 return self.vgname == y.vgname and self.name == y.name
48
49 def _getArgsAsStr(self):
50 retval = ""
51
52 if self.fstype != "":
53 retval += " --fstype=\"%s\"" % self.fstype
54 if self.grow:
55 retval += " --grow"
56 if self.maxSizeMB > 0:
57 retval += " --maxsize=%d" % self.maxSizeMB
58 if not self.format:
59 retval += " --noformat"
60 if self.percent > 0:
61 retval += " --percent=%d" % self.percent
62 if self.recommended:
63 retval += " --recommended"
64 if self.size > 0:
65 retval += " --size=%d" % self.size
66 if self.preexist:
67 retval += " --useexisting"
68
69 return retval
70
71 def __str__(self):
72 retval = BaseData.__str__(self)
73 retval += "logvol %s %s --name=%s --vgname=%s\n" % (self.mountpoint, self._getArgsAsStr(), self.name, self.vgname)
74 return retval
75
76class FC4_LogVolData(FC3_LogVolData):
77 removedKeywords = FC3_LogVolData.removedKeywords
78 removedAttrs = FC3_LogVolData.removedAttrs
79
80 def __init__(self, *args, **kwargs):
81 FC3_LogVolData.__init__(self, *args, **kwargs)
82 self.bytesPerInode = kwargs.get("bytesPerInode", 4096)
83 self.fsopts = kwargs.get("fsopts", "")
84
85 def _getArgsAsStr(self):
86 retval = FC3_LogVolData._getArgsAsStr(self)
87
88 if hasattr(self, "bytesPerInode") and self.bytesPerInode != 0:
89 retval += " --bytes-per-inode=%d" % self.bytesPerInode
90 if self.fsopts != "":
91 retval += " --fsoptions=\"%s\"" % self.fsopts
92
93 return retval
94
95class RHEL5_LogVolData(FC4_LogVolData):
96 removedKeywords = FC4_LogVolData.removedKeywords
97 removedAttrs = FC4_LogVolData.removedAttrs
98
99 def __init__(self, *args, **kwargs):
100 FC4_LogVolData.__init__(self, *args, **kwargs)
101 self.encrypted = kwargs.get("encrypted", False)
102 self.passphrase = kwargs.get("passphrase", "")
103
104 def _getArgsAsStr(self):
105 retval = FC4_LogVolData._getArgsAsStr(self)
106
107 if self.encrypted:
108 retval += " --encrypted"
109
110 if self.passphrase != "":
111 retval += " --passphrase=\"%s\"" % self.passphrase
112
113 return retval
114
115class F9_LogVolData(FC4_LogVolData):
116 removedKeywords = FC4_LogVolData.removedKeywords + ["bytesPerInode"]
117 removedAttrs = FC4_LogVolData.removedAttrs + ["bytesPerInode"]
118
119 def __init__(self, *args, **kwargs):
120 FC4_LogVolData.__init__(self, *args, **kwargs)
121 self.deleteRemovedAttrs()
122
123 self.fsopts = kwargs.get("fsopts", "")
124 self.fsprofile = kwargs.get("fsprofile", "")
125 self.encrypted = kwargs.get("encrypted", False)
126 self.passphrase = kwargs.get("passphrase", "")
127
128 def _getArgsAsStr(self):
129 retval = FC4_LogVolData._getArgsAsStr(self)
130
131 if self.fsprofile != "":
132 retval += " --fsprofile=\"%s\"" % self.fsprofile
133 if self.encrypted:
134 retval += " --encrypted"
135
136 if self.passphrase != "":
137 retval += " --passphrase=\"%s\"" % self.passphrase
138
139 return retval
140
141class F12_LogVolData(F9_LogVolData):
142 removedKeywords = F9_LogVolData.removedKeywords
143 removedAttrs = F9_LogVolData.removedAttrs
144
145 def __init__(self, *args, **kwargs):
146 F9_LogVolData.__init__(self, *args, **kwargs)
147 self.deleteRemovedAttrs()
148
149 self.escrowcert = kwargs.get("escrowcert", "")
150 self.backuppassphrase = kwargs.get("backuppassphrase", False)
151
152 def _getArgsAsStr(self):
153 retval = F9_LogVolData._getArgsAsStr(self)
154
155 if self.encrypted and self.escrowcert != "":
156 retval += " --escrowcert=\"%s\"" % self.escrowcert
157
158 if self.backuppassphrase:
159 retval += " --backuppassphrase"
160
161 return retval
162
163F14_LogVolData = F12_LogVolData
164
165class F15_LogVolData(F14_LogVolData):
166 removedKeywords = F14_LogVolData.removedKeywords
167 removedAttrs = F14_LogVolData.removedAttrs
168
169 def __init__(self, *args, **kwargs):
170 F14_LogVolData.__init__(self, *args, **kwargs)
171 self.label = kwargs.get("label", "")
172
173 def _getArgsAsStr(self):
174 retval = F14_LogVolData._getArgsAsStr(self)
175
176 if self.label != "":
177 retval += " --label=\"%s\"" % self.label
178
179 return retval
180
181class FC3_LogVol(KickstartCommand):
182 removedKeywords = KickstartCommand.removedKeywords
183 removedAttrs = KickstartCommand.removedAttrs
184
185 def __init__(self, writePriority=133, *args, **kwargs):
186 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
187 self.op = self._getParser()
188
189 self.lvList = kwargs.get("lvList", [])
190
191 def __str__(self):
192 retval = ""
193
194 for part in self.lvList:
195 retval += part.__str__()
196
197 return retval
198
199 def _getParser(self):
200 def lv_cb (option, opt_str, value, parser):
201 parser.values.format = False
202 parser.values.preexist = True
203
204 op = KSOptionParser()
205 op.add_option("--fstype", dest="fstype")
206 op.add_option("--grow", dest="grow", action="store_true",
207 default=False)
208 op.add_option("--maxsize", dest="maxSizeMB", action="store", type="int",
209 nargs=1)
210 op.add_option("--name", dest="name", required=1)
211 op.add_option("--noformat", action="callback", callback=lv_cb,
212 dest="format", default=True, nargs=0)
213 op.add_option("--percent", dest="percent", action="store", type="int",
214 nargs=1)
215 op.add_option("--recommended", dest="recommended", action="store_true",
216 default=False)
217 op.add_option("--size", dest="size", action="store", type="int",
218 nargs=1)
219 op.add_option("--useexisting", dest="preexist", action="store_true",
220 default=False)
221 op.add_option("--vgname", dest="vgname", required=1)
222 return op
223
224 def parse(self, args):
225 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
226
227 if len(extra) == 0:
228 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol")
229
230 lvd = self.handler.LogVolData()
231 self._setToObj(self.op, opts, lvd)
232 lvd.lineno = self.lineno
233 lvd.mountpoint=extra[0]
234
235 # Check for duplicates in the data list.
236 if lvd in self.dataList():
237 warnings.warn(_("A logical volume with the name %s has already been defined in volume group %s.") % (lvd.device, lvd.vgname))
238
239 return lvd
240
241 def dataList(self):
242 return self.lvList
243
244class FC4_LogVol(FC3_LogVol):
245 removedKeywords = FC3_LogVol.removedKeywords
246 removedAttrs = FC3_LogVol.removedAttrs
247
248 def _getParser(self):
249 op = FC3_LogVol._getParser(self)
250 op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store",
251 type="int", nargs=1)
252 op.add_option("--fsoptions", dest="fsopts")
253 return op
254
255class RHEL5_LogVol(FC4_LogVol):
256 removedKeywords = FC4_LogVol.removedKeywords
257 removedAttrs = FC4_LogVol.removedAttrs
258
259 def _getParser(self):
260 op = FC4_LogVol._getParser(self)
261 op.add_option("--encrypted", action="store_true", default=False)
262 op.add_option("--passphrase")
263 return op
264
265class F9_LogVol(FC4_LogVol):
266 removedKeywords = FC4_LogVol.removedKeywords
267 removedAttrs = FC4_LogVol.removedAttrs
268
269 def _getParser(self):
270 op = FC4_LogVol._getParser(self)
271 op.add_option("--bytes-per-inode", deprecated=1)
272 op.add_option("--fsprofile", dest="fsprofile", action="store",
273 type="string", nargs=1)
274 op.add_option("--encrypted", action="store_true", default=False)
275 op.add_option("--passphrase")
276 return op
277
278class F12_LogVol(F9_LogVol):
279 removedKeywords = F9_LogVol.removedKeywords
280 removedAttrs = F9_LogVol.removedAttrs
281
282 def _getParser(self):
283 op = F9_LogVol._getParser(self)
284 op.add_option("--escrowcert")
285 op.add_option("--backuppassphrase", action="store_true", default=False)
286 return op
287
288class F14_LogVol(F12_LogVol):
289 removedKeywords = F12_LogVol.removedKeywords
290 removedAttrs = F12_LogVol.removedAttrs
291
292 def _getParser(self):
293 op = F12_LogVol._getParser(self)
294 op.remove_option("--bytes-per-inode")
295 return op
296
297class F15_LogVol(F14_LogVol):
298 removedKeywords = F14_LogVol.removedKeywords
299 removedAttrs = F14_LogVol.removedAttrs
300
301 def _getParser(self):
302 op = F14_LogVol._getParser(self)
303 op.add_option("--label")
304 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/mediacheck.py b/scripts/lib/mic/3rdparty/pykickstart/commands/mediacheck.py
new file mode 100644
index 0000000000..388823a839
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/mediacheck.py
@@ -0,0 +1,53 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC4_MediaCheck(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.mediacheck = kwargs.get("mediacheck", False)
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38 if self.mediacheck:
39 retval += "mediacheck\n"
40
41 return retval
42
43 def _getParser(self):
44 op = KSOptionParser()
45 return op
46
47 def parse(self, args):
48 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
49 if len(extra) > 0:
50 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "mediacheck")
51
52 self.mediacheck = True
53 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/method.py b/scripts/lib/mic/3rdparty/pykickstart/commands/method.py
new file mode 100644
index 0000000000..e21064acda
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/method.py
@@ -0,0 +1,186 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007, 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Method(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.method = kwargs.get("method", "")
34
35 # Set all these attributes so calls to this command's __call__
36 # method can set them. However we don't want to provide them as
37 # arguments to __init__ because method is special.
38 self.biospart = None
39 self.partition = None
40 self.server = None
41 self.dir = None
42 self.url = None
43
44 def __str__(self):
45 retval = KickstartCommand.__str__(self)
46
47 if self.method == "cdrom":
48 retval += "# Use CDROM installation media\ncdrom\n"
49 elif self.method == "harddrive":
50 msg = "# Use hard drive installation media\nharddrive --dir=%s" % self.dir
51
52 if self.biospart is not None:
53 retval += msg + " --biospart=%s\n" % self.biospart
54 else:
55 retval += msg + " --partition=%s\n" % self.partition
56 elif self.method == "nfs":
57 retval += "# Use NFS installation media\nnfs --server=%s --dir=%s\n" % (self.server, self.dir)
58 elif self.method == "url":
59 retval += "# Use network installation\nurl --url=\"%s\"\n" % self.url
60
61 return retval
62
63 def _getParser(self):
64 op = KSOptionParser()
65
66 # method = "cdrom" falls through to the return
67 if self.currentCmd == "harddrive":
68 op.add_option("--biospart", dest="biospart")
69 op.add_option("--partition", dest="partition")
70 op.add_option("--dir", dest="dir", required=1)
71 elif self.currentCmd == "nfs":
72 op.add_option("--server", dest="server", required=1)
73 op.add_option("--dir", dest="dir", required=1)
74 elif self.currentCmd == "url":
75 op.add_option("--url", dest="url", required=1)
76
77 return op
78
79 def parse(self, args):
80 self.method = self.currentCmd
81
82 op = self._getParser()
83 (opts, extra) = op.parse_args(args=args, lineno=self.lineno)
84 self._setToSelf(op, opts)
85
86 if self.currentCmd == "harddrive":
87 if self.biospart is None and self.partition is None or \
88 self.biospart is not None and self.partition is not None:
89 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of biospart or partition options must be specified."))
90
91 return self
92
93class FC6_Method(FC3_Method):
94 removedKeywords = FC3_Method.removedKeywords
95 removedAttrs = FC3_Method.removedAttrs
96
97 def __init__(self, writePriority=0, *args, **kwargs):
98 FC3_Method.__init__(self, writePriority, *args, **kwargs)
99
100 # Same reason for this attribute as the comment in FC3_Method.
101 self.opts = None
102
103 def __str__(self):
104 retval = KickstartCommand.__str__(self)
105
106 if self.method == "cdrom":
107 retval += "# Use CDROM installation media\ncdrom\n"
108 elif self.method == "harddrive":
109 msg = "# Use hard drive installation media\nharddrive --dir=%s" % self.dir
110
111 if self.biospart is not None:
112 retval += msg + " --biospart=%s\n" % self.biospart
113 else:
114 retval += msg + " --partition=%s\n" % self.partition
115 elif self.method == "nfs":
116 retval += "# Use NFS installation media\nnfs --server=%s --dir=%s" % (self.server, self.dir)
117 if self.opts is not None:
118 retval += " --opts=\"%s\"" % self.opts
119 retval += "\n"
120 elif self.method == "url":
121 retval += "# Use network installation\nurl --url=\"%s\"\n" % self.url
122
123 return retval
124
125 def _getParser(self):
126 op = FC3_Method._getParser(self)
127
128 if self.currentCmd == "nfs":
129 op.add_option("--opts", dest="opts")
130
131 return op
132
133class F13_Method(FC6_Method):
134 removedKeywords = FC6_Method.removedKeywords
135 removedAttrs = FC6_Method.removedAttrs
136
137 def __init__(self, *args, **kwargs):
138 FC6_Method.__init__(self, *args, **kwargs)
139
140 # And same as all the other __init__ methods.
141 self.proxy = ""
142
143 def __str__(self):
144 retval = FC6_Method.__str__(self)
145
146 if self.method == "url" and self.proxy:
147 retval = retval.strip()
148 retval += " --proxy=\"%s\"\n" % self.proxy
149
150 return retval
151
152 def _getParser(self):
153 op = FC6_Method._getParser(self)
154
155 if self.currentCmd == "url":
156 op.add_option("--proxy")
157
158 return op
159
160class F14_Method(F13_Method):
161 removedKeywords = F13_Method.removedKeywords
162 removedAttrs = F13_Method.removedAttrs
163
164 def __init__(self, *args, **kwargs):
165 F13_Method.__init__(self, *args, **kwargs)
166
167 self.noverifyssl = False
168
169 def __str__(self):
170 retval = F13_Method.__str__(self)
171
172 if self.method == "url" and self.noverifyssl:
173 retval = retval.strip()
174 retval += " --noverifyssl\n"
175
176 return retval
177
178 def _getParser(self):
179 op = F13_Method._getParser(self)
180
181 if self.currentCmd == "url":
182 op.add_option("--noverifyssl", action="store_true", default=False)
183
184 return op
185
186RHEL6_Method = F14_Method
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/monitor.py b/scripts/lib/mic/3rdparty/pykickstart/commands/monitor.py
new file mode 100644
index 0000000000..8c8c2c4fc9
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/monitor.py
@@ -0,0 +1,106 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Monitor(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.hsync = kwargs.get("hsync", "")
36 self.monitor = kwargs.get("monitor", "")
37 self.vsync = kwargs.get("vsync", "")
38
39 def __str__(self):
40 retval = KickstartCommand.__str__(self)
41 retval += "monitor"
42
43 if self.hsync != "":
44 retval += " --hsync=%s" % self.hsync
45 if self.monitor != "":
46 retval += " --monitor=\"%s\"" % self.monitor
47 if self.vsync != "":
48 retval += " --vsync=%s" % self.vsync
49
50 if retval != "monitor":
51 return retval + "\n"
52 else:
53 return ""
54
55 def _getParser(self):
56 op = KSOptionParser()
57 op.add_option("--hsync")
58 op.add_option("--monitor")
59 op.add_option("--vsync")
60 return op
61
62 def parse(self, args):
63 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
64
65 if extra:
66 mapping = {"cmd": "monitor", "options": extra}
67 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(cmd)s command: %(options)s") % mapping)
68
69 self._setToSelf(self.op, opts)
70 return self
71
72class FC6_Monitor(FC3_Monitor):
73 removedKeywords = FC3_Monitor.removedKeywords
74 removedAttrs = FC3_Monitor.removedAttrs
75
76 def __init__(self, writePriority=0, *args, **kwargs):
77 FC3_Monitor.__init__(self, writePriority, *args, **kwargs)
78 self.probe = kwargs.get("probe", True)
79
80 def __str__(self):
81 retval = KickstartCommand.__str__(self)
82 retval += "monitor"
83
84 if self.hsync != "":
85 retval += " --hsync=%s" % self.hsync
86 if self.monitor != "":
87 retval += " --monitor=\"%s\"" % self.monitor
88 if not self.probe:
89 retval += " --noprobe"
90 if self.vsync != "":
91 retval += " --vsync=%s" % self.vsync
92
93 if retval != "monitor":
94 return retval + "\n"
95 else:
96 return ""
97
98 def _getParser(self):
99 op = FC3_Monitor._getParser(self)
100 op.add_option("--noprobe", dest="probe", action="store_false",
101 default=True)
102 return op
103
104class F10_Monitor(DeprecatedCommand):
105 def __init__(self):
106 DeprecatedCommand.__init__(self)
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/mouse.py b/scripts/lib/mic/3rdparty/pykickstart/commands/mouse.py
new file mode 100644
index 0000000000..c643bcedc3
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/mouse.py
@@ -0,0 +1,70 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class RHEL3_Mouse(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.device = kwargs.get("device", "")
36 self.emulthree = kwargs.get("emulthree", False)
37 self.mouse = kwargs.get("mouse", "")
38
39 def __str__(self):
40 retval = KickstartCommand.__str__(self)
41
42 opts = ""
43 if self.device:
44 opts += "--device=%s " % self.device
45 if self.emulthree:
46 opts += "--emulthree "
47
48 if self.mouse:
49 retval += "# System mouse\nmouse %s%s\n" % (opts, self.mouse)
50 return retval
51
52 def _getParser(self):
53 op = KSOptionParser()
54 op.add_option("--device", dest="device", default="")
55 op.add_option("--emulthree", dest="emulthree", default=False, action="store_true")
56 return op
57
58 def parse(self, args):
59 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
60 self._setToSelf(self.op, opts)
61
62 if len(extra) != 1:
63 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "mouse")
64
65 self.mouse = extra[0]
66 return self
67
68class FC3_Mouse(DeprecatedCommand):
69 def __init__(self):
70 DeprecatedCommand.__init__(self)
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/multipath.py b/scripts/lib/mic/3rdparty/pykickstart/commands/multipath.py
new file mode 100644
index 0000000000..84ba755e68
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/multipath.py
@@ -0,0 +1,111 @@
1#
2# Chris Lumens <clumens@redhat.com>
3# Peter Jones <pjones@redhat.com>
4#
5# Copyright 2006, 2007 Red Hat, Inc.
6#
7# This copyrighted material is made available to anyone wishing to use, modify,
8# copy, or redistribute it subject to the terms and conditions of the GNU
9# General Public License v.2. This program is distributed in the hope that it
10# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12# See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along with
15# this program; if not, write to the Free Software Foundation, Inc., 51
16# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
17# trademarks that are incorporated in the source code or documentation are not
18# subject to the GNU General Public License and may only be used or replicated
19# with the express permission of Red Hat, Inc.
20#
21from pykickstart.base import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC6_MpPathData(BaseData):
29 removedKeywords = BaseData.removedKeywords
30 removedAttrs = BaseData.removedAttrs
31
32 def __init__(self, *args, **kwargs):
33 BaseData.__init__(self, *args, **kwargs)
34 self.mpdev = kwargs.get("mpdev", "")
35 self.device = kwargs.get("device", "")
36 self.rule = kwargs.get("rule", "")
37
38 def __str__(self):
39 return " --device=%s --rule=\"%s\"" % (self.device, self.rule)
40
41class FC6_MultiPathData(BaseData):
42 removedKeywords = BaseData.removedKeywords
43 removedAttrs = BaseData.removedAttrs
44
45 def __init__(self, *args, **kwargs):
46 BaseData.__init__(self, *args, **kwargs)
47 self.name = kwargs.get("name", "")
48 self.paths = kwargs.get("paths", [])
49
50 def __str__(self):
51 retval = BaseData.__str__(self)
52
53 for path in self.paths:
54 retval += "multipath --mpdev=%s %s\n" % (self.name, path.__str__())
55
56 return retval
57
58class FC6_MultiPath(KickstartCommand):
59 removedKeywords = KickstartCommand.removedKeywords
60 removedAttrs = KickstartCommand.removedAttrs
61
62 def __init__(self, writePriority=50, *args, **kwargs):
63 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
64 self.op = self._getParser()
65
66 self.mpaths = kwargs.get("mpaths", [])
67
68 def __str__(self):
69 retval = ""
70 for mpath in self.mpaths:
71 retval += mpath.__str__()
72
73 return retval
74
75 def _getParser(self):
76 op = KSOptionParser()
77 op.add_option("--name", dest="name", action="store", type="string",
78 required=1)
79 op.add_option("--device", dest="device", action="store", type="string",
80 required=1)
81 op.add_option("--rule", dest="rule", action="store", type="string",
82 required=1)
83 return op
84
85 def parse(self, args):
86 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
87 dd = FC6_MpPathData()
88 self._setToObj(self.op, opts, dd)
89 dd.lineno = self.lineno
90 dd.mpdev = dd.mpdev.split('/')[-1]
91
92 parent = None
93 for x in range(0, len(self.mpaths)):
94 mpath = self.mpaths[x]
95 for path in mpath.paths:
96 if path.device == dd.device:
97 mapping = {"device": path.device, "multipathdev": path.mpdev}
98 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Device '%(device)s' is already used in multipath '%(multipathdev)s'") % mapping)
99 if mpath.name == dd.mpdev:
100 parent = x
101
102 if parent is None:
103 mpath = FC6_MultiPathData()
104 return mpath
105 else:
106 mpath = self.mpaths[parent]
107
108 return dd
109
110 def dataList(self):
111 return self.mpaths
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/network.py b/scripts/lib/mic/3rdparty/pykickstart/commands/network.py
new file mode 100644
index 0000000000..9b67f92831
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/network.py
@@ -0,0 +1,363 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26import warnings
27_ = lambda x: gettext.ldgettext("pykickstart", x)
28
29class FC3_NetworkData(BaseData):
30 removedKeywords = BaseData.removedKeywords
31 removedAttrs = BaseData.removedAttrs
32
33 def __init__(self, *args, **kwargs):
34 BaseData.__init__(self, *args, **kwargs)
35 self.bootProto = kwargs.get("bootProto", BOOTPROTO_DHCP)
36 self.dhcpclass = kwargs.get("dhcpclass", "")
37 self.device = kwargs.get("device", "")
38 self.essid = kwargs.get("essid", "")
39 self.ethtool = kwargs.get("ethtool", "")
40 self.gateway = kwargs.get("gateway", "")
41 self.hostname = kwargs.get("hostname", "")
42 self.ip = kwargs.get("ip", "")
43 self.mtu = kwargs.get("mtu", "")
44 self.nameserver = kwargs.get("nameserver", "")
45 self.netmask = kwargs.get("netmask", "")
46 self.nodns = kwargs.get("nodns", False)
47 self.onboot = kwargs.get("onboot", True)
48 self.wepkey = kwargs.get("wepkey", "")
49
50 def __eq__(self, y):
51 return self.device and self.device == y.device
52
53 def _getArgsAsStr(self):
54 retval = ""
55
56 if self.bootProto != "":
57 retval += " --bootproto=%s" % self.bootProto
58 if self.dhcpclass != "":
59 retval += " --dhcpclass=%s" % self.dhcpclass
60 if self.device != "":
61 retval += " --device=%s" % self.device
62 if self.essid != "":
63 retval += " --essid=\"%s\"" % self.essid
64 if self.ethtool != "":
65 retval += " --ethtool=\"%s\"" % self.ethtool
66 if self.gateway != "":
67 retval += " --gateway=%s" % self.gateway
68 if self.hostname != "":
69 retval += " --hostname=%s" % self.hostname
70 if self.ip != "":
71 retval += " --ip=%s" % self.ip
72 if self.mtu != "":
73 retval += " --mtu=%s" % self.mtu
74 if self.nameserver != "":
75 retval += " --nameserver=%s" % self.nameserver
76 if self.netmask != "":
77 retval += " --netmask=%s" % self.netmask
78 if self.nodns:
79 retval += " --nodns"
80 if not self.onboot:
81 retval += " --onboot=off"
82 if self.wepkey != "":
83 retval += " --wepkey=%s" % self.wepkey
84
85 return retval
86
87 def __str__(self):
88 retval = BaseData.__str__(self)
89 retval += "network %s\n" % self._getArgsAsStr()
90 return retval
91
92class FC4_NetworkData(FC3_NetworkData):
93 removedKeywords = FC3_NetworkData.removedKeywords
94 removedAttrs = FC3_NetworkData.removedAttrs
95
96 def __init__(self, *args, **kwargs):
97 FC3_NetworkData.__init__(self, *args, **kwargs)
98 self.notksdevice = kwargs.get("notksdevice", False)
99
100 def _getArgsAsStr(self):
101 retval = FC3_NetworkData._getArgsAsStr(self)
102
103 if self.notksdevice:
104 retval += " --notksdevice"
105
106 return retval
107
108class FC6_NetworkData(FC4_NetworkData):
109 removedKeywords = FC4_NetworkData.removedKeywords
110 removedAttrs = FC4_NetworkData.removedAttrs
111
112 def __init__(self, *args, **kwargs):
113 FC4_NetworkData.__init__(self, *args, **kwargs)
114 self.noipv4 = kwargs.get("noipv4", False)
115 self.noipv6 = kwargs.get("noipv6", False)
116
117 def _getArgsAsStr(self):
118 retval = FC4_NetworkData._getArgsAsStr(self)
119
120 if self.noipv4:
121 retval += " --noipv4"
122 if self.noipv6:
123 retval += " --noipv6"
124
125 return retval
126
127class F8_NetworkData(FC6_NetworkData):
128 removedKeywords = FC6_NetworkData.removedKeywords
129 removedAttrs = FC6_NetworkData.removedAttrs
130
131 def __init__(self, *args, **kwargs):
132 FC6_NetworkData.__init__(self, *args, **kwargs)
133 self.ipv6 = kwargs.get("ipv6", "")
134
135 def _getArgsAsStr(self):
136 retval = FC6_NetworkData._getArgsAsStr(self)
137
138 if self.ipv6 != "":
139 retval += " --ipv6" % self.ipv6
140
141 return retval
142
143class F16_NetworkData(F8_NetworkData):
144 removedKeywords = F8_NetworkData.removedKeywords
145 removedAttrs = F8_NetworkData.removedAttrs
146
147 def __init__(self, *args, **kwargs):
148 F8_NetworkData.__init__(self, *args, **kwargs)
149 self.activate = kwargs.get("activate", False)
150 self.nodefroute = kwargs.get("nodefroute", False)
151 self.wpakey = kwargs.get("wpakey", "")
152
153 def _getArgsAsStr(self):
154 retval = F8_NetworkData._getArgsAsStr(self)
155
156 if self.activate:
157 retval += " --activate"
158 if self.nodefroute:
159 retval += " --nodefroute"
160 if self.wpakey != "":
161 retval += "--wpakey=%s" % self.wpakey
162
163 return retval
164
165class RHEL4_NetworkData(FC3_NetworkData):
166 removedKeywords = FC3_NetworkData.removedKeywords
167 removedAttrs = FC3_NetworkData.removedAttrs
168
169 def __init__(self, *args, **kwargs):
170 FC3_NetworkData.__init__(self, *args, **kwargs)
171 self.notksdevice = kwargs.get("notksdevice", False)
172
173 def _getArgsAsStr(self):
174 retval = FC3_NetworkData._getArgsAsStr(self)
175
176 if self.notksdevice:
177 retval += " --notksdevice"
178
179 return retval
180
181class RHEL6_NetworkData(F8_NetworkData):
182 removedKeywords = F8_NetworkData.removedKeywords
183 removedAttrs = F8_NetworkData.removedAttrs
184
185 def __init__(self, *args, **kwargs):
186 F8_NetworkData.__init__(self, *args, **kwargs)
187 self.activate = kwargs.get("activate", False)
188 self.nodefroute = kwargs.get("nodefroute", False)
189
190 def _getArgsAsStr(self):
191 retval = F8_NetworkData._getArgsAsStr(self)
192
193 if self.activate:
194 retval += " --activate"
195 if self.nodefroute:
196 retval += " --nodefroute"
197
198 return retval
199
200class FC3_Network(KickstartCommand):
201 removedKeywords = KickstartCommand.removedKeywords
202 removedAttrs = KickstartCommand.removedAttrs
203
204 def __init__(self, writePriority=0, *args, **kwargs):
205 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
206 self.bootprotoList = [BOOTPROTO_DHCP, BOOTPROTO_BOOTP,
207 BOOTPROTO_STATIC]
208
209 self.op = self._getParser()
210
211 self.network = kwargs.get("network", [])
212
213 def __str__(self):
214 retval = ""
215
216 for nic in self.network:
217 retval += nic.__str__()
218
219 if retval != "":
220 return "# Network information\n" + retval
221 else:
222 return ""
223
224 def _getParser(self):
225 op = KSOptionParser()
226 op.add_option("--bootproto", dest="bootProto",
227 default=BOOTPROTO_DHCP,
228 choices=self.bootprotoList)
229 op.add_option("--dhcpclass", dest="dhcpclass")
230 op.add_option("--device", dest="device")
231 op.add_option("--essid", dest="essid")
232 op.add_option("--ethtool", dest="ethtool")
233 op.add_option("--gateway", dest="gateway")
234 op.add_option("--hostname", dest="hostname")
235 op.add_option("--ip", dest="ip")
236 op.add_option("--mtu", dest="mtu")
237 op.add_option("--nameserver", dest="nameserver")
238 op.add_option("--netmask", dest="netmask")
239 op.add_option("--nodns", dest="nodns", action="store_true",
240 default=False)
241 op.add_option("--onboot", dest="onboot", action="store",
242 type="ksboolean")
243 op.add_option("--wepkey", dest="wepkey")
244 return op
245
246 def parse(self, args):
247 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
248 nd = self.handler.NetworkData()
249 self._setToObj(self.op, opts, nd)
250 nd.lineno = self.lineno
251
252 # Check for duplicates in the data list.
253 if nd in self.dataList():
254 warnings.warn(_("A network device with the name %s has already been defined.") % nd.device)
255
256 return nd
257
258 def dataList(self):
259 return self.network
260
261class FC4_Network(FC3_Network):
262 removedKeywords = FC3_Network.removedKeywords
263 removedAttrs = FC3_Network.removedAttrs
264
265 def _getParser(self):
266 op = FC3_Network._getParser(self)
267 op.add_option("--notksdevice", dest="notksdevice", action="store_true",
268 default=False)
269 return op
270
271class FC6_Network(FC4_Network):
272 removedKeywords = FC4_Network.removedKeywords
273 removedAttrs = FC4_Network.removedAttrs
274
275 def _getParser(self):
276 op = FC4_Network._getParser(self)
277 op.add_option("--noipv4", dest="noipv4", action="store_true",
278 default=False)
279 op.add_option("--noipv6", dest="noipv6", action="store_true",
280 default=False)
281 return op
282
283class F8_Network(FC6_Network):
284 removedKeywords = FC6_Network.removedKeywords
285 removedAttrs = FC6_Network.removedAttrs
286
287 def _getParser(self):
288 op = FC6_Network._getParser(self)
289 op.add_option("--ipv6", dest="ipv6")
290 return op
291
292class F9_Network(F8_Network):
293 removedKeywords = F8_Network.removedKeywords
294 removedAttrs = F8_Network.removedAttrs
295
296 def __init__(self, writePriority=0, *args, **kwargs):
297 F8_Network.__init__(self, writePriority, *args, **kwargs)
298 self.bootprotoList.append(BOOTPROTO_QUERY)
299
300 def _getParser(self):
301 op = F8_Network._getParser(self)
302 op.add_option("--bootproto", dest="bootProto",
303 default=BOOTPROTO_DHCP,
304 choices=self.bootprotoList)
305 return op
306
307class F16_Network(F9_Network):
308 removedKeywords = F9_Network.removedKeywords
309 removedAttrs = F9_Network.removedAttrs
310
311 def __init__(self, writePriority=0, *args, **kwargs):
312 F9_Network.__init__(self, writePriority, *args, **kwargs)
313 self.bootprotoList.append(BOOTPROTO_IBFT)
314
315 def _getParser(self):
316 op = F9_Network._getParser(self)
317 op.add_option("--activate", dest="activate", action="store_true",
318 default=False)
319 op.add_option("--nodefroute", dest="nodefroute", action="store_true",
320 default=False)
321 op.add_option("--wpakey", dest="wpakey", action="store", default="")
322 return op
323
324class RHEL4_Network(FC3_Network):
325 removedKeywords = FC3_Network.removedKeywords
326 removedAttrs = FC3_Network.removedAttrs
327
328 def _getParser(self):
329 op = FC3_Network._getParser(self)
330 op.add_option("--notksdevice", dest="notksdevice", action="store_true",
331 default=False)
332 return op
333
334class RHEL5_Network(FC6_Network):
335 removedKeywords = FC6_Network.removedKeywords
336 removedAttrs = FC6_Network.removedAttrs
337
338 def __init__(self, writePriority=0, *args, **kwargs):
339 FC6_Network.__init__(self, writePriority, *args, **kwargs)
340 self.bootprotoList.append(BOOTPROTO_QUERY)
341
342 def _getParser(self):
343 op = FC6_Network._getParser(self)
344 op.add_option("--bootproto", dest="bootProto",
345 default=BOOTPROTO_DHCP,
346 choices=self.bootprotoList)
347 return op
348
349class RHEL6_Network(F9_Network):
350 removedKeywords = F9_Network.removedKeywords
351 removedAttrs = F9_Network.removedAttrs
352
353 def __init__(self, writePriority=0, *args, **kwargs):
354 F9_Network.__init__(self, writePriority, *args, **kwargs)
355 self.bootprotoList.append(BOOTPROTO_IBFT)
356
357 def _getParser(self):
358 op = F9_Network._getParser(self)
359 op.add_option("--activate", dest="activate", action="store_true",
360 default=False)
361 op.add_option("--nodefroute", dest="nodefroute", action="store_true",
362 default=False)
363 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/partition.py b/scripts/lib/mic/3rdparty/pykickstart/commands/partition.py
new file mode 100644
index 0000000000..e65e012d02
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/partition.py
@@ -0,0 +1,353 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25import warnings
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC3_PartData(BaseData):
29 removedKeywords = BaseData.removedKeywords
30 removedAttrs = BaseData.removedAttrs
31
32 def __init__(self, *args, **kwargs):
33 BaseData.__init__(self, *args, **kwargs)
34 self.active = kwargs.get("active", False)
35 self.primOnly = kwargs.get("primOnly", False)
36 self.end = kwargs.get("end", 0)
37 self.fstype = kwargs.get("fstype", "")
38 self.grow = kwargs.get("grow", False)
39 self.maxSizeMB = kwargs.get("maxSizeMB", 0)
40 self.format = kwargs.get("format", True)
41 self.onbiosdisk = kwargs.get("onbiosdisk", "")
42 self.disk = kwargs.get("disk", "")
43 self.onPart = kwargs.get("onPart", "")
44 self.recommended = kwargs.get("recommended", False)
45 self.size = kwargs.get("size", None)
46 self.start = kwargs.get("start", 0)
47 self.mountpoint = kwargs.get("mountpoint", "")
48
49 def __eq__(self, y):
50 if self.mountpoint:
51 return self.mountpoint == y.mountpoint
52 else:
53 return False
54
55 def _getArgsAsStr(self):
56 retval = ""
57
58 if self.active:
59 retval += " --active"
60 if self.primOnly:
61 retval += " --asprimary"
62 if hasattr(self, "end") and self.end != 0:
63 retval += " --end=%s" % self.end
64 if self.fstype != "":
65 retval += " --fstype=\"%s\"" % self.fstype
66 if self.grow:
67 retval += " --grow"
68 if self.maxSizeMB > 0:
69 retval += " --maxsize=%d" % self.maxSizeMB
70 if not self.format:
71 retval += " --noformat"
72 if self.onbiosdisk != "":
73 retval += " --onbiosdisk=%s" % self.onbiosdisk
74 if self.disk != "":
75 retval += " --ondisk=%s" % self.disk
76 if self.onPart != "":
77 retval += " --onpart=%s" % self.onPart
78 if self.recommended:
79 retval += " --recommended"
80 if self.size and self.size != 0:
81 retval += " --size=%s" % self.size
82 if hasattr(self, "start") and self.start != 0:
83 retval += " --start=%s" % self.start
84
85 return retval
86
87 def __str__(self):
88 retval = BaseData.__str__(self)
89 if self.mountpoint:
90 mountpoint_str = "%s" % self.mountpoint
91 else:
92 mountpoint_str = "(No mount point)"
93 retval += "part %s%s\n" % (mountpoint_str, self._getArgsAsStr())
94 return retval
95
96class FC4_PartData(FC3_PartData):
97 removedKeywords = FC3_PartData.removedKeywords
98 removedAttrs = FC3_PartData.removedAttrs
99
100 def __init__(self, *args, **kwargs):
101 FC3_PartData.__init__(self, *args, **kwargs)
102 self.bytesPerInode = kwargs.get("bytesPerInode", 4096)
103 self.fsopts = kwargs.get("fsopts", "")
104 self.label = kwargs.get("label", "")
105
106 def _getArgsAsStr(self):
107 retval = FC3_PartData._getArgsAsStr(self)
108
109 if hasattr(self, "bytesPerInode") and self.bytesPerInode != 0:
110 retval += " --bytes-per-inode=%d" % self.bytesPerInode
111 if self.fsopts != "":
112 retval += " --fsoptions=\"%s\"" % self.fsopts
113 if self.label != "":
114 retval += " --label=%s" % self.label
115
116 return retval
117
118class RHEL5_PartData(FC4_PartData):
119 removedKeywords = FC4_PartData.removedKeywords
120 removedAttrs = FC4_PartData.removedAttrs
121
122 def __init__(self, *args, **kwargs):
123 FC4_PartData.__init__(self, *args, **kwargs)
124 self.encrypted = kwargs.get("encrypted", False)
125 self.passphrase = kwargs.get("passphrase", "")
126
127 def _getArgsAsStr(self):
128 retval = FC4_PartData._getArgsAsStr(self)
129
130 if self.encrypted:
131 retval += " --encrypted"
132
133 if self.passphrase != "":
134 retval += " --passphrase=\"%s\"" % self.passphrase
135
136 return retval
137
138class F9_PartData(FC4_PartData):
139 removedKeywords = FC4_PartData.removedKeywords + ["bytesPerInode"]
140 removedAttrs = FC4_PartData.removedAttrs + ["bytesPerInode"]
141
142 def __init__(self, *args, **kwargs):
143 FC4_PartData.__init__(self, *args, **kwargs)
144 self.deleteRemovedAttrs()
145
146 self.fsopts = kwargs.get("fsopts", "")
147 self.label = kwargs.get("label", "")
148 self.fsprofile = kwargs.get("fsprofile", "")
149 self.encrypted = kwargs.get("encrypted", False)
150 self.passphrase = kwargs.get("passphrase", "")
151
152 def _getArgsAsStr(self):
153 retval = FC4_PartData._getArgsAsStr(self)
154
155 if self.fsprofile != "":
156 retval += " --fsprofile=\"%s\"" % self.fsprofile
157 if self.encrypted:
158 retval += " --encrypted"
159
160 if self.passphrase != "":
161 retval += " --passphrase=\"%s\"" % self.passphrase
162
163 return retval
164
165class F11_PartData(F9_PartData):
166 removedKeywords = F9_PartData.removedKeywords + ["start", "end"]
167 removedAttrs = F9_PartData.removedAttrs + ["start", "end"]
168
169class F12_PartData(F11_PartData):
170 removedKeywords = F11_PartData.removedKeywords
171 removedAttrs = F11_PartData.removedAttrs
172
173 def __init__(self, *args, **kwargs):
174 F11_PartData.__init__(self, *args, **kwargs)
175
176 self.escrowcert = kwargs.get("escrowcert", "")
177 self.backuppassphrase = kwargs.get("backuppassphrase", False)
178
179 def _getArgsAsStr(self):
180 retval = F11_PartData._getArgsAsStr(self)
181
182 if self.encrypted and self.escrowcert != "":
183 retval += " --escrowcert=\"%s\"" % self.escrowcert
184
185 if self.backuppassphrase:
186 retval += " --backuppassphrase"
187
188 return retval
189
190F14_PartData = F12_PartData
191
192class FC3_Partition(KickstartCommand):
193 removedKeywords = KickstartCommand.removedKeywords
194 removedAttrs = KickstartCommand.removedAttrs
195
196 def __init__(self, writePriority=130, *args, **kwargs):
197 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
198 self.op = self._getParser()
199
200 self.partitions = kwargs.get("partitions", [])
201
202 def __str__(self):
203 retval = ""
204
205 for part in self.partitions:
206 retval += part.__str__()
207
208 if retval != "":
209 return "# Disk partitioning information\n" + retval
210 else:
211 return ""
212
213 def _getParser(self):
214 def part_cb (option, opt_str, value, parser):
215 if value.startswith("/dev/"):
216 parser.values.ensure_value(option.dest, value[5:])
217 else:
218 parser.values.ensure_value(option.dest, value)
219
220 op = KSOptionParser()
221 op.add_option("--active", dest="active", action="store_true",
222 default=False)
223 op.add_option("--asprimary", dest="primOnly", action="store_true",
224 default=False)
225 op.add_option("--end", dest="end", action="store", type="int",
226 nargs=1)
227 op.add_option("--fstype", "--type", dest="fstype")
228 op.add_option("--grow", dest="grow", action="store_true", default=False)
229 op.add_option("--maxsize", dest="maxSizeMB", action="store", type="int",
230 nargs=1)
231 op.add_option("--noformat", dest="format", action="store_false",
232 default=True)
233 op.add_option("--onbiosdisk", dest="onbiosdisk")
234 op.add_option("--ondisk", "--ondrive", dest="disk")
235 op.add_option("--onpart", "--usepart", dest="onPart", action="callback",
236 callback=part_cb, nargs=1, type="string")
237 op.add_option("--recommended", dest="recommended", action="store_true",
238 default=False)
239 op.add_option("--size", dest="size", action="store", type="int",
240 nargs=1)
241 op.add_option("--start", dest="start", action="store", type="int",
242 nargs=1)
243 return op
244
245 def parse(self, args):
246 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
247
248 pd = self.handler.PartData()
249 self._setToObj(self.op, opts, pd)
250 pd.lineno = self.lineno
251 if extra:
252 pd.mountpoint = extra[0]
253 if pd in self.dataList():
254 warnings.warn(_("A partition with the mountpoint %s has already been defined.") % pd.mountpoint)
255 else:
256 pd.mountpoint = None
257
258 return pd
259
260 def dataList(self):
261 return self.partitions
262
263class FC4_Partition(FC3_Partition):
264 removedKeywords = FC3_Partition.removedKeywords
265 removedAttrs = FC3_Partition.removedAttrs
266
267 def __init__(self, writePriority=130, *args, **kwargs):
268 FC3_Partition.__init__(self, writePriority, *args, **kwargs)
269
270 def part_cb (option, opt_str, value, parser):
271 if value.startswith("/dev/"):
272 parser.values.ensure_value(option.dest, value[5:])
273 else:
274 parser.values.ensure_value(option.dest, value)
275
276 def _getParser(self):
277 op = FC3_Partition._getParser(self)
278 op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store",
279 type="int", nargs=1)
280 op.add_option("--fsoptions", dest="fsopts")
281 op.add_option("--label", dest="label")
282 return op
283
284class RHEL5_Partition(FC4_Partition):
285 removedKeywords = FC4_Partition.removedKeywords
286 removedAttrs = FC4_Partition.removedAttrs
287
288 def __init__(self, writePriority=130, *args, **kwargs):
289 FC4_Partition.__init__(self, writePriority, *args, **kwargs)
290
291 def part_cb (option, opt_str, value, parser):
292 if value.startswith("/dev/"):
293 parser.values.ensure_value(option.dest, value[5:])
294 else:
295 parser.values.ensure_value(option.dest, value)
296
297 def _getParser(self):
298 op = FC4_Partition._getParser(self)
299 op.add_option("--encrypted", action="store_true", default=False)
300 op.add_option("--passphrase")
301 return op
302
303class F9_Partition(FC4_Partition):
304 removedKeywords = FC4_Partition.removedKeywords
305 removedAttrs = FC4_Partition.removedAttrs
306
307 def __init__(self, writePriority=130, *args, **kwargs):
308 FC4_Partition.__init__(self, writePriority, *args, **kwargs)
309
310 def part_cb (option, opt_str, value, parser):
311 if value.startswith("/dev/"):
312 parser.values.ensure_value(option.dest, value[5:])
313 else:
314 parser.values.ensure_value(option.dest, value)
315
316 def _getParser(self):
317 op = FC4_Partition._getParser(self)
318 op.add_option("--bytes-per-inode", deprecated=1)
319 op.add_option("--fsprofile")
320 op.add_option("--encrypted", action="store_true", default=False)
321 op.add_option("--passphrase")
322 return op
323
324class F11_Partition(F9_Partition):
325 removedKeywords = F9_Partition.removedKeywords
326 removedAttrs = F9_Partition.removedAttrs
327
328 def _getParser(self):
329 op = F9_Partition._getParser(self)
330 op.add_option("--start", deprecated=1)
331 op.add_option("--end", deprecated=1)
332 return op
333
334class F12_Partition(F11_Partition):
335 removedKeywords = F11_Partition.removedKeywords
336 removedAttrs = F11_Partition.removedAttrs
337
338 def _getParser(self):
339 op = F11_Partition._getParser(self)
340 op.add_option("--escrowcert")
341 op.add_option("--backuppassphrase", action="store_true", default=False)
342 return op
343
344class F14_Partition(F12_Partition):
345 removedKeywords = F12_Partition.removedKeywords
346 removedAttrs = F12_Partition.removedAttrs
347
348 def _getParser(self):
349 op = F12_Partition._getParser(self)
350 op.remove_option("--bytes-per-inode")
351 op.remove_option("--start")
352 op.remove_option("--end")
353 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/raid.py b/scripts/lib/mic/3rdparty/pykickstart/commands/raid.py
new file mode 100644
index 0000000000..0f4c92a107
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/raid.py
@@ -0,0 +1,365 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008, 2011 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25import warnings
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC3_RaidData(BaseData):
29 removedKeywords = BaseData.removedKeywords
30 removedAttrs = BaseData.removedAttrs
31
32 def __init__(self, *args, **kwargs):
33 BaseData.__init__(self, *args, **kwargs)
34 self.device = kwargs.get("device", None)
35 self.fstype = kwargs.get("fstype", "")
36 self.level = kwargs.get("level", "")
37 self.format = kwargs.get("format", True)
38 self.spares = kwargs.get("spares", 0)
39 self.preexist = kwargs.get("preexist", False)
40 self.mountpoint = kwargs.get("mountpoint", "")
41 self.members = kwargs.get("members", [])
42
43 def __eq__(self, y):
44 return self.device == y.device
45
46 def _getArgsAsStr(self):
47 retval = ""
48
49 if self.device != "":
50 retval += " --device=%s" % self.device
51 if self.fstype != "":
52 retval += " --fstype=\"%s\"" % self.fstype
53 if self.level != "":
54 retval += " --level=%s" % self.level
55 if not self.format:
56 retval += " --noformat"
57 if self.spares != 0:
58 retval += " --spares=%d" % self.spares
59 if self.preexist:
60 retval += " --useexisting"
61
62 return retval
63
64 def __str__(self):
65 retval = BaseData.__str__(self)
66 retval += "raid %s%s %s\n" % (self.mountpoint, self._getArgsAsStr(),
67 " ".join(self.members))
68 return retval
69
70class FC4_RaidData(FC3_RaidData):
71 removedKeywords = FC3_RaidData.removedKeywords
72 removedAttrs = FC3_RaidData.removedAttrs
73
74 def __init__(self, *args, **kwargs):
75 FC3_RaidData.__init__(self, *args, **kwargs)
76 self.fsopts = kwargs.get("fsopts", "")
77
78 def _getArgsAsStr(self):
79 retval = FC3_RaidData._getArgsAsStr(self)
80
81 if self.fsopts != "":
82 retval += " --fsoptions=\"%s\"" % self.fsopts
83
84 return retval
85
86class FC5_RaidData(FC4_RaidData):
87 removedKeywords = FC4_RaidData.removedKeywords
88 removedAttrs = FC4_RaidData.removedAttrs
89
90 def __init__(self, *args, **kwargs):
91 FC4_RaidData.__init__(self, *args, **kwargs)
92 self.bytesPerInode = kwargs.get("bytesPerInode", 4096)
93
94 def _getArgsAsStr(self):
95 retval = FC4_RaidData._getArgsAsStr(self)
96
97 if hasattr(self, "bytesPerInode") and self.bytesPerInode != 0:
98 retval += " --bytes-per-inode=%d" % self.bytesPerInode
99
100 return retval
101
102class RHEL5_RaidData(FC5_RaidData):
103 removedKeywords = FC5_RaidData.removedKeywords
104 removedAttrs = FC5_RaidData.removedAttrs
105
106 def __init__(self, *args, **kwargs):
107 FC5_RaidData.__init__(self, *args, **kwargs)
108 self.encrypted = kwargs.get("encrypted", False)
109 self.passphrase = kwargs.get("passphrase", "")
110
111 def _getArgsAsStr(self):
112 retval = FC5_RaidData._getArgsAsStr(self)
113
114 if self.encrypted:
115 retval += " --encrypted"
116
117 if self.passphrase != "":
118 retval += " --passphrase=\"%s\"" % self.passphrase
119
120 return retval
121
122F7_RaidData = FC5_RaidData
123
124class F9_RaidData(FC5_RaidData):
125 removedKeywords = FC5_RaidData.removedKeywords + ["bytesPerInode"]
126 removedAttrs = FC5_RaidData.removedAttrs + ["bytesPerInode"]
127
128 def __init__(self, *args, **kwargs):
129 FC5_RaidData.__init__(self, *args, **kwargs)
130 self.deleteRemovedAttrs()
131
132 self.fsprofile = kwargs.get("fsprofile", "")
133 self.encrypted = kwargs.get("encrypted", False)
134 self.passphrase = kwargs.get("passphrase", "")
135
136 def _getArgsAsStr(self):
137 retval = FC5_RaidData._getArgsAsStr(self)
138
139 if self.fsprofile != "":
140 retval += " --fsprofile=\"%s\"" % self.fsprofile
141 if self.encrypted:
142 retval += " --encrypted"
143
144 if self.passphrase != "":
145 retval += " --passphrase=\"%s\"" % self.passphrase
146
147 return retval
148
149class F12_RaidData(F9_RaidData):
150 removedKeywords = F9_RaidData.removedKeywords
151 removedAttrs = F9_RaidData.removedAttrs
152
153 def __init__(self, *args, **kwargs):
154 F9_RaidData.__init__(self, *args, **kwargs)
155 self.deleteRemovedAttrs()
156
157 self.escrowcert = kwargs.get("escrowcert", "")
158 self.backuppassphrase = kwargs.get("backuppassphrase", False)
159
160 def _getArgsAsStr(self):
161 retval = F9_RaidData._getArgsAsStr(self)
162
163 if self.encrypted and self.escrowcert != "":
164 retval += " --escrowcert=\"%s\"" % self.escrowcert
165
166 if self.backuppassphrase:
167 retval += " --backuppassphrase"
168 return retval
169
170F13_RaidData = F12_RaidData
171
172F14_RaidData = F13_RaidData
173
174class F15_RaidData(F14_RaidData):
175 removedKeywords = F14_RaidData.removedKeywords
176 removedAttrs = F14_RaidData.removedAttrs
177
178 def __init__(self, *args, **kwargs):
179 F14_RaidData.__init__(self, *args, **kwargs)
180 self.deleteRemovedAttrs()
181
182 self.label = kwargs.get("label", "")
183
184 def _getArgsAsStr(self):
185 retval = F14_RaidData._getArgsAsStr(self)
186
187 if self.label != "":
188 retval += " --label=%s" % self.label
189
190 return retval
191
192class FC3_Raid(KickstartCommand):
193 removedKeywords = KickstartCommand.removedKeywords
194 removedAttrs = KickstartCommand.removedAttrs
195
196 def __init__(self, writePriority=131, *args, **kwargs):
197 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
198 self.op = self._getParser()
199
200 # A dict of all the RAID levels we support. This means that if we
201 # support more levels in the future, subclasses don't have to
202 # duplicate too much.
203 self.levelMap = { "RAID0": "RAID0", "0": "RAID0",
204 "RAID1": "RAID1", "1": "RAID1",
205 "RAID5": "RAID5", "5": "RAID5",
206 "RAID6": "RAID6", "6": "RAID6" }
207
208 self.raidList = kwargs.get("raidList", [])
209
210 def __str__(self):
211 retval = ""
212
213 for raid in self.raidList:
214 retval += raid.__str__()
215
216 return retval
217
218 def _getParser(self):
219 def raid_cb (option, opt_str, value, parser):
220 parser.values.format = False
221 parser.values.preexist = True
222
223 def device_cb (option, opt_str, value, parser):
224 if value[0:2] == "md":
225 parser.values.ensure_value(option.dest, value[2:])
226 else:
227 parser.values.ensure_value(option.dest, value)
228
229 def level_cb (option, opt_str, value, parser):
230 if self.levelMap.has_key(value):
231 parser.values.ensure_value(option.dest, self.levelMap[value])
232
233 op = KSOptionParser()
234 op.add_option("--device", action="callback", callback=device_cb,
235 dest="device", type="string", nargs=1, required=1)
236 op.add_option("--fstype", dest="fstype")
237 op.add_option("--level", dest="level", action="callback",
238 callback=level_cb, type="string", nargs=1)
239 op.add_option("--noformat", action="callback", callback=raid_cb,
240 dest="format", default=True, nargs=0)
241 op.add_option("--spares", dest="spares", action="store", type="int",
242 nargs=1, default=0)
243 op.add_option("--useexisting", dest="preexist", action="store_true",
244 default=False)
245 return op
246
247 def parse(self, args):
248 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
249
250 if len(extra) == 0:
251 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "raid")
252 if len(extra) == 1:
253 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid")
254
255 rd = self.handler.RaidData()
256 self._setToObj(self.op, opts, rd)
257 rd.lineno = self.lineno
258
259 # --device can't just take an int in the callback above, because it
260 # could be specificed as "mdX", which causes optparse to error when
261 # it runs int().
262 rd.device = int(rd.device)
263 rd.mountpoint = extra[0]
264 rd.members = extra[1:]
265
266 # Check for duplicates in the data list.
267 if rd in self.dataList():
268 warnings.warn(_("A RAID device with the name %s has already been defined.") % rd.device)
269
270 return rd
271
272 def dataList(self):
273 return self.raidList
274
275class FC4_Raid(FC3_Raid):
276 removedKeywords = FC3_Raid.removedKeywords
277 removedAttrs = FC3_Raid.removedAttrs
278
279 def _getParser(self):
280 op = FC3_Raid._getParser(self)
281 op.add_option("--fsoptions", dest="fsopts")
282 return op
283
284class FC5_Raid(FC4_Raid):
285 removedKeywords = FC4_Raid.removedKeywords
286 removedAttrs = FC4_Raid.removedAttrs
287
288 def _getParser(self):
289 op = FC4_Raid._getParser(self)
290 op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store",
291 type="int", nargs=1)
292 return op
293
294class RHEL5_Raid(FC5_Raid):
295 removedKeywords = FC5_Raid.removedKeywords
296 removedAttrs = FC5_Raid.removedAttrs
297
298 def __init__(self, writePriority=131, *args, **kwargs):
299 FC5_Raid.__init__(self, writePriority, *args, **kwargs)
300
301 self.levelMap.update({"RAID10": "RAID10", "10": "RAID10"})
302
303 def _getParser(self):
304 op = FC5_Raid._getParser(self)
305 op.add_option("--encrypted", action="store_true", default=False)
306 op.add_option("--passphrase")
307 return op
308
309class F7_Raid(FC5_Raid):
310 removedKeywords = FC5_Raid.removedKeywords
311 removedAttrs = FC5_Raid.removedAttrs
312
313 def __init__(self, writePriority=131, *args, **kwargs):
314 FC5_Raid.__init__(self, writePriority, *args, **kwargs)
315
316 self.levelMap.update({"RAID10": "RAID10", "10": "RAID10"})
317
318class F9_Raid(F7_Raid):
319 removedKeywords = F7_Raid.removedKeywords
320 removedAttrs = F7_Raid.removedAttrs
321
322 def _getParser(self):
323 op = F7_Raid._getParser(self)
324 op.add_option("--bytes-per-inode", deprecated=1)
325 op.add_option("--fsprofile")
326 op.add_option("--encrypted", action="store_true", default=False)
327 op.add_option("--passphrase")
328 return op
329
330class F12_Raid(F9_Raid):
331 removedKeywords = F9_Raid.removedKeywords
332 removedAttrs = F9_Raid.removedAttrs
333
334 def _getParser(self):
335 op = F9_Raid._getParser(self)
336 op.add_option("--escrowcert")
337 op.add_option("--backuppassphrase", action="store_true", default=False)
338 return op
339
340class F13_Raid(F12_Raid):
341 removedKeywords = F12_Raid.removedKeywords
342 removedAttrs = F12_Raid.removedAttrs
343
344 def __init__(self, writePriority=131, *args, **kwargs):
345 F12_Raid.__init__(self, writePriority, *args, **kwargs)
346
347 self.levelMap.update({"RAID4": "RAID4", "4": "RAID4"})
348
349class F14_Raid(F13_Raid):
350 removedKeywords = F13_Raid.removedKeywords
351 removedAttrs = F13_Raid.removedAttrs
352
353 def _getParser(self):
354 op = F13_Raid._getParser(self)
355 op.remove_option("--bytes-per-inode")
356 return op
357
358class F15_Raid(F14_Raid):
359 removedKeywords = F14_Raid.removedKeywords
360 removedAttrs = F14_Raid.removedAttrs
361
362 def _getParser(self):
363 op = F14_Raid._getParser(self)
364 op.add_option("--label")
365 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/reboot.py b/scripts/lib/mic/3rdparty/pykickstart/commands/reboot.py
new file mode 100644
index 0000000000..391af14c22
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/reboot.py
@@ -0,0 +1,79 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25class FC3_Reboot(KickstartCommand):
26 removedKeywords = KickstartCommand.removedKeywords
27 removedAttrs = KickstartCommand.removedAttrs
28
29 def __init__(self, writePriority=0, *args, **kwargs):
30 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
31 self.action = kwargs.get("action", None)
32
33 def __str__(self):
34 retval = KickstartCommand.__str__(self)
35
36 if self.action == KS_REBOOT:
37 retval += "# Reboot after installation\nreboot\n"
38 elif self.action == KS_SHUTDOWN:
39 retval += "# Shutdown after installation\nshutdown\n"
40
41 return retval
42
43 def parse(self, args):
44 if self.currentCmd == "reboot":
45 self.action = KS_REBOOT
46 else:
47 self.action = KS_SHUTDOWN
48
49 return self
50
51class FC6_Reboot(FC3_Reboot):
52 removedKeywords = FC3_Reboot.removedKeywords
53 removedAttrs = FC3_Reboot.removedAttrs
54
55 def __init__(self, writePriority=0, *args, **kwargs):
56 FC3_Reboot.__init__(self, writePriority, *args, **kwargs)
57 self.op = self._getParser()
58
59 self.eject = kwargs.get("eject", False)
60
61 def __str__(self):
62 retval = FC3_Reboot.__str__(self).rstrip()
63
64 if self.eject:
65 retval += " --eject"
66
67 return retval + "\n"
68
69 def _getParser(self):
70 op = KSOptionParser()
71 op.add_option("--eject", dest="eject", action="store_true",
72 default=False)
73 return op
74
75 def parse(self, args):
76 FC3_Reboot.parse(self, args)
77 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
78 self._setToSelf(self.op, opts)
79 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/repo.py b/scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
new file mode 100644
index 0000000000..543ef947c1
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
@@ -0,0 +1,249 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007, 2008, 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26import warnings
27_ = lambda x: gettext.ldgettext("pykickstart", x)
28
29class FC6_RepoData(BaseData):
30 removedKeywords = BaseData.removedKeywords
31 removedAttrs = BaseData.removedAttrs
32
33 def __init__(self, *args, **kwargs):
34 BaseData.__init__(self, *args, **kwargs)
35 self.baseurl = kwargs.get("baseurl", "")
36 self.mirrorlist = kwargs.get("mirrorlist", None)
37 self.name = kwargs.get("name", "")
38
39 def __eq__(self, y):
40 return self.name == y.name
41
42 def _getArgsAsStr(self):
43 retval = ""
44
45 if self.baseurl:
46 retval += "--baseurl=%s" % self.baseurl
47 elif self.mirrorlist:
48 retval += "--mirrorlist=%s" % self.mirrorlist
49
50 return retval
51
52 def __str__(self):
53 retval = BaseData.__str__(self)
54 retval += "repo --name=\"%s\" %s\n" % (self.name, self._getArgsAsStr())
55 return retval
56
57class F8_RepoData(FC6_RepoData):
58 removedKeywords = FC6_RepoData.removedKeywords
59 removedAttrs = FC6_RepoData.removedAttrs
60
61 def __init__(self, *args, **kwargs):
62 FC6_RepoData.__init__(self, *args, **kwargs)
63 self.cost = kwargs.get("cost", None)
64 self.includepkgs = kwargs.get("includepkgs", [])
65 self.excludepkgs = kwargs.get("excludepkgs", [])
66
67 def _getArgsAsStr(self):
68 retval = FC6_RepoData._getArgsAsStr(self)
69
70 if self.cost:
71 retval += " --cost=%s" % self.cost
72 if self.includepkgs:
73 retval += " --includepkgs=\"%s\"" % ",".join(self.includepkgs)
74 if self.excludepkgs:
75 retval += " --excludepkgs=\"%s\"" % ",".join(self.excludepkgs)
76
77 return retval
78
79class F11_RepoData(F8_RepoData):
80 removedKeywords = F8_RepoData.removedKeywords
81 removedAttrs = F8_RepoData.removedAttrs
82
83 def __init__(self, *args, **kwargs):
84 F8_RepoData.__init__(self, *args, **kwargs)
85 self.ignoregroups = kwargs.get("ignoregroups", None)
86
87 def _getArgsAsStr(self):
88 retval = F8_RepoData._getArgsAsStr(self)
89
90 if self.ignoregroups:
91 retval += " --ignoregroups=true"
92 return retval
93
94class F13_RepoData(F11_RepoData):
95 removedKeywords = F11_RepoData.removedKeywords
96 removedAttrs = F11_RepoData.removedAttrs
97
98 def __init__(self, *args, **kwargs):
99 F11_RepoData.__init__(self, *args, **kwargs)
100 self.proxy = kwargs.get("proxy", "")
101
102 def _getArgsAsStr(self):
103 retval = F11_RepoData._getArgsAsStr(self)
104
105 if self.proxy:
106 retval += " --proxy=\"%s\"" % self.proxy
107
108 return retval
109
110class F14_RepoData(F13_RepoData):
111 removedKeywords = F13_RepoData.removedKeywords
112 removedAttrs = F13_RepoData.removedAttrs
113
114 def __init__(self, *args, **kwargs):
115 F13_RepoData.__init__(self, *args, **kwargs)
116 self.noverifyssl = kwargs.get("noverifyssl", False)
117
118 def _getArgsAsStr(self):
119 retval = F13_RepoData._getArgsAsStr(self)
120
121 if self.noverifyssl:
122 retval += " --noverifyssl"
123
124 return retval
125
126RHEL6_RepoData = F14_RepoData
127
128F15_RepoData = F14_RepoData
129
130class FC6_Repo(KickstartCommand):
131 removedKeywords = KickstartCommand.removedKeywords
132 removedAttrs = KickstartCommand.removedAttrs
133
134 urlRequired = True
135
136 def __init__(self, writePriority=0, *args, **kwargs):
137 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
138 self.op = self._getParser()
139
140 self.repoList = kwargs.get("repoList", [])
141
142 def __str__(self):
143 retval = ""
144 for repo in self.repoList:
145 retval += repo.__str__()
146
147 return retval
148
149 def _getParser(self):
150 op = KSOptionParser()
151 op.add_option("--name", dest="name", required=1)
152 op.add_option("--baseurl")
153 op.add_option("--mirrorlist")
154 return op
155
156 def parse(self, args):
157 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
158
159 if len(extra) != 0:
160 mapping = {"command": "repo", "options": extra}
161 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
162
163 # This is lame, but I can't think of a better way to make sure only
164 # one of these two is specified.
165 if opts.baseurl and opts.mirrorlist:
166 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command."))
167
168 if self.urlRequired and not opts.baseurl and not opts.mirrorlist:
169 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command."))
170
171 rd = self.handler.RepoData()
172 self._setToObj(self.op, opts, rd)
173 rd.lineno = self.lineno
174
175 # Check for duplicates in the data list.
176 if rd in self.dataList():
177 warnings.warn(_("A repo with the name %s has already been defined.") % rd.name)
178
179 return rd
180
181 def dataList(self):
182 return self.repoList
183
184class F8_Repo(FC6_Repo):
185 removedKeywords = FC6_Repo.removedKeywords
186 removedAttrs = FC6_Repo.removedAttrs
187
188 def __str__(self):
189 retval = ""
190 for repo in self.repoList:
191 retval += repo.__str__()
192
193 return retval
194
195 def _getParser(self):
196 def list_cb (option, opt_str, value, parser):
197 for d in value.split(','):
198 parser.values.ensure_value(option.dest, []).append(d)
199
200 op = FC6_Repo._getParser(self)
201 op.add_option("--cost", action="store", type="int")
202 op.add_option("--excludepkgs", action="callback", callback=list_cb,
203 nargs=1, type="string")
204 op.add_option("--includepkgs", action="callback", callback=list_cb,
205 nargs=1, type="string")
206 return op
207
208 def methodToRepo(self):
209 if not self.handler.method.url:
210 raise KickstartError, formatErrorMsg(self.handler.method.lineno, msg=_("Method must be a url to be added to the repo list."))
211 reponame = "ks-method-url"
212 repourl = self.handler.method.url
213 rd = self.handler.RepoData(name=reponame, baseurl=repourl)
214 return rd
215
216class F11_Repo(F8_Repo):
217 removedKeywords = F8_Repo.removedKeywords
218 removedAttrs = F8_Repo.removedAttrs
219
220 def _getParser(self):
221 op = F8_Repo._getParser(self)
222 op.add_option("--ignoregroups", action="store", type="ksboolean")
223 return op
224
225class F13_Repo(F11_Repo):
226 removedKeywords = F11_Repo.removedKeywords
227 removedAttrs = F11_Repo.removedAttrs
228
229 def _getParser(self):
230 op = F11_Repo._getParser(self)
231 op.add_option("--proxy")
232 return op
233
234class F14_Repo(F13_Repo):
235 removedKeywords = F13_Repo.removedKeywords
236 removedAttrs = F13_Repo.removedAttrs
237
238 def _getParser(self):
239 op = F13_Repo._getParser(self)
240 op.add_option("--noverifyssl", action="store_true", default=False)
241 return op
242
243RHEL6_Repo = F14_Repo
244
245class F15_Repo(F14_Repo):
246 removedKeywords = F14_Repo.removedKeywords
247 removedAttrs = F14_Repo.removedAttrs
248
249 urlRequired = False
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/rescue.py b/scripts/lib/mic/3rdparty/pykickstart/commands/rescue.py
new file mode 100644
index 0000000000..1893d4ea49
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/rescue.py
@@ -0,0 +1,68 @@
1#
2# Alexander Todorov <atodorov@redhat.com>
3#
4# Copyright 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class F10_Rescue(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.rescue = False
36 self.nomount = kwargs.get("nomount", False)
37 self.romount = kwargs.get("romount", False)
38
39 def __str__(self):
40 retval = KickstartCommand.__str__(self)
41
42 if self.rescue:
43 retval += "rescue"
44
45 if self.nomount:
46 retval += " --nomount"
47 if self.romount:
48 retval += " --romount"
49
50 retval = "# Start rescue mode\n%s\n" % retval
51
52 return retval
53
54 def _getParser(self):
55 op = KSOptionParser()
56 op.add_option("--nomount", dest="nomount", action="store_true", default=False)
57 op.add_option("--romount", dest="romount", action="store_true", default=False)
58 return op
59
60 def parse(self, args):
61 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
62
63 if opts.nomount and opts.romount:
64 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --nomount and --romount may be specified for rescue command."))
65
66 self._setToSelf(self.op, opts)
67 self.rescue = True
68 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/rootpw.py b/scripts/lib/mic/3rdparty/pykickstart/commands/rootpw.py
new file mode 100644
index 0000000000..e038b4525d
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/rootpw.py
@@ -0,0 +1,93 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_RootPw(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.isCrypted = kwargs.get("isCrypted", False)
36 self.password = kwargs.get("password", "")
37
38 def _getArgsAsStr(self):
39 retval = ""
40
41 if self.isCrypted:
42 retval += " --iscrypted"
43
44 return retval
45
46 def __str__(self):
47 retval = KickstartCommand.__str__(self)
48
49 if self.password != "":
50 retval += "# Root password\nrootpw%s %s\n" % (self._getArgsAsStr(), self.password)
51
52 return retval
53
54 def _getParser(self):
55 op = KSOptionParser()
56 op.add_option("--iscrypted", dest="isCrypted", action="store_true",
57 default=False)
58 return op
59
60 def parse(self, args):
61 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
62 self._setToSelf(self.op, opts)
63
64 if len(extra) != 1:
65 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "rootpw")
66
67 self.password = extra[0]
68 return self
69
70class F8_RootPw(FC3_RootPw):
71 removedKeywords = FC3_RootPw.removedKeywords
72 removedAttrs = FC3_RootPw.removedAttrs
73
74 def __init__(self, writePriority=0, *args, **kwargs):
75 FC3_RootPw.__init__(self, writePriority, *args, **kwargs)
76 self.lock = kwargs.get("lock", False)
77
78 def _getArgsAsStr(self):
79 retval = FC3_RootPw._getArgsAsStr(self)
80
81 if self.lock:
82 retval += " --lock"
83
84 if not self.isCrypted:
85 retval += " --plaintext"
86
87 return retval
88
89 def _getParser(self):
90 op = FC3_RootPw._getParser(self)
91 op.add_option("--lock", dest="lock", action="store_true", default=False)
92 op.add_option("--plaintext", dest="isCrypted", action="store_false")
93 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/selinux.py b/scripts/lib/mic/3rdparty/pykickstart/commands/selinux.py
new file mode 100644
index 0000000000..9f8059c76b
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/selinux.py
@@ -0,0 +1,64 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.options import *
23
24class FC3_SELinux(KickstartCommand):
25 removedKeywords = KickstartCommand.removedKeywords
26 removedAttrs = KickstartCommand.removedAttrs
27
28 def __init__(self, writePriority=0, *args, **kwargs):
29 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
30 self.op = self._getParser()
31
32 self.selinux = kwargs.get("selinux", None)
33
34 def __str__(self):
35 retval = KickstartCommand.__str__(self)
36
37 if not retval and self.selinux is None:
38 return ""
39
40 retval += "# SELinux configuration\n"
41
42 if self.selinux == SELINUX_DISABLED:
43 retval += "selinux --disabled\n"
44 elif self.selinux == SELINUX_ENFORCING:
45 retval += "selinux --enforcing\n"
46 elif self.selinux == SELINUX_PERMISSIVE:
47 retval += "selinux --permissive\n"
48
49 return retval
50
51 def _getParser(self):
52 op = KSOptionParser()
53 op.add_option("--disabled", dest="selinux", action="store_const",
54 const=SELINUX_DISABLED)
55 op.add_option("--enforcing", dest="selinux", action="store_const",
56 const=SELINUX_ENFORCING)
57 op.add_option("--permissive", dest="selinux", action="store_const",
58 const=SELINUX_PERMISSIVE)
59 return op
60
61 def parse(self, args):
62 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
63 self._setToSelf(self.op, opts)
64 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/services.py b/scripts/lib/mic/3rdparty/pykickstart/commands/services.py
new file mode 100644
index 0000000000..2e0eab8007
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/services.py
@@ -0,0 +1,71 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC6_Services(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.disabled = kwargs.get("disabled", [])
36 self.enabled = kwargs.get("enabled", [])
37
38 def __str__(self):
39 retval = KickstartCommand.__str__(self)
40 args = ""
41
42 if len(self.disabled) > 0:
43 args += " --disabled=\"%s\"" % ",".join(self.disabled)
44 if len(self.enabled) > 0:
45 args += " --enabled=\"%s\"" % ",".join(self.enabled)
46
47 if args != "":
48 retval += "# System services\nservices%s\n" % args
49
50 return retval
51
52 def _getParser(self):
53 def services_cb (option, opt_str, value, parser):
54 for d in value.split(','):
55 parser.values.ensure_value(option.dest, []).append(d.strip())
56
57 op = KSOptionParser()
58 op.add_option("--disabled", dest="disabled", action="callback",
59 callback=services_cb, nargs=1, type="string")
60 op.add_option("--enabled", dest="enabled", action="callback",
61 callback=services_cb, nargs=1, type="string")
62 return op
63
64 def parse(self, args):
65 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
66 self._setToSelf(self.op, opts)
67
68 if len(self.disabled) == 0 and len(self.enabled) == 0:
69 raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("One of --disabled or --enabled must be provided."))
70
71 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/skipx.py b/scripts/lib/mic/3rdparty/pykickstart/commands/skipx.py
new file mode 100644
index 0000000000..36d1a8d5ba
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/skipx.py
@@ -0,0 +1,54 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_SkipX(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.skipx = kwargs.get("skipx", False)
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.skipx:
40 retval += "# Do not configure the X Window System\nskipx\n"
41
42 return retval
43
44 def _getParser(self):
45 op = KSOptionParser()
46 return op
47
48 def parse(self, args):
49 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
50 if len(extra) > 0:
51 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "skipx")
52
53 self.skipx = True
54 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/sshpw.py b/scripts/lib/mic/3rdparty/pykickstart/commands/sshpw.py
new file mode 100644
index 0000000000..e7867ebfb2
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/sshpw.py
@@ -0,0 +1,105 @@
1#
2# Peter Jones <pjones@redhat.com>
3#
4# Copyright 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class F13_SshPwData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
30
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.username = kwargs.get("username", None)
34 self.isCrypted = kwargs.get("isCrypted", False)
35 self.password = kwargs.get("password", "")
36 self.lock = kwargs.get("lock", False)
37
38 def __eq__(self, y):
39 return self.username == y.username
40
41 def __str__(self):
42 retval = BaseData.__str__(self)
43
44 retval += "sshpw"
45 retval += self._getArgsAsStr() + '\n'
46
47 return retval
48
49 def _getArgsAsStr(self):
50 retval = ""
51
52 retval += " --username=%s" % self.username
53 if self.lock:
54 retval += " --lock"
55 if self.isCrypted:
56 retval += " --iscrypted"
57 else:
58 retval += " --plaintext"
59
60 retval += " %s" % self.password
61 return retval
62
63class F13_SshPw(KickstartCommand):
64 removedKeywords = KickstartCommand.removedKeywords
65 removedAttrs = KickstartCommand.removedAttrs
66
67 def __init__(self, writePriority=0, *args, **kwargs):
68 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
69 self.op = self._getParser()
70
71 self.sshUserList = kwargs.get("sshUserList", [])
72
73 def __str__(self):
74 retval = ""
75 for user in self.sshUserList:
76 retval += user.__str__()
77
78 return retval
79
80 def _getParser(self):
81 op = KSOptionParser()
82 op.add_option("--username", dest="username", required=True)
83 op.add_option("--iscrypted", dest="isCrypted", action="store_true",
84 default=False)
85 op.add_option("--plaintext", dest="isCrypted", action="store_false")
86 op.add_option("--lock", dest="lock", action="store_true", default=False)
87 return op
88
89 def parse(self, args):
90 ud = self.handler.SshPwData()
91 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
92 self._setToObj(self.op, opts, ud)
93 ud.lineno = self.lineno
94
95 if len(extra) != 1:
96 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "sshpw")
97 ud.password = extra[0]
98
99 if ud in self.dataList():
100 warnings.warn(_("An ssh user with the name %s has already been defined.") % ud.name)
101
102 return ud
103
104 def dataList(self):
105 return self.sshUserList
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/timezone.py b/scripts/lib/mic/3rdparty/pykickstart/commands/timezone.py
new file mode 100644
index 0000000000..f5441de593
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/timezone.py
@@ -0,0 +1,86 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Timezone(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.isUtc = kwargs.get("isUtc", False)
36 self.timezone = kwargs.get("timezone", "")
37
38 def __str__(self):
39 retval = KickstartCommand.__str__(self)
40
41 if self.timezone != "":
42 if self.isUtc:
43 utc = "--utc"
44 else:
45 utc = ""
46
47 retval += "# System timezone\ntimezone %s %s\n" %(utc, self.timezone)
48
49 return retval
50
51 def _getParser(self):
52 op = KSOptionParser()
53 op.add_option("--utc", dest="isUtc", action="store_true", default=False)
54 return op
55
56 def parse(self, args):
57 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
58 self._setToSelf(self.op, opts)
59
60 if len(extra) != 1:
61 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "timezone")
62
63 self.timezone = extra[0]
64 return self
65
66class FC6_Timezone(FC3_Timezone):
67 removedKeywords = FC3_Timezone.removedKeywords
68 removedAttrs = FC3_Timezone.removedAttrs
69
70 def __str__(self):
71 retval = KickstartCommand.__str__(self)
72
73 if self.timezone != "":
74 if self.isUtc:
75 utc = "--isUtc"
76 else:
77 utc = ""
78
79 retval += "# System timezone\ntimezone %s %s\n" %(utc, self.timezone)
80
81 return retval
82
83 def _getParser(self):
84 op = FC3_Timezone._getParser(self)
85 op.add_option("--utc", "--isUtc", dest="isUtc", action="store_true", default=False)
86 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/updates.py b/scripts/lib/mic/3rdparty/pykickstart/commands/updates.py
new file mode 100644
index 0000000000..53ec49f7b8
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/updates.py
@@ -0,0 +1,60 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class F7_Updates(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34 self.url = kwargs.get("url", "")
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.url == "floppy":
40 retval += "updates\n"
41 elif self.url != "":
42 retval += "updates %s\n" % self.url
43
44 return retval
45
46 def _getParser(self):
47 op = KSOptionParser()
48 return op
49
50 def parse(self, args):
51 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
52
53 if len(extra) > 1:
54 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s only takes one argument") % "updates")
55 elif len(extra) == 0:
56 self.url = "floppy"
57 else:
58 self.url = extra[0]
59
60 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py b/scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py
new file mode 100644
index 0000000000..a68a82d378
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py
@@ -0,0 +1,106 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Upgrade(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.upgrade = kwargs.get("upgrade", None)
34 self.op = self._getParser()
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if self.upgrade is None:
40 return retval
41
42 if self.upgrade:
43 retval += "# Upgrade existing installation\nupgrade\n"
44 else:
45 retval += "# Install OS instead of upgrade\ninstall\n"
46
47 return retval
48
49 def _getParser(self):
50 op = KSOptionParser()
51 return op
52
53 def parse(self, args):
54 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
55
56 if len(extra) > 0:
57 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
58
59 if self.currentCmd == "upgrade":
60 self.upgrade = True
61 else:
62 self.upgrade = False
63
64 return self
65
66class F11_Upgrade(FC3_Upgrade):
67 removedKeywords = FC3_Upgrade.removedKeywords
68 removedAttrs = FC3_Upgrade.removedAttrs
69
70 def __init__(self, writePriority=0, *args, **kwargs):
71 FC3_Upgrade.__init__(self, writePriority, *args, **kwargs)
72
73 self.op = self._getParser()
74 self.root_device = kwargs.get("root_device", None)
75
76 def __str__(self):
77 if self.upgrade and (self.root_device is not None):
78 retval = KickstartCommand.__str__(self)
79 retval += "# Upgrade existing installation\nupgrade --root-device=%s\n" % self.root_device
80 else:
81 retval = FC3_Upgrade.__str__(self)
82
83 return retval
84
85 def _getParser(self):
86 op = KSOptionParser()
87 op.add_option("--root-device", dest="root_device")
88 return op
89
90 def parse(self, args):
91 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
92
93 if len(extra) > 0:
94 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
95
96 if (opts.root_device is not None) and (opts.root_device == ""):
97 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device"))
98 else:
99 self.root_device = opts.root_device
100
101 if self.currentCmd == "upgrade":
102 self.upgrade = True
103 else:
104 self.upgrade = False
105
106 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/user.py b/scripts/lib/mic/3rdparty/pykickstart/commands/user.py
new file mode 100644
index 0000000000..189dc7585f
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/user.py
@@ -0,0 +1,173 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26import warnings
27_ = lambda x: gettext.ldgettext("pykickstart", x)
28
29class FC6_UserData(BaseData):
30 removedKeywords = BaseData.removedKeywords
31 removedAttrs = BaseData.removedAttrs
32
33 def __init__(self, *args, **kwargs):
34 BaseData.__init__(self, *args, **kwargs)
35 self.groups = kwargs.get("groups", [])
36 self.homedir = kwargs.get("homedir", "")
37 self.isCrypted = kwargs.get("isCrypted", False)
38 self.name = kwargs.get("name", "")
39 self.password = kwargs.get("password", "")
40 self.shell = kwargs.get("shell", "")
41 self.uid = kwargs.get("uid", None)
42
43 def __eq__(self, y):
44 return self.name == y.name
45
46 def __str__(self):
47 retval = BaseData.__str__(self)
48
49 if self.uid != "":
50 retval += "user"
51 retval += self._getArgsAsStr() + "\n"
52
53 return retval
54
55 def _getArgsAsStr(self):
56 retval = ""
57
58 if len(self.groups) > 0:
59 retval += " --groups=%s" % ",".join(self.groups)
60 if self.homedir:
61 retval += " --homedir=%s" % self.homedir
62 if self.name:
63 retval += " --name=%s" % self.name
64 if self.password:
65 retval += " --password=%s" % self.password
66 if self.isCrypted:
67 retval += " --iscrypted"
68 if self.shell:
69 retval += " --shell=%s" % self.shell
70 if self.uid:
71 retval += " --uid=%s" % self.uid
72
73 return retval
74
75class F8_UserData(FC6_UserData):
76 removedKeywords = FC6_UserData.removedKeywords
77 removedAttrs = FC6_UserData.removedAttrs
78
79 def __init__(self, *args, **kwargs):
80 FC6_UserData.__init__(self, *args, **kwargs)
81 self.lock = kwargs.get("lock", False)
82
83 def _getArgsAsStr(self):
84 retval = FC6_UserData._getArgsAsStr(self)
85
86 if self.lock:
87 retval += " --lock"
88
89 return retval
90
91class F12_UserData(F8_UserData):
92 removedKeywords = F8_UserData.removedKeywords
93 removedAttrs = F8_UserData.removedAttrs
94
95 def __init__(self, *args, **kwargs):
96 F8_UserData.__init__(self, *args, **kwargs)
97 self.gecos = kwargs.get("gecos", "")
98
99 def _getArgsAsStr(self):
100 retval = F8_UserData._getArgsAsStr(self)
101
102 if self.gecos:
103 retval += " --gecos=\"%s\"" % (self.gecos,)
104
105 return retval
106
107class FC6_User(KickstartCommand):
108 removedKeywords = KickstartCommand.removedKeywords
109 removedAttrs = KickstartCommand.removedAttrs
110
111 def __init__(self, writePriority=0, *args, **kwargs):
112 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
113 self.op = self._getParser()
114
115 self.userList = kwargs.get("userList", [])
116
117 def __str__(self):
118 retval = ""
119 for user in self.userList:
120 retval += user.__str__()
121
122 return retval
123
124 def _getParser(self):
125 def groups_cb (option, opt_str, value, parser):
126 for d in value.split(','):
127 parser.values.ensure_value(option.dest, []).append(d)
128
129 op = KSOptionParser()
130 op.add_option("--groups", dest="groups", action="callback",
131 callback=groups_cb, nargs=1, type="string")
132 op.add_option("--homedir")
133 op.add_option("--iscrypted", dest="isCrypted", action="store_true",
134 default=False)
135 op.add_option("--name", required=1)
136 op.add_option("--password")
137 op.add_option("--shell")
138 op.add_option("--uid", type="int")
139 return op
140
141 def parse(self, args):
142 ud = self.handler.UserData()
143 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
144 self._setToObj(self.op, opts, ud)
145 ud.lineno = self.lineno
146
147 # Check for duplicates in the data list.
148 if ud in self.dataList():
149 warnings.warn(_("A user with the name %s has already been defined.") % ud.name)
150
151 return ud
152
153 def dataList(self):
154 return self.userList
155
156class F8_User(FC6_User):
157 removedKeywords = FC6_User.removedKeywords
158 removedAttrs = FC6_User.removedAttrs
159
160 def _getParser(self):
161 op = FC6_User._getParser(self)
162 op.add_option("--lock", action="store_true", default=False)
163 op.add_option("--plaintext", dest="isCrypted", action="store_false")
164 return op
165
166class F12_User(F8_User):
167 removedKeywords = F8_User.removedKeywords
168 removedAttrs = F8_User.removedAttrs
169
170 def _getParser(self):
171 op = F8_User._getParser(self)
172 op.add_option("--gecos", type="string")
173 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py b/scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py
new file mode 100644
index 0000000000..200ccfba2e
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/vnc.py
@@ -0,0 +1,114 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24class FC3_Vnc(KickstartCommand):
25 removedKeywords = KickstartCommand.removedKeywords
26 removedAttrs = KickstartCommand.removedAttrs
27
28 def __init__(self, writePriority=0, *args, **kwargs):
29 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
30 self.op = self._getParser()
31
32 self.enabled = kwargs.get("enabled", False)
33 self.password = kwargs.get("password", "")
34 self.connect = kwargs.get("connect", "")
35
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
38
39 if not self.enabled:
40 return retval
41
42 retval += "vnc"
43
44 if self.connect != "":
45 retval += " --connect=%s" % self.connect
46 if self.password != "":
47 retval += " --password=%s" % self.password
48
49 return retval + "\n"
50
51 def _getParser(self):
52 op = KSOptionParser()
53 op.add_option("--connect")
54 op.add_option("--password", dest="password")
55 return op
56
57 def parse(self, args):
58 self.enabled = True
59 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
60 self._setToSelf(self.op, opts)
61 return self
62
63class FC6_Vnc(FC3_Vnc):
64 removedKeywords = FC3_Vnc.removedKeywords + ["connect"]
65 removedAttrs = FC3_Vnc.removedAttrs + ["connect"]
66
67 def __init__(self, writePriority=0, host="", port="", *args, **kwargs):
68 FC3_Vnc.__init__(self, writePriority, *args, **kwargs)
69 self.deleteRemovedAttrs()
70
71 self.host = kwargs.get("host", "")
72 self.port = kwargs.get("port", "")
73
74 def __str__(self):
75 retval = KickstartCommand.__str__(self)
76
77 if not self.enabled:
78 return retval
79
80 retval += "vnc"
81
82 if self.host != "":
83 retval += " --host=%s" % self.host
84
85 if self.port != "":
86 retval += " --port=%s" % self.port
87 if self.password != "":
88 retval += " --password=%s" % self.password
89
90 return retval + "\n"
91
92 def _getParser(self):
93 def connect_cb (option, opt_str, value, parser):
94 cargs = value.split(":")
95 parser.values.ensure_value("host", cargs[0])
96
97 if len(cargs) > 1:
98 parser.values.ensure_value("port", cargs[1])
99
100 op = FC3_Vnc._getParser(self)
101 op.add_option("--connect", action="callback", callback=connect_cb,
102 nargs=1, type="string")
103 op.add_option("--host", dest="host")
104 op.add_option("--port", dest="port")
105 return op
106
107class F9_Vnc(FC6_Vnc):
108 removedKeywords = FC6_Vnc.removedKeywords
109 removedAttrs = FC6_Vnc.removedAttrs
110
111 def _getParser(self):
112 op = FC6_Vnc._getParser(self)
113 op.remove_option("--connect")
114 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/volgroup.py b/scripts/lib/mic/3rdparty/pykickstart/commands/volgroup.py
new file mode 100644
index 0000000000..255c47f0ae
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/volgroup.py
@@ -0,0 +1,102 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23import gettext
24import warnings
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_VolGroupData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
30
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.format = kwargs.get("format", True)
34 self.pesize = kwargs.get("pesize", 32768)
35 self.preexist = kwargs.get("preexist", False)
36 self.vgname = kwargs.get("vgname", "")
37 self.physvols = kwargs.get("physvols", [])
38
39 def __eq__(self, y):
40 return self.vgname == y.vgname
41
42 def __str__(self):
43 retval = BaseData.__str__(self)
44 retval += "volgroup %s" % self.vgname
45
46 if not self.format:
47 retval += " --noformat"
48 if self.pesize != 0:
49 retval += " --pesize=%d" % self.pesize
50 if self.preexist:
51 retval += " --useexisting"
52
53 return retval + " " + " ".join(self.physvols) + "\n"
54
55class FC3_VolGroup(KickstartCommand):
56 removedKeywords = KickstartCommand.removedKeywords
57 removedAttrs = KickstartCommand.removedAttrs
58
59 def __init__(self, writePriority=132, *args, **kwargs):
60 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
61 self.op = self._getParser()
62
63 self.vgList = kwargs.get("vgList", [])
64
65 def __str__(self):
66 retval = ""
67 for vg in self.vgList:
68 retval += vg.__str__()
69
70 return retval
71
72 def _getParser(self):
73 # Have to be a little more complicated to set two values.
74 def vg_cb (option, opt_str, value, parser):
75 parser.values.format = False
76 parser.values.preexist = True
77
78 op = KSOptionParser()
79 op.add_option("--noformat", action="callback", callback=vg_cb,
80 dest="format", default=True, nargs=0)
81 op.add_option("--pesize", dest="pesize", type="int", nargs=1,
82 default=32768)
83 op.add_option("--useexisting", dest="preexist", action="store_true",
84 default=False)
85 return op
86
87 def parse(self, args):
88 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
89 vg = self.handler.VolGroupData()
90 self._setToObj(self.op, opts, vg)
91 vg.lineno = self.lineno
92 vg.vgname = extra[0]
93 vg.physvols = extra[1:]
94
95 # Check for duplicates in the data list.
96 if vg in self.dataList():
97 warnings.warn(_("A volgroup with the name %s has already been defined.") % vg.vgname)
98
99 return vg
100
101 def dataList(self):
102 return self.vgList
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/xconfig.py b/scripts/lib/mic/3rdparty/pykickstart/commands/xconfig.py
new file mode 100644
index 0000000000..644ee86743
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/xconfig.py
@@ -0,0 +1,184 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_XConfig(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.op = self._getParser()
34
35 self.card = kwargs.get("card", "")
36 self.defaultdesktop = kwargs.get("defaultdesktop", "")
37 self.depth = kwargs.get("depth", 0)
38 self.hsync = kwargs.get("hsync", "")
39 self.monitor = kwargs.get("monitor", "")
40 self.noProbe = kwargs.get("noProbe", False)
41 self.resolution = kwargs.get("resolution", "")
42 self.server = kwargs.get("server", "")
43 self.startX = kwargs.get("startX", False)
44 self.videoRam = kwargs.get("videoRam", "")
45 self.vsync = kwargs.get("vsync", "")
46
47 def __str__(self):
48 retval = KickstartCommand.__str__(self)
49
50 if self.card != "":
51 retval += " --card=%s" % self.card
52 if self.defaultdesktop != "":
53 retval += " --defaultdesktop=%s" % self.defaultdesktop
54 if self.depth != 0:
55 retval += " --depth=%d" % self.depth
56 if self.hsync != "":
57 retval += " --hsync=%s" % self.hsync
58 if self.monitor != "":
59 retval += " --monitor=%s" % self.monitor
60 if self.noProbe:
61 retval += " --noprobe"
62 if self.resolution != "":
63 retval += " --resolution=%s" % self.resolution
64 if self.server != "":
65 retval += " --server=%s" % self.server
66 if self.startX:
67 retval += " --startxonboot"
68 if self.videoRam != "":
69 retval += " --videoram=%s" % self.videoRam
70 if self.vsync != "":
71 retval += " --vsync=%s" % self.vsync
72
73 if retval != "":
74 retval = "# X Window System configuration information\nxconfig %s\n" % retval
75
76 return retval
77
78 def _getParser(self):
79 op = KSOptionParser()
80 op.add_option("--card")
81 op.add_option("--defaultdesktop")
82 op.add_option("--depth", action="store", type="int", nargs=1)
83 op.add_option("--hsync")
84 op.add_option("--monitor")
85 op.add_option("--noprobe", dest="noProbe", action="store_true",
86 default=False)
87 op.add_option("--resolution")
88 op.add_option("--server")
89 op.add_option("--startxonboot", dest="startX", action="store_true",
90 default=False)
91 op.add_option("--videoram", dest="videoRam")
92 op.add_option("--vsync")
93 return op
94
95 def parse(self, args):
96 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
97 if extra:
98 mapping = {"command": "xconfig", "options": extra}
99 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
100
101 self._setToSelf(self.op, opts)
102 return self
103
104class FC6_XConfig(FC3_XConfig):
105 removedKeywords = FC3_XConfig.removedKeywords + ["card", "hsync", "monitor", "noProbe", "vsync"]
106 removedAttrs = FC3_XConfig.removedAttrs + ["card", "hsync", "monitor", "noProbe", "vsync"]
107
108 def __init__(self, writePriority=0, *args, **kwargs):
109 FC3_XConfig.__init__(self, writePriority, *args, **kwargs)
110 self.deleteRemovedAttrs()
111
112 self.driver = kwargs.get("driver", "")
113
114 def __str__(self):
115 retval = KickstartCommand.__str__(self)
116
117 if hasattr(self, "driver") and self.driver != "":
118 retval += " --driver=%s" % self.driver
119 if self.defaultdesktop != "":
120 retval += " --defaultdesktop=%s" % self.defaultdesktop
121 if self.depth != 0:
122 retval += " --depth=%d" % self.depth
123 if hasattr(self, "resolution") and self.resolution != "":
124 retval += " --resolution=%s" % self.resolution
125 if self.startX:
126 retval += " --startxonboot"
127 if hasattr(self, "videoRam") and self.videoRam != "":
128 retval += " --videoram=%s" % self.videoRam
129
130 if retval != "":
131 retval = "# X Window System configuration information\nxconfig %s\n" % retval
132
133 return retval
134
135 def _getParser(self):
136 op = FC3_XConfig._getParser(self)
137 op.add_option("--card", deprecated=1)
138 op.add_option("--driver", dest="driver")
139 op.add_option("--hsync", deprecated=1)
140 op.add_option("--monitor", deprecated=1)
141 op.add_option("--noprobe", deprecated=1)
142 op.add_option("--vsync", deprecated=1)
143 return op
144
145class F9_XConfig(FC6_XConfig):
146 removedKeywords = FC6_XConfig.removedKeywords
147 removedAttrs = FC6_XConfig.removedAttrs
148
149 def _getParser(self):
150 op = FC6_XConfig._getParser(self)
151 op.remove_option("--card")
152 op.remove_option("--hsync")
153 op.remove_option("--monitor")
154 op.remove_option("--noprobe")
155 op.remove_option("--vsync")
156 return op
157
158class F10_XConfig(F9_XConfig):
159 removedKeywords = F9_XConfig.removedKeywords + ["driver", "resolution", "videoRam"]
160 removedAttrs = F9_XConfig.removedAttrs + ["driver", "resolution", "videoRam"]
161
162 def __init__(self, writePriority=0, *args, **kwargs):
163 F9_XConfig.__init__(self, writePriority, *args, **kwargs)
164 self.deleteRemovedAttrs()
165
166 def _getParser(self):
167 op = F9_XConfig._getParser(self)
168 op.add_option("--driver", deprecated=1)
169 op.add_option("--depth", deprecated=1)
170 op.add_option("--resolution", deprecated=1)
171 op.add_option("--videoram", deprecated=1)
172 return op
173
174class F14_XConfig(F10_XConfig):
175 removedKeywords = F10_XConfig.removedKeywords
176 removedAttrs = F10_XConfig.removedAttrs
177
178 def _getParser(self):
179 op = F10_XConfig._getParser(self)
180 op.remove_option("--driver")
181 op.remove_option("--depth")
182 op.remove_option("--resolution")
183 op.remove_option("--videoram")
184 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/zerombr.py b/scripts/lib/mic/3rdparty/pykickstart/commands/zerombr.py
new file mode 100644
index 0000000000..79555a9b27
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/zerombr.py
@@ -0,0 +1,69 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20import warnings
21
22from pykickstart.base import *
23from pykickstart.options import *
24
25import gettext
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC3_ZeroMbr(KickstartCommand):
29 removedKeywords = KickstartCommand.removedKeywords
30 removedAttrs = KickstartCommand.removedAttrs
31
32 def __init__(self, writePriority=110, *args, **kwargs):
33 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
34 self.op = self._getParser()
35 self.zerombr = kwargs.get("zerombr", False)
36
37 def __str__(self):
38 retval = KickstartCommand.__str__(self)
39
40 if self.zerombr:
41 retval += "# Clear the Master Boot Record\nzerombr\n"
42
43 return retval
44
45 def _getParser(self):
46 op = KSOptionParser()
47 return op
48
49 def parse(self, args):
50 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
51
52 if len(extra) > 0:
53 warnings.warn(_("Ignoring deprecated option on line %s: The zerombr command no longer takes any options. In future releases, this will result in a fatal error from kickstart. Please modify your kickstart file to remove any options.") % self.lineno, DeprecationWarning)
54
55 self.zerombr = True
56 return self
57
58class F9_ZeroMbr(FC3_ZeroMbr):
59 removedKeywords = FC3_ZeroMbr.removedKeywords
60 removedAttrs = FC3_ZeroMbr.removedAttrs
61
62 def parse(self, args):
63 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
64
65 if len(extra) > 0:
66 raise KickstartParseError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "zerombr")
67
68 self.zerombr = True
69 return self
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py b/scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py
new file mode 100644
index 0000000000..1ed2694c89
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py
@@ -0,0 +1,134 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.options import *
22
23import gettext
24import warnings
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_ZFCPData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
30
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.devnum = kwargs.get("devnum", "")
34 self.wwpn = kwargs.get("wwpn", "")
35 self.fcplun = kwargs.get("fcplun", "")
36 self.scsiid = kwargs.get("scsiid", "")
37 self.scsilun = kwargs.get("scsilun", "")
38
39 def __eq__(self, y):
40 return self.devnum == y.devnum and self.wwpn == y.wwpn and \
41 self.fcplun == y.fcplun and self.scsiid == y.scsiid and \
42 self.scsilun == y.scsilun
43
44 def __str__(self):
45 retval = BaseData.__str__(self)
46 retval += "zfcp"
47
48 if self.devnum != "":
49 retval += " --devnum=%s" % self.devnum
50 if self.wwpn != "":
51 retval += " --wwpn=%s" % self.wwpn
52 if self.fcplun != "":
53 retval += " --fcplun=%s" % self.fcplun
54 if hasattr(self, "scsiid") and self.scsiid != "":
55 retval += " --scsiid=%s" % self.scsiid
56 if hasattr(self, "scsilun") and self.scsilun != "":
57 retval += " --scsilun=%s" % self.scsilun
58
59 return retval + "\n"
60
61class F12_ZFCPData(FC3_ZFCPData):
62 removedKeywords = FC3_ZFCPData.removedKeywords + ["scsiid", "scsilun"]
63 removedAttrs = FC3_ZFCPData.removedAttrs + ["scsiid", "scsilun"]
64
65 def __init__(self, *args, **kwargs):
66 FC3_ZFCPData.__init__(self, *args, **kwargs)
67 self.deleteRemovedAttrs()
68
69F14_ZFCPData = F12_ZFCPData
70
71class FC3_ZFCP(KickstartCommand):
72 removedKeywords = KickstartCommand.removedKeywords
73 removedAttrs = KickstartCommand.removedAttrs
74
75 def __init__(self, writePriority=71, *args, **kwargs):
76 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
77 self.op = self._getParser()
78
79 self.zfcp = kwargs.get("zfcp", [])
80
81 def __str__(self):
82 retval = ""
83 for zfcp in self.zfcp:
84 retval += zfcp.__str__()
85
86 return retval
87
88 def _getParser(self):
89 op = KSOptionParser()
90 op.add_option("--devnum", dest="devnum", required=1)
91 op.add_option("--fcplun", dest="fcplun", required=1)
92 op.add_option("--scsiid", dest="scsiid", required=1)
93 op.add_option("--scsilun", dest="scsilun", required=1)
94 op.add_option("--wwpn", dest="wwpn", required=1)
95 return op
96
97 def parse(self, args):
98 zd = self.handler.ZFCPData()
99 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
100 self._setToObj(self.op, opts, zd)
101 zd.lineno = self.lineno
102
103 # Check for duplicates in the data list.
104 if zd in self.dataList():
105 warnings.warn(_("A zfcp with this information has already been defined."))
106
107 return zd
108
109 def dataList(self):
110 return self.zfcp
111
112class F12_ZFCP(FC3_ZFCP):
113 removedKeywords = FC3_ZFCP.removedKeywords
114 removedAttrs = FC3_ZFCP.removedAttrs + ["scsiid", "scsilun"]
115
116 def __init__(self, *args, **kwargs):
117 FC3_ZFCP.__init__(self, *args, **kwargs)
118 self.deleteRemovedAttrs()
119
120 def _getParser(self):
121 op = FC3_ZFCP._getParser(self)
122 op.add_option("--scsiid", deprecated=1)
123 op.add_option("--scsilun", deprecated=1)
124 return op
125
126class F14_ZFCP(F12_ZFCP):
127 removedKeywords = F12_ZFCP.removedKeywords
128 removedAttrs = F12_ZFCP.removedAttrs
129
130 def _getParser(self):
131 op = F12_ZFCP._getParser(self)
132 op.remove_option("--scsiid")
133 op.remove_option("--scsilun")
134 return op
diff --git a/scripts/lib/mic/3rdparty/pykickstart/constants.py b/scripts/lib/mic/3rdparty/pykickstart/constants.py
new file mode 100644
index 0000000000..5e12fc80ec
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/constants.py
@@ -0,0 +1,57 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005-2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20CLEARPART_TYPE_LINUX = 0
21CLEARPART_TYPE_ALL = 1
22CLEARPART_TYPE_NONE = 2
23
24DISPLAY_MODE_CMDLINE = 0
25DISPLAY_MODE_GRAPHICAL = 1
26DISPLAY_MODE_TEXT = 2
27
28FIRSTBOOT_DEFAULT = 0
29FIRSTBOOT_SKIP = 1
30FIRSTBOOT_RECONFIG = 2
31
32KS_MISSING_PROMPT = 0
33KS_MISSING_IGNORE = 1
34
35SELINUX_DISABLED = 0
36SELINUX_ENFORCING = 1
37SELINUX_PERMISSIVE = 2
38
39KS_SCRIPT_PRE = 0
40KS_SCRIPT_POST = 1
41KS_SCRIPT_TRACEBACK = 2
42
43KS_WAIT = 0
44KS_REBOOT = 1
45KS_SHUTDOWN = 2
46
47KS_INSTKEY_SKIP = -99
48
49BOOTPROTO_DHCP = "dhcp"
50BOOTPROTO_BOOTP = "bootp"
51BOOTPROTO_STATIC = "static"
52BOOTPROTO_QUERY = "query"
53BOOTPROTO_IBFT = "ibft"
54
55GROUP_REQUIRED = 0
56GROUP_DEFAULT = 1
57GROUP_ALL = 2
diff --git a/scripts/lib/mic/3rdparty/pykickstart/errors.py b/scripts/lib/mic/3rdparty/pykickstart/errors.py
new file mode 100644
index 0000000000..a234d99d43
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/errors.py
@@ -0,0 +1,103 @@
1#
2# errors.py: Kickstart error handling.
3#
4# Chris Lumens <clumens@redhat.com>
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20"""
21Error handling classes and functions.
22
23This module exports a single function:
24
25 formatErrorMsg - Properly formats an error message.
26
27It also exports several exception classes:
28
29 KickstartError - A generic exception class.
30
31 KickstartParseError - An exception for errors relating to parsing.
32
33 KickstartValueError - An exception for errors relating to option
34 processing.
35
36 KickstartVersionError - An exception for errors relating to unsupported
37 syntax versions.
38"""
39import gettext
40_ = lambda x: gettext.ldgettext("pykickstart", x)
41
42def formatErrorMsg(lineno, msg=""):
43 """Properly format the error message msg for inclusion in an exception."""
44 if msg != "":
45 mapping = {"lineno": lineno, "msg": msg}
46 return _("The following problem occurred on line %(lineno)s of the kickstart file:\n\n%(msg)s\n") % mapping
47 else:
48 return _("There was a problem reading from line %s of the kickstart file") % lineno
49
50class KickstartError(Exception):
51 """A generic exception class for unspecific error conditions."""
52 def __init__(self, val = ""):
53 """Create a new KickstartError exception instance with the descriptive
54 message val. val should be the return value of formatErrorMsg.
55 """
56 Exception.__init__(self)
57 self.value = val
58
59 def __str__ (self):
60 return self.value
61
62class KickstartParseError(KickstartError):
63 """An exception class for errors when processing the input file, such as
64 unknown options, commands, or sections.
65 """
66 def __init__(self, msg):
67 """Create a new KickstartParseError exception instance with the
68 descriptive message val. val should be the return value of
69 formatErrorMsg.
70 """
71 KickstartError.__init__(self, msg)
72
73 def __str__(self):
74 return self.value
75
76class KickstartValueError(KickstartError):
77 """An exception class for errors when processing arguments to commands,
78 such as too many arguments, too few arguments, or missing required
79 arguments.
80 """
81 def __init__(self, msg):
82 """Create a new KickstartValueError exception instance with the
83 descriptive message val. val should be the return value of
84 formatErrorMsg.
85 """
86 KickstartError.__init__(self, msg)
87
88 def __str__ (self):
89 return self.value
90
91class KickstartVersionError(KickstartError):
92 """An exception class for errors related to using an incorrect version of
93 kickstart syntax.
94 """
95 def __init__(self, msg):
96 """Create a new KickstartVersionError exception instance with the
97 descriptive message val. val should be the return value of
98 formatErrorMsg.
99 """
100 KickstartError.__init__(self, msg)
101
102 def __str__ (self):
103 return self.value
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/__init__.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/__init__.py
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/control.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/control.py
new file mode 100644
index 0000000000..d8c8f2b899
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/control.py
@@ -0,0 +1,1307 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.version import *
21from pykickstart.commands import *
22
23# This map is keyed on kickstart syntax version as provided by
24# pykickstart.version. Within each sub-dict is a mapping from command name
25# to the class that handles it. This is an onto mapping - that is, multiple
26# command names can map to the same class. However, the Handler will ensure
27# that only one instance of each class ever exists.
28commandMap = {
29 FC3: {
30 "auth": authconfig.FC3_Authconfig,
31 "authconfig": authconfig.FC3_Authconfig,
32 "autopart": autopart.FC3_AutoPart,
33 "autostep": autostep.FC3_AutoStep,
34 "bootloader": bootloader.FC3_Bootloader,
35 "cdrom": method.FC3_Method,
36 "clearpart": clearpart.FC3_ClearPart,
37 "cmdline": displaymode.FC3_DisplayMode,
38 "device": device.FC3_Device,
39 "deviceprobe": deviceprobe.FC3_DeviceProbe,
40 "driverdisk": driverdisk.FC3_DriverDisk,
41 "firewall": firewall.FC3_Firewall,
42 "firstboot": firstboot.FC3_Firstboot,
43 "graphical": displaymode.FC3_DisplayMode,
44 "halt": reboot.FC3_Reboot,
45 "harddrive": method.FC3_Method,
46 "ignoredisk": ignoredisk.FC3_IgnoreDisk,
47 "install": upgrade.FC3_Upgrade,
48 "interactive": interactive.FC3_Interactive,
49 "keyboard": keyboard.FC3_Keyboard,
50 "lang": lang.FC3_Lang,
51 "langsupport": langsupport.FC3_LangSupport,
52 "lilo": bootloader.FC3_Bootloader,
53 "lilocheck": lilocheck.FC3_LiloCheck,
54 "logvol": logvol.FC3_LogVol,
55 "monitor": monitor.FC3_Monitor,
56 "mouse": mouse.FC3_Mouse,
57 "network": network.FC3_Network,
58 "nfs": method.FC3_Method,
59 "part": partition.FC3_Partition,
60 "partition": partition.FC3_Partition,
61 "poweroff": reboot.FC3_Reboot,
62 "raid": raid.FC3_Raid,
63 "reboot": reboot.FC3_Reboot,
64 "rootpw": rootpw.FC3_RootPw,
65 "selinux": selinux.FC3_SELinux,
66 "shutdown": reboot.FC3_Reboot,
67 "skipx": skipx.FC3_SkipX,
68 "text": displaymode.FC3_DisplayMode,
69 "timezone": timezone.FC3_Timezone,
70 "upgrade": upgrade.FC3_Upgrade,
71 "url": method.FC3_Method,
72 "vnc": vnc.FC3_Vnc,
73 "volgroup": volgroup.FC3_VolGroup,
74 "xconfig": xconfig.FC3_XConfig,
75 "zerombr": zerombr.FC3_ZeroMbr,
76 "zfcp": zfcp.FC3_ZFCP,
77 },
78
79 # based on fc3
80 FC4: {
81 "auth": authconfig.FC3_Authconfig,
82 "authconfig": authconfig.FC3_Authconfig,
83 "autopart": autopart.FC3_AutoPart,
84 "autostep": autostep.FC3_AutoStep,
85 "bootloader": bootloader.FC4_Bootloader,
86 "cdrom": method.FC3_Method,
87 "clearpart": clearpart.FC3_ClearPart,
88 "cmdline": displaymode.FC3_DisplayMode,
89 "device": device.FC3_Device,
90 "deviceprobe": deviceprobe.FC3_DeviceProbe,
91 "driverdisk": driverdisk.FC4_DriverDisk,
92 "firewall": firewall.FC3_Firewall,
93 "firstboot": firstboot.FC3_Firstboot,
94 "graphical": displaymode.FC3_DisplayMode,
95 "halt": reboot.FC3_Reboot,
96 "harddrive": method.FC3_Method,
97 "ignoredisk": ignoredisk.FC3_IgnoreDisk,
98 "install": upgrade.FC3_Upgrade,
99 "interactive": interactive.FC3_Interactive,
100 "keyboard": keyboard.FC3_Keyboard,
101 "lang": lang.FC3_Lang,
102 "langsupport": langsupport.FC3_LangSupport,
103 "logvol": logvol.FC4_LogVol,
104 "mediacheck": mediacheck.FC4_MediaCheck,
105 "monitor": monitor.FC3_Monitor,
106 "mouse": mouse.FC3_Mouse,
107 "network": network.FC4_Network,
108 "nfs": method.FC3_Method,
109 "part": partition.FC4_Partition,
110 "partition": partition.FC4_Partition,
111 "poweroff": reboot.FC3_Reboot,
112 "raid": raid.FC4_Raid,
113 "reboot": reboot.FC3_Reboot,
114 "rootpw": rootpw.FC3_RootPw,
115 "selinux": selinux.FC3_SELinux,
116 "shutdown": reboot.FC3_Reboot,
117 "skipx": skipx.FC3_SkipX,
118 "text": displaymode.FC3_DisplayMode,
119 "timezone": timezone.FC3_Timezone,
120 "upgrade": upgrade.FC3_Upgrade,
121 "url": method.FC3_Method,
122 "vnc": vnc.FC3_Vnc,
123 "volgroup": volgroup.FC3_VolGroup,
124 "xconfig": xconfig.FC3_XConfig,
125 "zerombr": zerombr.FC3_ZeroMbr,
126 "zfcp": zfcp.FC3_ZFCP,
127 },
128
129 # based on fc4
130 FC5: {
131 "auth": authconfig.FC3_Authconfig,
132 "authconfig": authconfig.FC3_Authconfig,
133 "autopart": autopart.FC3_AutoPart,
134 "autostep": autostep.FC3_AutoStep,
135 "bootloader": bootloader.FC4_Bootloader,
136 "cdrom": method.FC3_Method,
137 "clearpart": clearpart.FC3_ClearPart,
138 "cmdline": displaymode.FC3_DisplayMode,
139 "device": device.FC3_Device,
140 "deviceprobe": deviceprobe.FC3_DeviceProbe,
141 "driverdisk": driverdisk.FC4_DriverDisk,
142 "firewall": firewall.FC3_Firewall,
143 "firstboot": firstboot.FC3_Firstboot,
144 "graphical": displaymode.FC3_DisplayMode,
145 "halt": reboot.FC3_Reboot,
146 "harddrive": method.FC3_Method,
147 "ignoredisk": ignoredisk.FC3_IgnoreDisk,
148 "install": upgrade.FC3_Upgrade,
149 "interactive": interactive.FC3_Interactive,
150 "keyboard": keyboard.FC3_Keyboard,
151 "lang": lang.FC3_Lang,
152 "langsupport": langsupport.FC5_LangSupport,
153 "logvol": logvol.FC4_LogVol,
154 "mediacheck": mediacheck.FC4_MediaCheck,
155 "monitor": monitor.FC3_Monitor,
156 "mouse": mouse.FC3_Mouse,
157 "network": network.FC4_Network,
158 "nfs": method.FC3_Method,
159 "part": partition.FC4_Partition,
160 "partition": partition.FC4_Partition,
161 "poweroff": reboot.FC3_Reboot,
162 "raid": raid.FC5_Raid,
163 "reboot": reboot.FC3_Reboot,
164 "rootpw": rootpw.FC3_RootPw,
165 "selinux": selinux.FC3_SELinux,
166 "shutdown": reboot.FC3_Reboot,
167 "skipx": skipx.FC3_SkipX,
168 "text": displaymode.FC3_DisplayMode,
169 "timezone": timezone.FC3_Timezone,
170 "upgrade": upgrade.FC3_Upgrade,
171 "url": method.FC3_Method,
172 "vnc": vnc.FC3_Vnc,
173 "volgroup": volgroup.FC3_VolGroup,
174 "xconfig": xconfig.FC3_XConfig,
175 "zerombr": zerombr.FC3_ZeroMbr,
176 "zfcp": zfcp.FC3_ZFCP,
177 },
178
179 # based on fc5
180 FC6: {
181 "auth": authconfig.FC3_Authconfig,
182 "authconfig": authconfig.FC3_Authconfig,
183 "autopart": autopart.FC3_AutoPart,
184 "autostep": autostep.FC3_AutoStep,
185 "bootloader": bootloader.FC4_Bootloader,
186 "cdrom": method.FC6_Method,
187 "clearpart": clearpart.FC3_ClearPart,
188 "cmdline": displaymode.FC3_DisplayMode,
189 "device": device.FC3_Device,
190 "deviceprobe": deviceprobe.FC3_DeviceProbe,
191 "dmraid": dmraid.FC6_DmRaid,
192 "driverdisk": driverdisk.FC4_DriverDisk,
193 "firewall": firewall.FC3_Firewall,
194 "firstboot": firstboot.FC3_Firstboot,
195 "graphical": displaymode.FC3_DisplayMode,
196 "halt": reboot.FC6_Reboot,
197 "harddrive": method.FC6_Method,
198 "ignoredisk": ignoredisk.FC3_IgnoreDisk,
199 "install": upgrade.FC3_Upgrade,
200 "interactive": interactive.FC3_Interactive,
201 "iscsi": iscsi.FC6_Iscsi,
202 "iscsiname": iscsiname.FC6_IscsiName,
203 "keyboard": keyboard.FC3_Keyboard,
204 "lang": lang.FC3_Lang,
205 "langsupport": langsupport.FC5_LangSupport,
206 "logging": logging.FC6_Logging,
207 "logvol": logvol.FC4_LogVol,
208 "mediacheck": mediacheck.FC4_MediaCheck,
209 "monitor": monitor.FC6_Monitor,
210 "mouse": mouse.FC3_Mouse,
211 "multipath": multipath.FC6_MultiPath,
212 "network": network.FC6_Network,
213 "nfs": method.FC6_Method,
214 "part": partition.FC4_Partition,
215 "partition": partition.FC4_Partition,
216 "poweroff": reboot.FC6_Reboot,
217 "raid": raid.FC5_Raid,
218 "reboot": reboot.FC6_Reboot,
219 "repo": repo.FC6_Repo,
220 "rootpw": rootpw.FC3_RootPw,
221 "selinux": selinux.FC3_SELinux,
222 "services": services.FC6_Services,
223 "shutdown": reboot.FC6_Reboot,
224 "skipx": skipx.FC3_SkipX,
225 "text": displaymode.FC3_DisplayMode,
226 "timezone": timezone.FC6_Timezone,
227 "upgrade": upgrade.FC3_Upgrade,
228 "user": user.FC6_User,
229 "url": method.FC6_Method,
230 "vnc": vnc.FC6_Vnc,
231 "volgroup": volgroup.FC3_VolGroup,
232 "xconfig": xconfig.FC6_XConfig,
233 "zerombr": zerombr.FC3_ZeroMbr,
234 "zfcp": zfcp.FC3_ZFCP,
235 },
236
237 # based on fc6
238 F7: {
239 "auth": authconfig.FC3_Authconfig,
240 "authconfig": authconfig.FC3_Authconfig,
241 "autopart": autopart.FC3_AutoPart,
242 "autostep": autostep.FC3_AutoStep,
243 "bootloader": bootloader.FC4_Bootloader,
244 "cdrom": method.FC6_Method,
245 "clearpart": clearpart.FC3_ClearPart,
246 "cmdline": displaymode.FC3_DisplayMode,
247 "device": device.FC3_Device,
248 "deviceprobe": deviceprobe.FC3_DeviceProbe,
249 "dmraid": dmraid.FC6_DmRaid,
250 "driverdisk": driverdisk.FC4_DriverDisk,
251 "firewall": firewall.FC3_Firewall,
252 "firstboot": firstboot.FC3_Firstboot,
253 "graphical": displaymode.FC3_DisplayMode,
254 "halt": reboot.FC6_Reboot,
255 "harddrive": method.FC6_Method,
256 "ignoredisk": ignoredisk.FC3_IgnoreDisk,
257 "install": upgrade.FC3_Upgrade,
258 "interactive": interactive.FC3_Interactive,
259 "iscsi": iscsi.FC6_Iscsi,
260 "iscsiname": iscsiname.FC6_IscsiName,
261 "keyboard": keyboard.FC3_Keyboard,
262 "lang": lang.FC3_Lang,
263 "logging": logging.FC6_Logging,
264 "logvol": logvol.FC4_LogVol,
265 "mediacheck": mediacheck.FC4_MediaCheck,
266 "monitor": monitor.FC6_Monitor,
267 "multipath": multipath.FC6_MultiPath,
268 "network": network.FC6_Network,
269 "nfs": method.FC6_Method,
270 "part": partition.FC4_Partition,
271 "partition": partition.FC4_Partition,
272 "poweroff": reboot.FC6_Reboot,
273 "raid": raid.F7_Raid,
274 "reboot": reboot.FC6_Reboot,
275 "repo": repo.FC6_Repo,
276 "rootpw": rootpw.FC3_RootPw,
277 "selinux": selinux.FC3_SELinux,
278 "services": services.FC6_Services,
279 "shutdown": reboot.FC6_Reboot,
280 "skipx": skipx.FC3_SkipX,
281 "text": displaymode.FC3_DisplayMode,
282 "timezone": timezone.FC6_Timezone,
283 "updates": updates.F7_Updates,
284 "upgrade": upgrade.FC3_Upgrade,
285 "url": method.FC6_Method,
286 "user": user.FC6_User,
287 "vnc": vnc.FC6_Vnc,
288 "volgroup": volgroup.FC3_VolGroup,
289 "xconfig": xconfig.FC6_XConfig,
290 "zerombr": zerombr.FC3_ZeroMbr,
291 "zfcp": zfcp.FC3_ZFCP,
292 },
293
294 # based on f7
295 F8: {
296 "auth": authconfig.FC3_Authconfig,
297 "authconfig": authconfig.FC3_Authconfig,
298 "autopart": autopart.FC3_AutoPart,
299 "autostep": autostep.FC3_AutoStep,
300 "bootloader": bootloader.F8_Bootloader,
301 "cdrom": method.FC6_Method,
302 "clearpart": clearpart.FC3_ClearPart,
303 "cmdline": displaymode.FC3_DisplayMode,
304 "device": device.F8_Device,
305 "deviceprobe": deviceprobe.FC3_DeviceProbe,
306 "dmraid": dmraid.FC6_DmRaid,
307 "driverdisk": driverdisk.FC4_DriverDisk,
308 "firewall": firewall.FC3_Firewall,
309 "firstboot": firstboot.FC3_Firstboot,
310 "graphical": displaymode.FC3_DisplayMode,
311 "halt": reboot.FC6_Reboot,
312 "harddrive": method.FC6_Method,
313 "ignoredisk": ignoredisk.F8_IgnoreDisk,
314 "install": upgrade.FC3_Upgrade,
315 "interactive": interactive.FC3_Interactive,
316 "iscsi": iscsi.FC6_Iscsi,
317 "iscsiname": iscsiname.FC6_IscsiName,
318 "keyboard": keyboard.FC3_Keyboard,
319 "lang": lang.FC3_Lang,
320 "logging": logging.FC6_Logging,
321 "logvol": logvol.FC4_LogVol,
322 "mediacheck": mediacheck.FC4_MediaCheck,
323 "monitor": monitor.FC6_Monitor,
324 "multipath": multipath.FC6_MultiPath,
325 "network": network.F8_Network,
326 "nfs": method.FC6_Method,
327 "part": partition.FC4_Partition,
328 "partition": partition.FC4_Partition,
329 "poweroff": reboot.FC6_Reboot,
330 "raid": raid.F7_Raid,
331 "reboot": reboot.FC6_Reboot,
332 "repo": repo.F8_Repo,
333 "rootpw": rootpw.F8_RootPw,
334 "selinux": selinux.FC3_SELinux,
335 "services": services.FC6_Services,
336 "shutdown": reboot.FC6_Reboot,
337 "skipx": skipx.FC3_SkipX,
338 "text": displaymode.FC3_DisplayMode,
339 "timezone": timezone.FC6_Timezone,
340 "updates": updates.F7_Updates,
341 "upgrade": upgrade.FC3_Upgrade,
342 "url": method.FC6_Method,
343 "user": user.F8_User,
344 "vnc": vnc.FC6_Vnc,
345 "volgroup": volgroup.FC3_VolGroup,
346 "xconfig": xconfig.FC6_XConfig,
347 "zerombr": zerombr.FC3_ZeroMbr,
348 "zfcp": zfcp.FC3_ZFCP,
349 },
350
351 # based on f8
352 F9: {
353 "auth": authconfig.FC3_Authconfig,
354 "authconfig": authconfig.FC3_Authconfig,
355 "autopart": autopart.F9_AutoPart,
356 "autostep": autostep.FC3_AutoStep,
357 "bootloader": bootloader.F8_Bootloader,
358 "cdrom": method.FC6_Method,
359 "clearpart": clearpart.FC3_ClearPart,
360 "cmdline": displaymode.FC3_DisplayMode,
361 "device": device.F8_Device,
362 "deviceprobe": deviceprobe.FC3_DeviceProbe,
363 "dmraid": dmraid.FC6_DmRaid,
364 "driverdisk": driverdisk.FC4_DriverDisk,
365 "firewall": firewall.F9_Firewall,
366 "firstboot": firstboot.FC3_Firstboot,
367 "graphical": displaymode.FC3_DisplayMode,
368 "halt": reboot.FC6_Reboot,
369 "harddrive": method.FC6_Method,
370 "ignoredisk": ignoredisk.F8_IgnoreDisk,
371 "install": upgrade.FC3_Upgrade,
372 "interactive": interactive.FC3_Interactive,
373 "iscsi": iscsi.FC6_Iscsi,
374 "iscsiname": iscsiname.FC6_IscsiName,
375 "keyboard": keyboard.FC3_Keyboard,
376 "lang": lang.FC3_Lang,
377 "logging": logging.FC6_Logging,
378 "logvol": logvol.F9_LogVol,
379 "mediacheck": mediacheck.FC4_MediaCheck,
380 "monitor": monitor.FC6_Monitor,
381 "multipath": multipath.FC6_MultiPath,
382 "network": network.F9_Network,
383 "nfs": method.FC6_Method,
384 "part": partition.F9_Partition,
385 "partition": partition.F9_Partition,
386 "poweroff": reboot.FC6_Reboot,
387 "raid": raid.F9_Raid,
388 "reboot": reboot.FC6_Reboot,
389 "repo": repo.F8_Repo,
390 "rootpw": rootpw.F8_RootPw,
391 "selinux": selinux.FC3_SELinux,
392 "services": services.FC6_Services,
393 "shutdown": reboot.FC6_Reboot,
394 "skipx": skipx.FC3_SkipX,
395 "text": displaymode.FC3_DisplayMode,
396 "timezone": timezone.FC6_Timezone,
397 "updates": updates.F7_Updates,
398 "upgrade": upgrade.FC3_Upgrade,
399 "url": method.FC6_Method,
400 "user": user.F8_User,
401 "vnc": vnc.F9_Vnc,
402 "volgroup": volgroup.FC3_VolGroup,
403 "xconfig": xconfig.F9_XConfig,
404 "zerombr": zerombr.F9_ZeroMbr,
405 "zfcp": zfcp.FC3_ZFCP,
406 },
407
408 # based on f9
409 F10: {
410 "auth": authconfig.FC3_Authconfig,
411 "authconfig": authconfig.FC3_Authconfig,
412 "autopart": autopart.F9_AutoPart,
413 "autostep": autostep.FC3_AutoStep,
414 "bootloader": bootloader.F8_Bootloader,
415 "cdrom": method.FC6_Method,
416 "clearpart": clearpart.FC3_ClearPart,
417 "cmdline": displaymode.FC3_DisplayMode,
418 "device": device.F8_Device,
419 "deviceprobe": deviceprobe.FC3_DeviceProbe,
420 "dmraid": dmraid.FC6_DmRaid,
421 "driverdisk": driverdisk.FC4_DriverDisk,
422 "firewall": firewall.F10_Firewall,
423 "firstboot": firstboot.FC3_Firstboot,
424 "graphical": displaymode.FC3_DisplayMode,
425 "halt": reboot.FC6_Reboot,
426 "harddrive": method.FC6_Method,
427 "ignoredisk": ignoredisk.F8_IgnoreDisk,
428 "install": upgrade.FC3_Upgrade,
429 "interactive": interactive.FC3_Interactive,
430 "iscsi": iscsi.F10_Iscsi,
431 "iscsiname": iscsiname.FC6_IscsiName,
432 "keyboard": keyboard.FC3_Keyboard,
433 "lang": lang.FC3_Lang,
434 "logging": logging.FC6_Logging,
435 "logvol": logvol.F9_LogVol,
436 "mediacheck": mediacheck.FC4_MediaCheck,
437 "monitor": monitor.F10_Monitor,
438 "multipath": multipath.FC6_MultiPath,
439 "network": network.F9_Network,
440 "nfs": method.FC6_Method,
441 "part": partition.F9_Partition,
442 "partition": partition.F9_Partition,
443 "poweroff": reboot.FC6_Reboot,
444 "raid": raid.F9_Raid,
445 "reboot": reboot.FC6_Reboot,
446 "repo": repo.F8_Repo,
447 "rescue": rescue.F10_Rescue,
448 "rootpw": rootpw.F8_RootPw,
449 "selinux": selinux.FC3_SELinux,
450 "services": services.FC6_Services,
451 "shutdown": reboot.FC6_Reboot,
452 "skipx": skipx.FC3_SkipX,
453 "text": displaymode.FC3_DisplayMode,
454 "timezone": timezone.FC6_Timezone,
455 "updates": updates.F7_Updates,
456 "upgrade": upgrade.FC3_Upgrade,
457 "url": method.FC6_Method,
458 "user": user.F8_User,
459 "vnc": vnc.F9_Vnc,
460 "volgroup": volgroup.FC3_VolGroup,
461 "xconfig": xconfig.F10_XConfig,
462 "zerombr": zerombr.F9_ZeroMbr,
463 "zfcp": zfcp.FC3_ZFCP,
464 },
465
466 # based on f10
467 F11: {
468 "auth": authconfig.FC3_Authconfig,
469 "authconfig": authconfig.FC3_Authconfig,
470 "autopart": autopart.F9_AutoPart,
471 "autostep": autostep.FC3_AutoStep,
472 "bootloader": bootloader.F8_Bootloader,
473 "cdrom": method.FC6_Method,
474 "clearpart": clearpart.FC3_ClearPart,
475 "cmdline": displaymode.FC3_DisplayMode,
476 "device": device.F8_Device,
477 "deviceprobe": deviceprobe.FC3_DeviceProbe,
478 "dmraid": dmraid.FC6_DmRaid,
479 "driverdisk": driverdisk.FC4_DriverDisk,
480 "firewall": firewall.F10_Firewall,
481 "firstboot": firstboot.FC3_Firstboot,
482 "graphical": displaymode.FC3_DisplayMode,
483 "halt": reboot.FC6_Reboot,
484 "harddrive": method.FC6_Method,
485 "ignoredisk": ignoredisk.F8_IgnoreDisk,
486 "install": upgrade.F11_Upgrade,
487 "interactive": interactive.FC3_Interactive,
488 "iscsi": iscsi.F10_Iscsi,
489 "iscsiname": iscsiname.FC6_IscsiName,
490 "keyboard": keyboard.FC3_Keyboard,
491 "lang": lang.FC3_Lang,
492 "logging": logging.FC6_Logging,
493 "logvol": logvol.F9_LogVol,
494 "mediacheck": mediacheck.FC4_MediaCheck,
495 "monitor": monitor.F10_Monitor,
496 "multipath": multipath.FC6_MultiPath,
497 "network": network.F9_Network,
498 "nfs": method.FC6_Method,
499 "part": partition.F11_Partition,
500 "partition": partition.F11_Partition,
501 "poweroff": reboot.FC6_Reboot,
502 "raid": raid.F9_Raid,
503 "reboot": reboot.FC6_Reboot,
504 "repo": repo.F11_Repo,
505 "rescue": rescue.F10_Rescue,
506 "rootpw": rootpw.F8_RootPw,
507 "selinux": selinux.FC3_SELinux,
508 "services": services.FC6_Services,
509 "shutdown": reboot.FC6_Reboot,
510 "skipx": skipx.FC3_SkipX,
511 "text": displaymode.FC3_DisplayMode,
512 "timezone": timezone.FC6_Timezone,
513 "updates": updates.F7_Updates,
514 "upgrade": upgrade.F11_Upgrade,
515 "url": method.FC6_Method,
516 "user": user.F8_User,
517 "vnc": vnc.F9_Vnc,
518 "volgroup": volgroup.FC3_VolGroup,
519 "xconfig": xconfig.F10_XConfig,
520 "zerombr": zerombr.F9_ZeroMbr,
521 "zfcp": zfcp.FC3_ZFCP,
522 },
523
524 # based on f11
525 F12: {
526 "auth": authconfig.FC3_Authconfig,
527 "authconfig": authconfig.FC3_Authconfig,
528 "autopart": autopart.F12_AutoPart,
529 "autostep": autostep.FC3_AutoStep,
530 "bootloader": bootloader.F12_Bootloader,
531 "cdrom": method.FC6_Method,
532 "clearpart": clearpart.FC3_ClearPart,
533 "cmdline": displaymode.FC3_DisplayMode,
534 "device": device.F8_Device,
535 "deviceprobe": deviceprobe.FC3_DeviceProbe,
536 "dmraid": dmraid.FC6_DmRaid,
537 "driverdisk": driverdisk.F12_DriverDisk,
538 "fcoe": fcoe.F12_Fcoe,
539 "firewall": firewall.F10_Firewall,
540 "firstboot": firstboot.FC3_Firstboot,
541 "graphical": displaymode.FC3_DisplayMode,
542 "group": group.F12_Group,
543 "halt": reboot.FC6_Reboot,
544 "harddrive": method.FC6_Method,
545 "ignoredisk": ignoredisk.F8_IgnoreDisk,
546 "install": upgrade.F11_Upgrade,
547 "interactive": interactive.FC3_Interactive,
548 "iscsi": iscsi.F10_Iscsi,
549 "iscsiname": iscsiname.FC6_IscsiName,
550 "keyboard": keyboard.FC3_Keyboard,
551 "lang": lang.FC3_Lang,
552 "logging": logging.FC6_Logging,
553 "logvol": logvol.F12_LogVol,
554 "mediacheck": mediacheck.FC4_MediaCheck,
555 "monitor": monitor.F10_Monitor,
556 "multipath": multipath.FC6_MultiPath,
557 "network": network.F9_Network,
558 "nfs": method.FC6_Method,
559 "part": partition.F12_Partition,
560 "partition": partition.F12_Partition,
561 "poweroff": reboot.FC6_Reboot,
562 "raid": raid.F12_Raid,
563 "reboot": reboot.FC6_Reboot,
564 "repo": repo.F11_Repo,
565 "rescue": rescue.F10_Rescue,
566 "rootpw": rootpw.F8_RootPw,
567 "selinux": selinux.FC3_SELinux,
568 "services": services.FC6_Services,
569 "shutdown": reboot.FC6_Reboot,
570 "skipx": skipx.FC3_SkipX,
571 "text": displaymode.FC3_DisplayMode,
572 "timezone": timezone.FC6_Timezone,
573 "updates": updates.F7_Updates,
574 "upgrade": upgrade.F11_Upgrade,
575 "url": method.FC6_Method,
576 "user": user.F12_User,
577 "vnc": vnc.F9_Vnc,
578 "volgroup": volgroup.FC3_VolGroup,
579 "xconfig": xconfig.F10_XConfig,
580 "zerombr": zerombr.F9_ZeroMbr,
581 "zfcp": zfcp.F12_ZFCP,
582 },
583
584 # based on f12
585 F13: {
586 "auth": authconfig.FC3_Authconfig,
587 "authconfig": authconfig.FC3_Authconfig,
588 "autopart": autopart.F12_AutoPart,
589 "autostep": autostep.FC3_AutoStep,
590 "bootloader": bootloader.F12_Bootloader,
591 "cdrom": method.F13_Method,
592 "clearpart": clearpart.FC3_ClearPart,
593 "cmdline": displaymode.FC3_DisplayMode,
594 "device": device.F8_Device,
595 "deviceprobe": deviceprobe.FC3_DeviceProbe,
596 "dmraid": dmraid.FC6_DmRaid,
597 "driverdisk": driverdisk.F12_DriverDisk,
598 "fcoe": fcoe.F13_Fcoe,
599 "firewall": firewall.F10_Firewall,
600 "firstboot": firstboot.FC3_Firstboot,
601 "graphical": displaymode.FC3_DisplayMode,
602 "group": group.F12_Group,
603 "halt": reboot.FC6_Reboot,
604 "harddrive": method.F13_Method,
605 "ignoredisk": ignoredisk.F8_IgnoreDisk,
606 "install": upgrade.F11_Upgrade,
607 "interactive": interactive.FC3_Interactive,
608 "iscsi": iscsi.F10_Iscsi,
609 "iscsiname": iscsiname.FC6_IscsiName,
610 "keyboard": keyboard.FC3_Keyboard,
611 "lang": lang.FC3_Lang,
612 "logging": logging.FC6_Logging,
613 "logvol": logvol.F12_LogVol,
614 "mediacheck": mediacheck.FC4_MediaCheck,
615 "monitor": monitor.F10_Monitor,
616 "multipath": multipath.FC6_MultiPath,
617 "network": network.F9_Network,
618 "nfs": method.F13_Method,
619 "part": partition.F12_Partition,
620 "partition": partition.F12_Partition,
621 "poweroff": reboot.FC6_Reboot,
622 "raid": raid.F13_Raid,
623 "reboot": reboot.FC6_Reboot,
624 "repo": repo.F13_Repo,
625 "rescue": rescue.F10_Rescue,
626 "rootpw": rootpw.F8_RootPw,
627 "selinux": selinux.FC3_SELinux,
628 "services": services.FC6_Services,
629 "shutdown": reboot.FC6_Reboot,
630 "skipx": skipx.FC3_SkipX,
631 "sshpw": sshpw.F13_SshPw,
632 "text": displaymode.FC3_DisplayMode,
633 "timezone": timezone.FC6_Timezone,
634 "updates": updates.F7_Updates,
635 "upgrade": upgrade.F11_Upgrade,
636 "url": method.F13_Method,
637 "user": user.F12_User,
638 "vnc": vnc.F9_Vnc,
639 "volgroup": volgroup.FC3_VolGroup,
640 "xconfig": xconfig.F10_XConfig,
641 "zerombr": zerombr.F9_ZeroMbr,
642 "zfcp": zfcp.F12_ZFCP,
643 },
644
645 # based on f13
646 F14: {
647 "auth": authconfig.FC3_Authconfig,
648 "authconfig": authconfig.FC3_Authconfig,
649 "autopart": autopart.F12_AutoPart,
650 "autostep": autostep.FC3_AutoStep,
651 "bootloader": bootloader.F14_Bootloader,
652 "cdrom": method.F14_Method,
653 "clearpart": clearpart.FC3_ClearPart,
654 "cmdline": displaymode.FC3_DisplayMode,
655 "device": device.F8_Device,
656 "deviceprobe": deviceprobe.FC3_DeviceProbe,
657 "dmraid": dmraid.FC6_DmRaid,
658 "driverdisk": driverdisk.F14_DriverDisk,
659 "fcoe": fcoe.F13_Fcoe,
660 "firewall": firewall.F14_Firewall,
661 "firstboot": firstboot.FC3_Firstboot,
662 "graphical": displaymode.FC3_DisplayMode,
663 "group": group.F12_Group,
664 "halt": reboot.FC6_Reboot,
665 "harddrive": method.F14_Method,
666 "ignoredisk": ignoredisk.F14_IgnoreDisk,
667 "install": upgrade.F11_Upgrade,
668 "interactive": interactive.F14_Interactive,
669 "iscsi": iscsi.F10_Iscsi,
670 "iscsiname": iscsiname.FC6_IscsiName,
671 "keyboard": keyboard.FC3_Keyboard,
672 "lang": lang.FC3_Lang,
673 "logging": logging.FC6_Logging,
674 "logvol": logvol.F14_LogVol,
675 "mediacheck": mediacheck.FC4_MediaCheck,
676 "monitor": monitor.F10_Monitor,
677 "multipath": multipath.FC6_MultiPath,
678 "network": network.F9_Network,
679 "nfs": method.F14_Method,
680 "part": partition.F14_Partition,
681 "partition": partition.F14_Partition,
682 "poweroff": reboot.FC6_Reboot,
683 "raid": raid.F14_Raid,
684 "reboot": reboot.FC6_Reboot,
685 "repo": repo.F14_Repo,
686 "rescue": rescue.F10_Rescue,
687 "rootpw": rootpw.F8_RootPw,
688 "selinux": selinux.FC3_SELinux,
689 "services": services.FC6_Services,
690 "shutdown": reboot.FC6_Reboot,
691 "skipx": skipx.FC3_SkipX,
692 "sshpw": sshpw.F13_SshPw,
693 "text": displaymode.FC3_DisplayMode,
694 "timezone": timezone.FC6_Timezone,
695 "updates": updates.F7_Updates,
696 "upgrade": upgrade.F11_Upgrade,
697 "url": method.F14_Method,
698 "user": user.F12_User,
699 "vnc": vnc.F9_Vnc,
700 "volgroup": volgroup.FC3_VolGroup,
701 "xconfig": xconfig.F14_XConfig,
702 "zerombr": zerombr.F9_ZeroMbr,
703 "zfcp": zfcp.F14_ZFCP,
704 },
705
706 # based on f14
707 F15: {
708 "auth": authconfig.FC3_Authconfig,
709 "authconfig": authconfig.FC3_Authconfig,
710 "autopart": autopart.F12_AutoPart,
711 "autostep": autostep.FC3_AutoStep,
712 "bootloader": bootloader.F15_Bootloader,
713 "cdrom": method.F14_Method,
714 "clearpart": clearpart.FC3_ClearPart,
715 "cmdline": displaymode.FC3_DisplayMode,
716 "device": device.F8_Device,
717 "deviceprobe": deviceprobe.FC3_DeviceProbe,
718 "dmraid": dmraid.FC6_DmRaid,
719 "driverdisk": driverdisk.F14_DriverDisk,
720 "fcoe": fcoe.F13_Fcoe,
721 "firewall": firewall.F14_Firewall,
722 "firstboot": firstboot.FC3_Firstboot,
723 "graphical": displaymode.FC3_DisplayMode,
724 "group": group.F12_Group,
725 "halt": reboot.FC6_Reboot,
726 "harddrive": method.F14_Method,
727 "ignoredisk": ignoredisk.F14_IgnoreDisk,
728 "install": upgrade.F11_Upgrade,
729 "iscsi": iscsi.F10_Iscsi,
730 "iscsiname": iscsiname.FC6_IscsiName,
731 "keyboard": keyboard.FC3_Keyboard,
732 "lang": lang.FC3_Lang,
733 "logging": logging.FC6_Logging,
734 "logvol": logvol.F15_LogVol,
735 "mediacheck": mediacheck.FC4_MediaCheck,
736 "monitor": monitor.F10_Monitor,
737 "multipath": multipath.FC6_MultiPath,
738 "network": network.F9_Network,
739 "nfs": method.F14_Method,
740 "part": partition.F14_Partition,
741 "partition": partition.F14_Partition,
742 "poweroff": reboot.FC6_Reboot,
743 "raid": raid.F15_Raid,
744 "reboot": reboot.FC6_Reboot,
745 "repo": repo.F15_Repo,
746 "rescue": rescue.F10_Rescue,
747 "rootpw": rootpw.F8_RootPw,
748 "selinux": selinux.FC3_SELinux,
749 "services": services.FC6_Services,
750 "shutdown": reboot.FC6_Reboot,
751 "skipx": skipx.FC3_SkipX,
752 "sshpw": sshpw.F13_SshPw,
753 "text": displaymode.FC3_DisplayMode,
754 "timezone": timezone.FC6_Timezone,
755 "updates": updates.F7_Updates,
756 "upgrade": upgrade.F11_Upgrade,
757 "url": method.F14_Method,
758 "user": user.F12_User,
759 "vnc": vnc.F9_Vnc,
760 "volgroup": volgroup.FC3_VolGroup,
761 "xconfig": xconfig.F14_XConfig,
762 "zerombr": zerombr.F9_ZeroMbr,
763 "zfcp": zfcp.F14_ZFCP,
764 },
765
766 # based on f15
767 F16: {
768 "auth": authconfig.FC3_Authconfig,
769 "authconfig": authconfig.FC3_Authconfig,
770 "autopart": autopart.F12_AutoPart,
771 "autostep": autostep.FC3_AutoStep,
772 "bootloader": bootloader.F15_Bootloader,
773 "cdrom": method.F14_Method,
774 "clearpart": clearpart.FC3_ClearPart,
775 "cmdline": displaymode.FC3_DisplayMode,
776 "device": device.F8_Device,
777 "deviceprobe": deviceprobe.FC3_DeviceProbe,
778 "dmraid": dmraid.FC6_DmRaid,
779 "driverdisk": driverdisk.F14_DriverDisk,
780 "fcoe": fcoe.F13_Fcoe,
781 "firewall": firewall.F14_Firewall,
782 "firstboot": firstboot.FC3_Firstboot,
783 "graphical": displaymode.FC3_DisplayMode,
784 "group": group.F12_Group,
785 "halt": reboot.FC6_Reboot,
786 "harddrive": method.F14_Method,
787 "ignoredisk": ignoredisk.F14_IgnoreDisk,
788 "install": upgrade.F11_Upgrade,
789 "iscsi": iscsi.F10_Iscsi,
790 "iscsiname": iscsiname.FC6_IscsiName,
791 "keyboard": keyboard.FC3_Keyboard,
792 "lang": lang.FC3_Lang,
793 "logging": logging.FC6_Logging,
794 "logvol": logvol.F15_LogVol,
795 "mediacheck": mediacheck.FC4_MediaCheck,
796 "monitor": monitor.F10_Monitor,
797 "multipath": multipath.FC6_MultiPath,
798 "network": network.F16_Network,
799 "nfs": method.F14_Method,
800 "part": partition.F14_Partition,
801 "partition": partition.F14_Partition,
802 "poweroff": reboot.FC6_Reboot,
803 "raid": raid.F15_Raid,
804 "reboot": reboot.FC6_Reboot,
805 "repo": repo.F15_Repo,
806 "rescue": rescue.F10_Rescue,
807 "rootpw": rootpw.F8_RootPw,
808 "selinux": selinux.FC3_SELinux,
809 "services": services.FC6_Services,
810 "shutdown": reboot.FC6_Reboot,
811 "skipx": skipx.FC3_SkipX,
812 "sshpw": sshpw.F13_SshPw,
813 "text": displaymode.FC3_DisplayMode,
814 "timezone": timezone.FC6_Timezone,
815 "updates": updates.F7_Updates,
816 "upgrade": upgrade.F11_Upgrade,
817 "url": method.F14_Method,
818 "user": user.F12_User,
819 "vnc": vnc.F9_Vnc,
820 "volgroup": volgroup.FC3_VolGroup,
821 "xconfig": xconfig.F14_XConfig,
822 "zerombr": zerombr.F9_ZeroMbr,
823 "zfcp": zfcp.F14_ZFCP,
824 },
825
826 # based on fc1
827 RHEL3: {
828 "auth": authconfig.FC3_Authconfig,
829 "authconfig": authconfig.FC3_Authconfig,
830 "autopart": autopart.FC3_AutoPart,
831 "autostep": autostep.FC3_AutoStep,
832 "bootloader": bootloader.FC3_Bootloader,
833 "cdrom": method.FC3_Method,
834 "clearpart": clearpart.FC3_ClearPart,
835 "cmdline": displaymode.FC3_DisplayMode,
836 "device": device.FC3_Device,
837 "deviceprobe": deviceprobe.FC3_DeviceProbe,
838 "driverdisk": driverdisk.FC3_DriverDisk,
839 "firewall": firewall.FC3_Firewall,
840 "firstboot": firstboot.FC3_Firstboot,
841 "graphical": displaymode.FC3_DisplayMode,
842 "halt": reboot.FC3_Reboot,
843 "harddrive": method.FC3_Method,
844 "ignoredisk": ignoredisk.FC3_IgnoreDisk,
845 "install": upgrade.FC3_Upgrade,
846 "interactive": interactive.FC3_Interactive,
847 "keyboard": keyboard.FC3_Keyboard,
848 "lang": lang.FC3_Lang,
849 "langsupport": langsupport.FC3_LangSupport,
850 "lilo": bootloader.FC3_Bootloader,
851 "lilocheck": lilocheck.FC3_LiloCheck,
852 "logvol": logvol.FC3_LogVol,
853 "monitor": monitor.FC3_Monitor,
854 "mouse": mouse.RHEL3_Mouse,
855 "network": network.FC3_Network,
856 "nfs": method.FC3_Method,
857 "part": partition.FC3_Partition,
858 "partition": partition.FC3_Partition,
859 "poweroff": reboot.FC3_Reboot,
860 "raid": raid.FC3_Raid,
861 "reboot": reboot.FC3_Reboot,
862 "rootpw": rootpw.FC3_RootPw,
863 "shutdown": reboot.FC3_Reboot,
864 "skipx": skipx.FC3_SkipX,
865 "text": displaymode.FC3_DisplayMode,
866 "timezone": timezone.FC3_Timezone,
867 "upgrade": upgrade.FC3_Upgrade,
868 "url": method.FC3_Method,
869 "vnc": vnc.FC3_Vnc,
870 "volgroup": volgroup.FC3_VolGroup,
871 "xconfig": xconfig.FC3_XConfig,
872 "zerombr": zerombr.FC3_ZeroMbr,
873 },
874
875 # based on fc3
876 RHEL4: {
877 "auth": authconfig.FC3_Authconfig,
878 "authconfig": authconfig.FC3_Authconfig,
879 "autopart": autopart.FC3_AutoPart,
880 "autostep": autostep.FC3_AutoStep,
881 "bootloader": bootloader.FC3_Bootloader,
882 "cdrom": method.FC3_Method,
883 "clearpart": clearpart.FC3_ClearPart,
884 "cmdline": displaymode.FC3_DisplayMode,
885 "device": device.FC3_Device,
886 "deviceprobe": deviceprobe.FC3_DeviceProbe,
887 "driverdisk": driverdisk.FC4_DriverDisk,
888 "firewall": firewall.FC3_Firewall,
889 "firstboot": firstboot.FC3_Firstboot,
890 "graphical": displaymode.FC3_DisplayMode,
891 "halt": reboot.FC3_Reboot,
892 "harddrive": method.FC3_Method,
893 "ignoredisk": ignoredisk.F8_IgnoreDisk,
894 "install": upgrade.FC3_Upgrade,
895 "interactive": interactive.FC3_Interactive,
896 "keyboard": keyboard.FC3_Keyboard,
897 "lang": lang.FC3_Lang,
898 "langsupport": langsupport.FC3_LangSupport,
899 "lilo": bootloader.FC3_Bootloader,
900 "lilocheck": lilocheck.FC3_LiloCheck,
901 "logvol": logvol.FC3_LogVol,
902 "monitor": monitor.FC3_Monitor,
903 "mouse": mouse.FC3_Mouse,
904 "network": network.RHEL4_Network,
905 "nfs": method.FC3_Method,
906 "part": partition.FC3_Partition,
907 "partition": partition.FC3_Partition,
908 "poweroff": reboot.FC3_Reboot,
909 "raid": raid.FC3_Raid,
910 "reboot": reboot.FC3_Reboot,
911 "rootpw": rootpw.FC3_RootPw,
912 "selinux": selinux.FC3_SELinux,
913 "shutdown": reboot.FC3_Reboot,
914 "skipx": skipx.FC3_SkipX,
915 "text": displaymode.FC3_DisplayMode,
916 "timezone": timezone.FC3_Timezone,
917 "upgrade": upgrade.FC3_Upgrade,
918 "url": method.FC3_Method,
919 "vnc": vnc.FC3_Vnc,
920 "volgroup": volgroup.FC3_VolGroup,
921 "xconfig": xconfig.FC3_XConfig,
922 "zerombr": zerombr.FC3_ZeroMbr,
923 "zfcp": zfcp.FC3_ZFCP,
924 },
925
926 # based on fc6
927 RHEL5: {
928 "auth": authconfig.FC3_Authconfig,
929 "authconfig": authconfig.FC3_Authconfig,
930 "autopart": autopart.F9_AutoPart,
931 "autostep": autostep.FC3_AutoStep,
932 "bootloader": bootloader.RHEL5_Bootloader,
933 "cdrom": method.FC6_Method,
934 "clearpart": clearpart.FC3_ClearPart,
935 "cmdline": displaymode.FC3_DisplayMode,
936 "device": device.FC3_Device,
937 "deviceprobe": deviceprobe.FC3_DeviceProbe,
938 "dmraid": dmraid.FC6_DmRaid,
939 "driverdisk": driverdisk.F12_DriverDisk,
940 "firewall": firewall.FC3_Firewall,
941 "firstboot": firstboot.FC3_Firstboot,
942 "graphical": displaymode.FC3_DisplayMode,
943 "halt": reboot.FC6_Reboot,
944 "harddrive": method.FC6_Method,
945 "ignoredisk": ignoredisk.F8_IgnoreDisk,
946 "install": upgrade.FC3_Upgrade,
947 "interactive": interactive.FC3_Interactive,
948 "iscsi": iscsi.FC6_Iscsi,
949 "iscsiname": iscsiname.FC6_IscsiName,
950 "key": key.RHEL5_Key,
951 "keyboard": keyboard.FC3_Keyboard,
952 "lang": lang.FC3_Lang,
953 "langsupport": langsupport.FC5_LangSupport,
954 "logging": logging.FC6_Logging,
955 "logvol": logvol.RHEL5_LogVol,
956 "mediacheck": mediacheck.FC4_MediaCheck,
957 "monitor": monitor.FC6_Monitor,
958 "mouse": mouse.FC3_Mouse,
959 "multipath": multipath.FC6_MultiPath,
960 "network": network.RHEL5_Network,
961 "nfs": method.FC6_Method,
962 "part": partition.RHEL5_Partition,
963 "partition": partition.RHEL5_Partition,
964 "poweroff": reboot.FC6_Reboot,
965 "raid": raid.RHEL5_Raid,
966 "reboot": reboot.FC6_Reboot,
967 "repo": repo.FC6_Repo,
968 "rootpw": rootpw.FC3_RootPw,
969 "services": services.FC6_Services,
970 "selinux": selinux.FC3_SELinux,
971 "shutdown": reboot.FC6_Reboot,
972 "skipx": skipx.FC3_SkipX,
973 "text": displaymode.FC3_DisplayMode,
974 "timezone": timezone.FC6_Timezone,
975 "upgrade": upgrade.FC3_Upgrade,
976 "user": user.FC6_User,
977 "url": method.FC6_Method,
978 "vnc": vnc.FC6_Vnc,
979 "volgroup": volgroup.FC3_VolGroup,
980 "xconfig": xconfig.FC6_XConfig,
981 "zerombr": zerombr.FC3_ZeroMbr,
982 "zfcp": zfcp.FC3_ZFCP,
983 },
984
985 # based on f13ish
986 RHEL6: {
987 "auth": authconfig.FC3_Authconfig,
988 "authconfig": authconfig.FC3_Authconfig,
989 "autopart": autopart.F12_AutoPart,
990 "autostep": autostep.FC3_AutoStep,
991 "bootloader": bootloader.RHEL6_Bootloader,
992 "cdrom": method.RHEL6_Method,
993 "clearpart": clearpart.FC3_ClearPart,
994 "cmdline": displaymode.FC3_DisplayMode,
995 "device": device.F8_Device,
996 "deviceprobe": deviceprobe.FC3_DeviceProbe,
997 "dmraid": dmraid.FC6_DmRaid,
998 "driverdisk": driverdisk.F12_DriverDisk,
999 "fcoe": fcoe.F13_Fcoe,
1000 "firewall": firewall.F10_Firewall,
1001 "firstboot": firstboot.FC3_Firstboot,
1002 "graphical": displaymode.FC3_DisplayMode,
1003 "group": group.F12_Group,
1004 "halt": reboot.FC6_Reboot,
1005 "harddrive": method.RHEL6_Method,
1006 "ignoredisk": ignoredisk.RHEL6_IgnoreDisk,
1007 "install": upgrade.F11_Upgrade,
1008 "interactive": interactive.FC3_Interactive,
1009 "iscsi": iscsi.F10_Iscsi,
1010 "iscsiname": iscsiname.FC6_IscsiName,
1011 "keyboard": keyboard.FC3_Keyboard,
1012 "lang": lang.FC3_Lang,
1013 "logging": logging.FC6_Logging,
1014 "logvol": logvol.F12_LogVol,
1015 "mediacheck": mediacheck.FC4_MediaCheck,
1016 "monitor": monitor.F10_Monitor,
1017 "multipath": multipath.FC6_MultiPath,
1018 "network": network.RHEL6_Network,
1019 "nfs": method.RHEL6_Method,
1020 "part": partition.F12_Partition,
1021 "partition": partition.F12_Partition,
1022 "poweroff": reboot.FC6_Reboot,
1023 "raid": raid.F13_Raid,
1024 "reboot": reboot.FC6_Reboot,
1025 "repo": repo.RHEL6_Repo,
1026 "rescue": rescue.F10_Rescue,
1027 "rootpw": rootpw.F8_RootPw,
1028 "selinux": selinux.FC3_SELinux,
1029 "services": services.FC6_Services,
1030 "shutdown": reboot.FC6_Reboot,
1031 "skipx": skipx.FC3_SkipX,
1032 "sshpw": sshpw.F13_SshPw,
1033 "text": displaymode.FC3_DisplayMode,
1034 "timezone": timezone.FC6_Timezone,
1035 "updates": updates.F7_Updates,
1036 "upgrade": upgrade.F11_Upgrade,
1037 "url": method.RHEL6_Method,
1038 "user": user.F12_User,
1039 "vnc": vnc.F9_Vnc,
1040 "volgroup": volgroup.FC3_VolGroup,
1041 "xconfig": xconfig.F10_XConfig,
1042 "zerombr": zerombr.F9_ZeroMbr,
1043 "zfcp": zfcp.F12_ZFCP,
1044 }
1045}
1046
1047# This map is keyed on kickstart syntax version as provided by
1048# pykickstart.version. Within each sub-dict is a mapping from a data object
1049# name to the class that provides it. This is a bijective mapping - that is,
1050# each name maps to exactly one data class and all data classes have a name.
1051# More than one instance of each class is allowed to exist, however.
1052dataMap = {
1053 FC3: {
1054 "DriverDiskData": driverdisk.FC3_DriverDiskData,
1055 "LogVolData": logvol.FC3_LogVolData,
1056 "NetworkData": network.FC3_NetworkData,
1057 "PartData": partition.FC3_PartData,
1058 "RaidData": raid.FC3_RaidData,
1059 "VolGroupData": volgroup.FC3_VolGroupData,
1060 "ZFCPData": zfcp.FC3_ZFCPData,
1061 },
1062 FC4: {
1063 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1064 "LogVolData": logvol.FC4_LogVolData,
1065 "NetworkData": network.FC4_NetworkData,
1066 "PartData": partition.FC4_PartData,
1067 "RaidData": raid.FC4_RaidData,
1068 "VolGroupData": volgroup.FC3_VolGroupData,
1069 "ZFCPData": zfcp.FC3_ZFCPData,
1070 },
1071 FC5: {
1072 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1073 "LogVolData": logvol.FC4_LogVolData,
1074 "NetworkData": network.FC4_NetworkData,
1075 "PartData": partition.FC4_PartData,
1076 "RaidData": raid.FC5_RaidData,
1077 "VolGroupData": volgroup.FC3_VolGroupData,
1078 "ZFCPData": zfcp.FC3_ZFCPData,
1079 },
1080 FC6: {
1081 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1082 "DmRaidData": dmraid.FC6_DmRaidData,
1083 "IscsiData": iscsi.FC6_IscsiData,
1084 "LogVolData": logvol.FC4_LogVolData,
1085 "MultiPathData": multipath.FC6_MultiPathData,
1086 "NetworkData": network.FC6_NetworkData,
1087 "PartData": partition.FC4_PartData,
1088 "RaidData": raid.FC5_RaidData,
1089 "RepoData": repo.FC6_RepoData,
1090 "UserData": user.FC6_UserData,
1091 "VolGroupData": volgroup.FC3_VolGroupData,
1092 "ZFCPData": zfcp.FC3_ZFCPData,
1093 },
1094 F7: {
1095 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1096 "DmRaidData": dmraid.FC6_DmRaidData,
1097 "IscsiData": iscsi.FC6_IscsiData,
1098 "LogVolData": logvol.FC4_LogVolData,
1099 "MultiPathData": multipath.FC6_MultiPathData,
1100 "NetworkData": network.FC6_NetworkData,
1101 "PartData": partition.FC4_PartData,
1102 "RaidData": raid.F7_RaidData,
1103 "RepoData": repo.FC6_RepoData,
1104 "UserData": user.FC6_UserData,
1105 "VolGroupData": volgroup.FC3_VolGroupData,
1106 "ZFCPData": zfcp.FC3_ZFCPData,
1107 },
1108 F8: {
1109 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1110 "DeviceData": device.F8_DeviceData,
1111 "DmRaidData": dmraid.FC6_DmRaidData,
1112 "IscsiData": iscsi.FC6_IscsiData,
1113 "LogVolData": logvol.FC4_LogVolData,
1114 "MultiPathData": multipath.FC6_MultiPathData,
1115 "NetworkData": network.F8_NetworkData,
1116 "PartData": partition.FC4_PartData,
1117 "RaidData": raid.F7_RaidData,
1118 "RepoData": repo.F8_RepoData,
1119 "UserData": user.F8_UserData,
1120 "VolGroupData": volgroup.FC3_VolGroupData,
1121 "ZFCPData": zfcp.FC3_ZFCPData,
1122 },
1123 F9: {
1124 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1125 "DeviceData": device.F8_DeviceData,
1126 "DmRaidData": dmraid.FC6_DmRaidData,
1127 "IscsiData": iscsi.FC6_IscsiData,
1128 "LogVolData": logvol.F9_LogVolData,
1129 "MultiPathData": multipath.FC6_MultiPathData,
1130 "NetworkData": network.F8_NetworkData,
1131 "PartData": partition.F9_PartData,
1132 "RaidData": raid.F9_RaidData,
1133 "RepoData": repo.F8_RepoData,
1134 "UserData": user.F8_UserData,
1135 "VolGroupData": volgroup.FC3_VolGroupData,
1136 "ZFCPData": zfcp.FC3_ZFCPData,
1137 },
1138 F10: {
1139 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1140 "DeviceData": device.F8_DeviceData,
1141 "DmRaidData": dmraid.FC6_DmRaidData,
1142 "IscsiData": iscsi.F10_IscsiData,
1143 "LogVolData": logvol.F9_LogVolData,
1144 "MultiPathData": multipath.FC6_MultiPathData,
1145 "NetworkData": network.F8_NetworkData,
1146 "PartData": partition.F9_PartData,
1147 "RaidData": raid.F9_RaidData,
1148 "RepoData": repo.F8_RepoData,
1149 "UserData": user.F8_UserData,
1150 "VolGroupData": volgroup.FC3_VolGroupData,
1151 "ZFCPData": zfcp.FC3_ZFCPData,
1152 },
1153 F11: {
1154 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1155 "DeviceData": device.F8_DeviceData,
1156 "DmRaidData": dmraid.FC6_DmRaidData,
1157 "IscsiData": iscsi.F10_IscsiData,
1158 "LogVolData": logvol.F9_LogVolData,
1159 "MultiPathData": multipath.FC6_MultiPathData,
1160 "NetworkData": network.F8_NetworkData,
1161 "PartData": partition.F11_PartData,
1162 "RaidData": raid.F9_RaidData,
1163 "RepoData": repo.F11_RepoData,
1164 "UserData": user.F8_UserData,
1165 "VolGroupData": volgroup.FC3_VolGroupData,
1166 "ZFCPData": zfcp.FC3_ZFCPData,
1167 },
1168 F12: {
1169 "DriverDiskData": driverdisk.F12_DriverDiskData,
1170 "DeviceData": device.F8_DeviceData,
1171 "DmRaidData": dmraid.FC6_DmRaidData,
1172 "FcoeData": fcoe.F12_FcoeData,
1173 "GroupData": group.F12_GroupData,
1174 "IscsiData": iscsi.F10_IscsiData,
1175 "LogVolData": logvol.F12_LogVolData,
1176 "MultiPathData": multipath.FC6_MultiPathData,
1177 "NetworkData": network.F8_NetworkData,
1178 "PartData": partition.F12_PartData,
1179 "RaidData": raid.F12_RaidData,
1180 "RepoData": repo.F11_RepoData,
1181 "UserData": user.F12_UserData,
1182 "VolGroupData": volgroup.FC3_VolGroupData,
1183 "ZFCPData": zfcp.F12_ZFCPData,
1184 },
1185 F13: {
1186 "DriverDiskData": driverdisk.F12_DriverDiskData,
1187 "DeviceData": device.F8_DeviceData,
1188 "DmRaidData": dmraid.FC6_DmRaidData,
1189 "FcoeData": fcoe.F13_FcoeData,
1190 "GroupData": group.F12_GroupData,
1191 "IscsiData": iscsi.F10_IscsiData,
1192 "LogVolData": logvol.F12_LogVolData,
1193 "MultiPathData": multipath.FC6_MultiPathData,
1194 "NetworkData": network.F8_NetworkData,
1195 "PartData": partition.F12_PartData,
1196 "RaidData": raid.F13_RaidData,
1197 "RepoData": repo.F13_RepoData,
1198 "SshPwData": sshpw.F13_SshPwData,
1199 "UserData": user.F12_UserData,
1200 "VolGroupData": volgroup.FC3_VolGroupData,
1201 "ZFCPData": zfcp.F12_ZFCPData,
1202 },
1203 F14: {
1204 "DriverDiskData": driverdisk.F14_DriverDiskData,
1205 "DeviceData": device.F8_DeviceData,
1206 "DmRaidData": dmraid.FC6_DmRaidData,
1207 "FcoeData": fcoe.F13_FcoeData,
1208 "GroupData": group.F12_GroupData,
1209 "IscsiData": iscsi.F10_IscsiData,
1210 "LogVolData": logvol.F14_LogVolData,
1211 "MultiPathData": multipath.FC6_MultiPathData,
1212 "NetworkData": network.F8_NetworkData,
1213 "PartData": partition.F14_PartData,
1214 "RaidData": raid.F14_RaidData,
1215 "RepoData": repo.F14_RepoData,
1216 "SshPwData": sshpw.F13_SshPwData,
1217 "UserData": user.F12_UserData,
1218 "VolGroupData": volgroup.FC3_VolGroupData,
1219 "ZFCPData": zfcp.F14_ZFCPData,
1220 },
1221 F15: {
1222 "DriverDiskData": driverdisk.F14_DriverDiskData,
1223 "DeviceData": device.F8_DeviceData,
1224 "DmRaidData": dmraid.FC6_DmRaidData,
1225 "FcoeData": fcoe.F13_FcoeData,
1226 "GroupData": group.F12_GroupData,
1227 "IscsiData": iscsi.F10_IscsiData,
1228 "LogVolData": logvol.F15_LogVolData,
1229 "MultiPathData": multipath.FC6_MultiPathData,
1230 "NetworkData": network.F8_NetworkData,
1231 "PartData": partition.F14_PartData,
1232 "RaidData": raid.F15_RaidData,
1233 "RepoData": repo.F15_RepoData,
1234 "SshPwData": sshpw.F13_SshPwData,
1235 "UserData": user.F12_UserData,
1236 "VolGroupData": volgroup.FC3_VolGroupData,
1237 "ZFCPData": zfcp.F14_ZFCPData,
1238 },
1239 F16: {
1240 "DriverDiskData": driverdisk.F14_DriverDiskData,
1241 "DeviceData": device.F8_DeviceData,
1242 "DmRaidData": dmraid.FC6_DmRaidData,
1243 "FcoeData": fcoe.F13_FcoeData,
1244 "GroupData": group.F12_GroupData,
1245 "IscsiData": iscsi.F10_IscsiData,
1246 "LogVolData": logvol.F15_LogVolData,
1247 "MultiPathData": multipath.FC6_MultiPathData,
1248 "NetworkData": network.F16_NetworkData,
1249 "PartData": partition.F14_PartData,
1250 "RaidData": raid.F15_RaidData,
1251 "RepoData": repo.F15_RepoData,
1252 "SshPwData": sshpw.F13_SshPwData,
1253 "UserData": user.F12_UserData,
1254 "VolGroupData": volgroup.FC3_VolGroupData,
1255 "ZFCPData": zfcp.F14_ZFCPData,
1256 },
1257 RHEL3: {
1258 "DriverDiskData": driverdisk.FC3_DriverDiskData,
1259 "LogVolData": logvol.FC3_LogVolData,
1260 "NetworkData": network.RHEL4_NetworkData,
1261 "PartData": partition.FC3_PartData,
1262 "RaidData": raid.FC3_RaidData,
1263 "VolGroupData": volgroup.FC3_VolGroupData,
1264 "ZFCPData": zfcp.FC3_ZFCPData,
1265 },
1266 RHEL4: {
1267 "DriverDiskData": driverdisk.FC4_DriverDiskData,
1268 "LogVolData": logvol.FC3_LogVolData,
1269 "NetworkData": network.RHEL4_NetworkData,
1270 "PartData": partition.FC3_PartData,
1271 "RaidData": raid.FC3_RaidData,
1272 "VolGroupData": volgroup.FC3_VolGroupData,
1273 "ZFCPData": zfcp.FC3_ZFCPData,
1274 },
1275 RHEL5: {
1276 "DriverDiskData": driverdisk.F12_DriverDiskData,
1277 "DmRaidData": dmraid.FC6_DmRaidData,
1278 "IscsiData": iscsi.FC6_IscsiData,
1279 "LogVolData": logvol.RHEL5_LogVolData,
1280 "MultiPathData": multipath.FC6_MultiPathData,
1281 "NetworkData": network.FC6_NetworkData,
1282 "PartData": partition.RHEL5_PartData,
1283 "RaidData": raid.RHEL5_RaidData,
1284 "RepoData": repo.FC6_RepoData,
1285 "UserData": user.FC6_UserData,
1286 "VolGroupData": volgroup.FC3_VolGroupData,
1287 "ZFCPData": zfcp.FC3_ZFCPData,
1288 },
1289 RHEL6: {
1290 "DriverDiskData": driverdisk.F12_DriverDiskData,
1291 "DeviceData": device.F8_DeviceData,
1292 "DmRaidData": dmraid.FC6_DmRaidData,
1293 "FcoeData": fcoe.F13_FcoeData,
1294 "GroupData": group.F12_GroupData,
1295 "IscsiData": iscsi.F10_IscsiData,
1296 "LogVolData": logvol.F12_LogVolData,
1297 "MultiPathData": multipath.FC6_MultiPathData,
1298 "NetworkData": network.RHEL6_NetworkData,
1299 "PartData": partition.F12_PartData,
1300 "RaidData": raid.F13_RaidData,
1301 "RepoData": repo.RHEL6_RepoData,
1302 "SshPwData": sshpw.F13_SshPwData,
1303 "UserData": user.F12_UserData,
1304 "VolGroupData": volgroup.FC3_VolGroupData,
1305 "ZFCPData": zfcp.F12_ZFCPData,
1306 }
1307}
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f10.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f10.py
new file mode 100644
index 0000000000..17c8211bbf
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f10.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F10Handler(BaseHandler):
24 version = F10
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f11.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f11.py
new file mode 100644
index 0000000000..d21aee3e8b
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f11.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2008 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F11Handler(BaseHandler):
24 version = F11
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f12.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f12.py
new file mode 100644
index 0000000000..cea3ecef6b
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f12.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F12Handler(BaseHandler):
24 version = F12
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f13.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f13.py
new file mode 100644
index 0000000000..b94c738f79
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f13.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F13Handler(BaseHandler):
24 version = F13
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f14.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f14.py
new file mode 100644
index 0000000000..478f75d15e
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f14.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2010 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F14Handler(BaseHandler):
24 version = F14
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f15.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f15.py
new file mode 100644
index 0000000000..12aecb4c1a
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f15.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2010 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F15Handler(BaseHandler):
24 version = F15
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f16.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f16.py
new file mode 100644
index 0000000000..3c52f8d754
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f16.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2011 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F16Handler(BaseHandler):
24 version = F16
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f7.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f7.py
new file mode 100644
index 0000000000..5e856ea983
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f7.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F7Handler(BaseHandler):
24 version = F7
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f8.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f8.py
new file mode 100644
index 0000000000..1a978810f4
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f8.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F8Handler(BaseHandler):
24 version = F8
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/f9.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/f9.py
new file mode 100644
index 0000000000..116f1b57c9
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/f9.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class F9Handler(BaseHandler):
24 version = F9
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/fc3.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc3.py
new file mode 100644
index 0000000000..a115dc2646
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc3.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class FC3Handler(BaseHandler):
24 version = FC3
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/fc4.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc4.py
new file mode 100644
index 0000000000..fd47b732ef
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc4.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class FC4Handler(BaseHandler):
24 version = FC4
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/fc5.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc5.py
new file mode 100644
index 0000000000..bcdc29d23a
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc5.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class FC5Handler(BaseHandler):
24 version = FC5
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/fc6.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc6.py
new file mode 100644
index 0000000000..c83a929f84
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/fc6.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class FC6Handler(BaseHandler):
24 version = FC6
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel3.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel3.py
new file mode 100644
index 0000000000..131763c2a8
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel3.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class RHEL3Handler(BaseHandler):
24 version = RHEL3
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel4.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel4.py
new file mode 100644
index 0000000000..3496c43ea5
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel4.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class RHEL4Handler(BaseHandler):
24 version = RHEL4
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel5.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel5.py
new file mode 100644
index 0000000000..abb7a8d36c
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel5.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class RHEL5Handler(BaseHandler):
24 version = RHEL5
diff --git a/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel6.py b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel6.py
new file mode 100644
index 0000000000..7202419780
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/handlers/rhel6.py
@@ -0,0 +1,24 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2010 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.version import *
22
23class RHEL6Handler(BaseHandler):
24 version = RHEL6
diff --git a/scripts/lib/mic/3rdparty/pykickstart/ko.py b/scripts/lib/mic/3rdparty/pykickstart/ko.py
new file mode 100644
index 0000000000..1350d19c70
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/ko.py
@@ -0,0 +1,37 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20"""
21Base classes for internal pykickstart use.
22
23The module exports the following important classes:
24
25 KickstartObject - The base class for all classes in pykickstart
26"""
27
28class KickstartObject(object):
29 """The base class for all other classes in pykickstart."""
30 def __init__(self, *args, **kwargs):
31 """Create a new KickstartObject instance. All other classes in
32 pykickstart should be derived from this one. Instance attributes:
33 """
34 pass
35
36 def __str__(self):
37 return ""
diff --git a/scripts/lib/mic/3rdparty/pykickstart/options.py b/scripts/lib/mic/3rdparty/pykickstart/options.py
new file mode 100644
index 0000000000..341c5d7298
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/options.py
@@ -0,0 +1,204 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20"""
21Specialized option handling.
22
23This module exports two classes:
24
25 KSOptionParser - A specialized subclass of OptionParser to be used
26 in BaseHandler subclasses.
27
28 KSOption - A specialized subclass of Option.
29"""
30import warnings
31from copy import copy
32from optparse import *
33
34from constants import *
35from errors import *
36from version import *
37
38import gettext
39_ = lambda x: gettext.ldgettext("pykickstart", x)
40
41class KSOptionParser(OptionParser):
42 """A specialized subclass of optparse.OptionParser to handle extra option
43 attribute checking, work error reporting into the KickstartParseError
44 framework, and to turn off the default help.
45 """
46 def exit(self, status=0, msg=None):
47 pass
48
49 def error(self, msg):
50 if self.lineno != None:
51 raise KickstartParseError, formatErrorMsg(self.lineno, msg=msg)
52 else:
53 raise KickstartParseError, msg
54
55 def keys(self):
56 retval = []
57
58 for opt in self.option_list:
59 if opt not in retval:
60 retval.append(opt.dest)
61
62 return retval
63
64 def _init_parsing_state (self):
65 OptionParser._init_parsing_state(self)
66 self.option_seen = {}
67
68 def check_values (self, values, args):
69 def seen(self, option):
70 return self.option_seen.has_key(option)
71
72 def usedTooNew(self, option):
73 return option.introduced and option.introduced > self.version
74
75 def usedDeprecated(self, option):
76 return option.deprecated
77
78 def usedRemoved(self, option):
79 return option.removed and option.removed <= self.version
80
81 for option in filter(lambda o: isinstance(o, Option), self.option_list):
82 if option.required and not seen(self, option):
83 raise KickstartValueError, formatErrorMsg(self.lineno, _("Option %s is required") % option)
84 elif seen(self, option) and usedTooNew(self, option):
85 mapping = {"option": option, "intro": versionToString(option.introduced),
86 "version": versionToString(self.version)}
87 self.error(_("The %(option)s option was introduced in version %(intro)s, but you are using kickstart syntax version %(version)s.") % mapping)
88 elif seen(self, option) and usedRemoved(self, option):
89 mapping = {"option": option, "removed": versionToString(option.removed),
90 "version": versionToString(self.version)}
91
92 if option.removed == self.version:
93 self.error(_("The %(option)s option is no longer supported.") % mapping)
94 else:
95 self.error(_("The %(option)s option was removed in version %(removed)s, but you are using kickstart syntax version %(version)s.") % mapping)
96 elif seen(self, option) and usedDeprecated(self, option):
97 mapping = {"lineno": self.lineno, "option": option}
98 warnings.warn(_("Ignoring deprecated option on line %(lineno)s: The %(option)s option has been deprecated and no longer has any effect. It may be removed from future releases, which will result in a fatal error from kickstart. Please modify your kickstart file to remove this option.") % mapping, DeprecationWarning)
99
100 return (values, args)
101
102 def parse_args(self, *args, **kwargs):
103 if kwargs.has_key("lineno"):
104 self.lineno = kwargs.pop("lineno")
105
106 return OptionParser.parse_args(self, **kwargs)
107
108 def __init__(self, mapping=None, version=None):
109 """Create a new KSOptionParser instance. Each KickstartCommand
110 subclass should create one instance of KSOptionParser, providing
111 at least the lineno attribute. mapping and version are not required.
112 Instance attributes:
113
114 mapping -- A mapping from option strings to different values.
115 version -- The version of the kickstart syntax we are checking
116 against.
117 """
118 OptionParser.__init__(self, option_class=KSOption,
119 add_help_option=False,
120 conflict_handler="resolve")
121 if mapping is None:
122 self.map = {}
123 else:
124 self.map = mapping
125
126 self.lineno = None
127 self.option_seen = {}
128 self.version = version
129
130def _check_ksboolean(option, opt, value):
131 if value.lower() in ("on", "yes", "true", "1"):
132 return True
133 elif value.lower() in ("off", "no", "false", "0"):
134 return False
135 else:
136 mapping = {"opt": opt, "value": value}
137 raise OptionValueError(_("Option %(opt)s: invalid boolean value: %(value)r") % mapping)
138
139def _check_string(option, opt, value):
140 if len(value) > 2 and value.startswith("--"):
141 mapping = {"opt": opt, "value": value}
142 raise OptionValueError(_("Option %(opt)s: invalid string value: %(value)r") % mapping)
143 else:
144 return value
145
146# Creates a new Option class that supports several new attributes:
147# - required: any option with this attribute must be supplied or an exception
148# is thrown
149# - introduced: the kickstart syntax version that this option first appeared
150# in - an exception will be raised if the option is used and
151# the specified syntax version is less than the value of this
152# attribute
153# - deprecated: the kickstart syntax version that this option was deprecated
154# in - a DeprecationWarning will be thrown if the option is
155# used and the specified syntax version is greater than the
156# value of this attribute
157# - removed: the kickstart syntax version that this option was removed in - an
158# exception will be raised if the option is used and the specified
159# syntax version is greated than the value of this attribute
160# Also creates a new type:
161# - ksboolean: support various kinds of boolean values on an option
162# And two new actions:
163# - map : allows you to define an opt -> val mapping such that dest gets val
164# when opt is seen
165# - map_extend: allows you to define an opt -> [val1, ... valn] mapping such
166# that dest gets a list of vals built up when opt is seen
167class KSOption (Option):
168 ATTRS = Option.ATTRS + ['introduced', 'deprecated', 'removed', 'required']
169 ACTIONS = Option.ACTIONS + ("map", "map_extend",)
170 STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",)
171
172 TYPES = Option.TYPES + ("ksboolean", "string")
173 TYPE_CHECKER = copy(Option.TYPE_CHECKER)
174 TYPE_CHECKER["ksboolean"] = _check_ksboolean
175 TYPE_CHECKER["string"] = _check_string
176
177 def _check_required(self):
178 if self.required and not self.takes_value():
179 raise OptionError(_("Required flag set for option that doesn't take a value"), self)
180
181 # Make sure _check_required() is called from the constructor!
182 CHECK_METHODS = Option.CHECK_METHODS + [_check_required]
183
184 def process (self, opt, value, values, parser):
185 Option.process(self, opt, value, values, parser)
186 parser.option_seen[self] = 1
187
188 # Override default take_action method to handle our custom actions.
189 def take_action(self, action, dest, opt, value, values, parser):
190 if action == "map":
191 values.ensure_value(dest, parser.map[opt.lstrip('-')])
192 elif action == "map_extend":
193 values.ensure_value(dest, []).extend(parser.map[opt.lstrip('-')])
194 else:
195 Option.take_action(self, action, dest, opt, value, values, parser)
196
197 def takes_value(self):
198 # Deprecated options don't take a value.
199 return Option.takes_value(self) and not self.deprecated
200
201 def __init__(self, *args, **kwargs):
202 self.deprecated = False
203 self.required = False
204 Option.__init__(self, *args, **kwargs)
diff --git a/scripts/lib/mic/3rdparty/pykickstart/parser.py b/scripts/lib/mic/3rdparty/pykickstart/parser.py
new file mode 100644
index 0000000000..840a448673
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/parser.py
@@ -0,0 +1,702 @@
1#
2# parser.py: Kickstart file parser.
3#
4# Chris Lumens <clumens@redhat.com>
5#
6# Copyright 2005, 2006, 2007, 2008, 2011 Red Hat, Inc.
7#
8# This copyrighted material is made available to anyone wishing to use, modify,
9# copy, or redistribute it subject to the terms and conditions of the GNU
10# General Public License v.2. This program is distributed in the hope that it
11# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
12# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13# See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 51
17# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
18# trademarks that are incorporated in the source code or documentation are not
19# subject to the GNU General Public License and may only be used or replicated
20# with the express permission of Red Hat, Inc.
21#
22"""
23Main kickstart file processing module.
24
25This module exports several important classes:
26
27 Script - Representation of a single %pre, %post, or %traceback script.
28
29 Packages - Representation of the %packages section.
30
31 KickstartParser - The kickstart file parser state machine.
32"""
33
34from collections import Iterator
35import os
36import shlex
37import sys
38import tempfile
39from copy import copy
40from optparse import *
41from urlgrabber import urlread
42import urlgrabber.grabber as grabber
43
44import constants
45from errors import KickstartError, KickstartParseError, KickstartValueError, formatErrorMsg
46from ko import KickstartObject
47from sections import *
48import version
49
50import gettext
51_ = lambda x: gettext.ldgettext("pykickstart", x)
52
53STATE_END = "end"
54STATE_COMMANDS = "commands"
55
56ver = version.DEVEL
57
58def _preprocessStateMachine (lineIter):
59 l = None
60 lineno = 0
61
62 # Now open an output kickstart file that we are going to write to one
63 # line at a time.
64 (outF, outName) = tempfile.mkstemp("-ks.cfg", "", "/tmp")
65
66 while True:
67 try:
68 l = lineIter.next()
69 except StopIteration:
70 break
71
72 # At the end of the file?
73 if l == "":
74 break
75
76 lineno += 1
77 url = None
78
79 ll = l.strip()
80 if not ll.startswith("%ksappend"):
81 os.write(outF, l)
82 continue
83
84 # Try to pull down the remote file.
85 try:
86 ksurl = ll.split(' ')[1]
87 except:
88 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll)
89
90 try:
91 url = grabber.urlopen(ksurl)
92 except grabber.URLGrabError, e:
93 raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror)
94 else:
95 # Sanity check result. Sometimes FTP doesn't catch a file
96 # is missing.
97 try:
98 if url.size < 1:
99 raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
100 except:
101 raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
102
103 # If that worked, write the remote file to the output kickstart
104 # file in one burst. Then close everything up to get ready to
105 # read ahead in the input file. This allows multiple %ksappend
106 # lines to exist.
107 if url is not None:
108 os.write(outF, url.read())
109 url.close()
110
111 # All done - close the temp file and return its location.
112 os.close(outF)
113 return outName
114
115def preprocessFromString (s):
116 """Preprocess the kickstart file, provided as the string str. This
117 method is currently only useful for handling %ksappend lines,
118 which need to be fetched before the real kickstart parser can be
119 run. Returns the location of the complete kickstart file.
120 """
121 i = iter(s.splitlines(True) + [""])
122 rc = _preprocessStateMachine (i.next)
123 return rc
124
125def preprocessKickstart (f):
126 """Preprocess the kickstart file, given by the filename file. This
127 method is currently only useful for handling %ksappend lines,
128 which need to be fetched before the real kickstart parser can be
129 run. Returns the location of the complete kickstart file.
130 """
131 try:
132 fh = urlopen(f)
133 except grabber.URLGrabError, e:
134 raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
135
136 rc = _preprocessStateMachine (iter(fh.readlines()))
137 fh.close()
138 return rc
139
140class PutBackIterator(Iterator):
141 def __init__(self, iterable):
142 self._iterable = iter(iterable)
143 self._buf = None
144
145 def __iter__(self):
146 return self
147
148 def put(self, s):
149 self._buf = s
150
151 def next(self):
152 if self._buf:
153 retval = self._buf
154 self._buf = None
155 return retval
156 else:
157 return self._iterable.next()
158
159###
160### SCRIPT HANDLING
161###
162class Script(KickstartObject):
163 """A class representing a single kickstart script. If functionality beyond
164 just a data representation is needed (for example, a run method in
165 anaconda), Script may be subclassed. Although a run method is not
166 provided, most of the attributes of Script have to do with running the
167 script. Instances of Script are held in a list by the Version object.
168 """
169 def __init__(self, script, *args , **kwargs):
170 """Create a new Script instance. Instance attributes:
171
172 errorOnFail -- If execution of the script fails, should anaconda
173 stop, display an error, and then reboot without
174 running any other scripts?
175 inChroot -- Does the script execute in anaconda's chroot
176 environment or not?
177 interp -- The program that should be used to interpret this
178 script.
179 lineno -- The line number this script starts on.
180 logfile -- Where all messages from the script should be logged.
181 script -- A string containing all the lines of the script.
182 type -- The type of the script, which can be KS_SCRIPT_* from
183 pykickstart.constants.
184 """
185 KickstartObject.__init__(self, *args, **kwargs)
186 self.script = "".join(script)
187
188 self.interp = kwargs.get("interp", "/bin/sh")
189 self.inChroot = kwargs.get("inChroot", False)
190 self.lineno = kwargs.get("lineno", None)
191 self.logfile = kwargs.get("logfile", None)
192 self.errorOnFail = kwargs.get("errorOnFail", False)
193 self.type = kwargs.get("type", constants.KS_SCRIPT_PRE)
194
195 def __str__(self):
196 """Return a string formatted for output to a kickstart file."""
197 retval = ""
198
199 if self.type == constants.KS_SCRIPT_PRE:
200 retval += '\n%pre'
201 elif self.type == constants.KS_SCRIPT_POST:
202 retval += '\n%post'
203 elif self.type == constants.KS_SCRIPT_TRACEBACK:
204 retval += '\n%traceback'
205
206 if self.interp != "/bin/sh" and self.interp != "":
207 retval += " --interpreter=%s" % self.interp
208 if self.type == constants.KS_SCRIPT_POST and not self.inChroot:
209 retval += " --nochroot"
210 if self.logfile != None:
211 retval += " --logfile %s" % self.logfile
212 if self.errorOnFail:
213 retval += " --erroronfail"
214
215 if self.script.endswith("\n"):
216 if ver >= version.F8:
217 return retval + "\n%s%%end\n" % self.script
218 else:
219 return retval + "\n%s\n" % self.script
220 else:
221 if ver >= version.F8:
222 return retval + "\n%s\n%%end\n" % self.script
223 else:
224 return retval + "\n%s\n" % self.script
225
226
227##
228## PACKAGE HANDLING
229##
230class Group:
231 """A class representing a single group in the %packages section."""
232 def __init__(self, name="", include=constants.GROUP_DEFAULT):
233 """Create a new Group instance. Instance attributes:
234
235 name -- The group's identifier
236 include -- The level of how much of the group should be included.
237 Values can be GROUP_* from pykickstart.constants.
238 """
239 self.name = name
240 self.include = include
241
242 def __str__(self):
243 """Return a string formatted for output to a kickstart file."""
244 if self.include == constants.GROUP_REQUIRED:
245 return "@%s --nodefaults" % self.name
246 elif self.include == constants.GROUP_ALL:
247 return "@%s --optional" % self.name
248 else:
249 return "@%s" % self.name
250
251 def __cmp__(self, other):
252 if self.name < other.name:
253 return -1
254 elif self.name > other.name:
255 return 1
256 return 0
257
258class Packages(KickstartObject):
259 """A class representing the %packages section of the kickstart file."""
260 def __init__(self, *args, **kwargs):
261 """Create a new Packages instance. Instance attributes:
262
263 addBase -- Should the Base group be installed even if it is
264 not specified?
265 default -- Should the default package set be selected?
266 excludedList -- A list of all the packages marked for exclusion in
267 the %packages section, without the leading minus
268 symbol.
269 excludeDocs -- Should documentation in each package be excluded?
270 groupList -- A list of Group objects representing all the groups
271 specified in the %packages section. Names will be
272 stripped of the leading @ symbol.
273 excludedGroupList -- A list of Group objects representing all the
274 groups specified for removal in the %packages
275 section. Names will be stripped of the leading
276 -@ symbols.
277 handleMissing -- If unknown packages are specified in the %packages
278 section, should it be ignored or not? Values can
279 be KS_MISSING_* from pykickstart.constants.
280 packageList -- A list of all the packages specified in the
281 %packages section.
282 instLangs -- A list of languages to install.
283 """
284 KickstartObject.__init__(self, *args, **kwargs)
285
286 self.addBase = True
287 self.default = False
288 self.excludedList = []
289 self.excludedGroupList = []
290 self.excludeDocs = False
291 self.groupList = []
292 self.handleMissing = constants.KS_MISSING_PROMPT
293 self.packageList = []
294 self.instLangs = None
295
296 def __str__(self):
297 """Return a string formatted for output to a kickstart file."""
298 pkgs = ""
299
300 if not self.default:
301 grps = self.groupList
302 grps.sort()
303 for grp in grps:
304 pkgs += "%s\n" % grp.__str__()
305
306 p = self.packageList
307 p.sort()
308 for pkg in p:
309 pkgs += "%s\n" % pkg
310
311 grps = self.excludedGroupList
312 grps.sort()
313 for grp in grps:
314 pkgs += "-%s\n" % grp.__str__()
315
316 p = self.excludedList
317 p.sort()
318 for pkg in p:
319 pkgs += "-%s\n" % pkg
320
321 if pkgs == "":
322 return ""
323
324 retval = "\n%packages"
325
326 if self.default:
327 retval += " --default"
328 if self.excludeDocs:
329 retval += " --excludedocs"
330 if not self.addBase:
331 retval += " --nobase"
332 if self.handleMissing == constants.KS_MISSING_IGNORE:
333 retval += " --ignoremissing"
334 if self.instLangs:
335 retval += " --instLangs=%s" % self.instLangs
336
337 if ver >= version.F8:
338 return retval + "\n" + pkgs + "\n%end\n"
339 else:
340 return retval + "\n" + pkgs + "\n"
341
342 def _processGroup (self, line):
343 op = OptionParser()
344 op.add_option("--nodefaults", action="store_true", default=False)
345 op.add_option("--optional", action="store_true", default=False)
346
347 (opts, extra) = op.parse_args(args=line.split())
348
349 if opts.nodefaults and opts.optional:
350 raise KickstartValueError, _("Group cannot specify both --nodefaults and --optional")
351
352 # If the group name has spaces in it, we have to put it back together
353 # now.
354 grp = " ".join(extra)
355
356 if opts.nodefaults:
357 self.groupList.append(Group(name=grp, include=constants.GROUP_REQUIRED))
358 elif opts.optional:
359 self.groupList.append(Group(name=grp, include=constants.GROUP_ALL))
360 else:
361 self.groupList.append(Group(name=grp, include=constants.GROUP_DEFAULT))
362
363 def add (self, pkgList):
364 """Given a list of lines from the input file, strip off any leading
365 symbols and add the result to the appropriate list.
366 """
367 existingExcludedSet = set(self.excludedList)
368 existingPackageSet = set(self.packageList)
369 newExcludedSet = set()
370 newPackageSet = set()
371
372 excludedGroupList = []
373
374 for pkg in pkgList:
375 stripped = pkg.strip()
376
377 if stripped[0] == "@":
378 self._processGroup(stripped[1:])
379 elif stripped[0] == "-":
380 if stripped[1] == "@":
381 excludedGroupList.append(Group(name=stripped[2:]))
382 else:
383 newExcludedSet.add(stripped[1:])
384 else:
385 newPackageSet.add(stripped)
386
387 # Groups have to be excluded in two different ways (note: can't use
388 # sets here because we have to store objects):
389 excludedGroupNames = map(lambda g: g.name, excludedGroupList)
390
391 # First, an excluded group may be cancelling out a previously given
392 # one. This is often the case when using %include. So there we should
393 # just remove the group from the list.
394 self.groupList = filter(lambda g: g.name not in excludedGroupNames, self.groupList)
395
396 # Second, the package list could have included globs which are not
397 # processed by pykickstart. In that case we need to preserve a list of
398 # excluded groups so whatever tool doing package/group installation can
399 # take appropriate action.
400 self.excludedGroupList.extend(excludedGroupList)
401
402 existingPackageSet = (existingPackageSet - newExcludedSet) | newPackageSet
403 existingExcludedSet = (existingExcludedSet - existingPackageSet) | newExcludedSet
404
405 self.packageList = list(existingPackageSet)
406 self.excludedList = list(existingExcludedSet)
407
408
409###
410### PARSER
411###
412class KickstartParser:
413 """The kickstart file parser class as represented by a basic state
414 machine. To create a specialized parser, make a subclass and override
415 any of the methods you care about. Methods that don't need to do
416 anything may just pass. However, _stateMachine should never be
417 overridden.
418 """
419 def __init__ (self, handler, followIncludes=True, errorsAreFatal=True,
420 missingIncludeIsFatal=True):
421 """Create a new KickstartParser instance. Instance attributes:
422
423 errorsAreFatal -- Should errors cause processing to halt, or
424 just print a message to the screen? This
425 is most useful for writing syntax checkers
426 that may want to continue after an error is
427 encountered.
428 followIncludes -- If %include is seen, should the included
429 file be checked as well or skipped?
430 handler -- An instance of a BaseHandler subclass. If
431 None, the input file will still be parsed
432 but no data will be saved and no commands
433 will be executed.
434 missingIncludeIsFatal -- Should missing include files be fatal, even
435 if errorsAreFatal is False?
436 """
437 self.errorsAreFatal = errorsAreFatal
438 self.followIncludes = followIncludes
439 self.handler = handler
440 self.currentdir = {}
441 self.missingIncludeIsFatal = missingIncludeIsFatal
442
443 self._state = STATE_COMMANDS
444 self._includeDepth = 0
445 self._line = ""
446
447 self.version = self.handler.version
448
449 global ver
450 ver = self.version
451
452 self._sections = {}
453 self.setupSections()
454
455 def _reset(self):
456 """Reset the internal variables of the state machine for a new kickstart file."""
457 self._state = STATE_COMMANDS
458 self._includeDepth = 0
459
460 def getSection(self, s):
461 """Return a reference to the requested section (s must start with '%'s),
462 or raise KeyError if not found.
463 """
464 return self._sections[s]
465
466 def handleCommand (self, lineno, args):
467 """Given the list of command and arguments, call the Version's
468 dispatcher method to handle the command. Returns the command or
469 data object returned by the dispatcher. This method may be
470 overridden in a subclass if necessary.
471 """
472 if self.handler:
473 self.handler.currentCmd = args[0]
474 self.handler.currentLine = self._line
475 retval = self.handler.dispatcher(args, lineno)
476
477 return retval
478
479 def registerSection(self, obj):
480 """Given an instance of a Section subclass, register the new section
481 with the parser. Calling this method means the parser will
482 recognize your new section and dispatch into the given object to
483 handle it.
484 """
485 if not obj.sectionOpen:
486 raise TypeError, "no sectionOpen given for section %s" % obj
487
488 if not obj.sectionOpen.startswith("%"):
489 raise TypeError, "section %s tag does not start with a %%" % obj.sectionOpen
490
491 self._sections[obj.sectionOpen] = obj
492
493 def _finalize(self, obj):
494 """Called at the close of a kickstart section to take any required
495 actions. Internally, this is used to add scripts once we have the
496 whole body read.
497 """
498 obj.finalize()
499 self._state = STATE_COMMANDS
500
501 def _handleSpecialComments(self, line):
502 """Kickstart recognizes a couple special comments."""
503 if self._state != STATE_COMMANDS:
504 return
505
506 # Save the platform for s-c-kickstart.
507 if line[:10] == "#platform=":
508 self.handler.platform = self._line[11:]
509
510 def _readSection(self, lineIter, lineno):
511 obj = self._sections[self._state]
512
513 while True:
514 try:
515 line = lineIter.next()
516 if line == "":
517 # This section ends at the end of the file.
518 if self.version >= version.F8:
519 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end."))
520
521 self._finalize(obj)
522 except StopIteration:
523 break
524
525 lineno += 1
526
527 # Throw away blank lines and comments, unless the section wants all
528 # lines.
529 if self._isBlankOrComment(line) and not obj.allLines:
530 continue
531
532 if line.startswith("%"):
533 args = shlex.split(line)
534
535 if args and args[0] == "%end":
536 # This is a properly terminated section.
537 self._finalize(obj)
538 break
539 elif args and args[0] == "%ksappend":
540 continue
541 elif args and (self._validState(args[0]) or args[0] in ["%include", "%ksappend"]):
542 # This is an unterminated section.
543 if self.version >= version.F8:
544 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Section does not end with %%end."))
545
546 # Finish up. We do not process the header here because
547 # kicking back out to STATE_COMMANDS will ensure that happens.
548 lineIter.put(line)
549 lineno -= 1
550 self._finalize(obj)
551 break
552 else:
553 # This is just a line within a section. Pass it off to whatever
554 # section handles it.
555 obj.handleLine(line)
556
557 return lineno
558
559 def _validState(self, st):
560 """Is the given section tag one that has been registered with the parser?"""
561 return st in self._sections.keys()
562
563 def _tryFunc(self, fn):
564 """Call the provided function (which doesn't take any arguments) and
565 do the appropriate error handling. If errorsAreFatal is False, this
566 function will just print the exception and keep going.
567 """
568 try:
569 fn()
570 except Exception, msg:
571 if self.errorsAreFatal:
572 raise
573 else:
574 print msg
575
576 def _isBlankOrComment(self, line):
577 return line.isspace() or line == "" or line.lstrip()[0] == '#'
578
579 def _stateMachine(self, lineIter):
580 # For error reporting.
581 lineno = 0
582
583 while True:
584 # Get the next line out of the file, quitting if this is the last line.
585 try:
586 self._line = lineIter.next()
587 if self._line == "":
588 break
589 except StopIteration:
590 break
591
592 lineno += 1
593
594 # Eliminate blank lines, whitespace-only lines, and comments.
595 if self._isBlankOrComment(self._line):
596 self._handleSpecialComments(self._line)
597 continue
598
599 # Remove any end-of-line comments.
600 sanitized = self._line.split("#")[0]
601
602 # Then split the line.
603 args = shlex.split(sanitized.rstrip())
604
605 if args[0] == "%include":
606 # This case comes up primarily in ksvalidator.
607 if not self.followIncludes:
608 continue
609
610 if len(args) == 1 or not args[1]:
611 raise KickstartParseError, formatErrorMsg(lineno)
612
613 self._includeDepth += 1
614
615 try:
616 self.readKickstart(args[1], reset=False)
617 except KickstartError:
618 # Handle the include file being provided over the
619 # network in a %pre script. This case comes up in the
620 # early parsing in anaconda.
621 if self.missingIncludeIsFatal:
622 raise
623
624 self._includeDepth -= 1
625 continue
626
627 # Now on to the main event.
628 if self._state == STATE_COMMANDS:
629 if args[0] == "%ksappend":
630 # This is handled by the preprocess* functions, so continue.
631 continue
632 elif args[0][0] == '%':
633 # This is the beginning of a new section. Handle its header
634 # here.
635 newSection = args[0]
636 if not self._validState(newSection):
637 raise KickstartParseError, formatErrorMsg(lineno, msg=_("Unknown kickstart section: %s" % newSection))
638
639 self._state = newSection
640 obj = self._sections[self._state]
641 self._tryFunc(lambda: obj.handleHeader(lineno, args))
642
643 # This will handle all section processing, kicking us back
644 # out to STATE_COMMANDS at the end with the current line
645 # being the next section header, etc.
646 lineno = self._readSection(lineIter, lineno)
647 else:
648 # This is a command in the command section. Dispatch to it.
649 self._tryFunc(lambda: self.handleCommand(lineno, args))
650 elif self._state == STATE_END:
651 break
652
653 def readKickstartFromString (self, s, reset=True):
654 """Process a kickstart file, provided as the string str."""
655 if reset:
656 self._reset()
657
658 # Add a "" to the end of the list so the string reader acts like the
659 # file reader and we only get StopIteration when we're after the final
660 # line of input.
661 i = PutBackIterator(s.splitlines(True) + [""])
662 self._stateMachine (i)
663
664 def readKickstart(self, f, reset=True):
665 """Process a kickstart file, given by the filename f."""
666 if reset:
667 self._reset()
668
669 # an %include might not specify a full path. if we don't try to figure
670 # out what the path should have been, then we're unable to find it
671 # requiring full path specification, though, sucks. so let's make
672 # the reading "smart" by keeping track of what the path is at each
673 # include depth.
674 if not os.path.exists(f):
675 if self.currentdir.has_key(self._includeDepth - 1):
676 if os.path.exists(os.path.join(self.currentdir[self._includeDepth - 1], f)):
677 f = os.path.join(self.currentdir[self._includeDepth - 1], f)
678
679 cd = os.path.dirname(f)
680 if not cd.startswith("/"):
681 cd = os.path.abspath(cd)
682 self.currentdir[self._includeDepth] = cd
683
684 try:
685 s = urlread(f)
686 except grabber.URLGrabError, e:
687 raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
688
689 self.readKickstartFromString(s, reset=False)
690
691 def setupSections(self):
692 """Install the sections all kickstart files support. You may override
693 this method in a subclass, but should avoid doing so unless you know
694 what you're doing.
695 """
696 self._sections = {}
697
698 # Install the sections all kickstart files support.
699 self.registerSection(PreScriptSection(self.handler, dataObj=Script))
700 self.registerSection(PostScriptSection(self.handler, dataObj=Script))
701 self.registerSection(TracebackScriptSection(self.handler, dataObj=Script))
702 self.registerSection(PackageSection(self.handler))
diff --git a/scripts/lib/mic/3rdparty/pykickstart/sections.py b/scripts/lib/mic/3rdparty/pykickstart/sections.py
new file mode 100644
index 0000000000..44df856b8d
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/sections.py
@@ -0,0 +1,244 @@
1#
2# sections.py: Kickstart file sections.
3#
4# Chris Lumens <clumens@redhat.com>
5#
6# Copyright 2011 Red Hat, Inc.
7#
8# This copyrighted material is made available to anyone wishing to use, modify,
9# copy, or redistribute it subject to the terms and conditions of the GNU
10# General Public License v.2. This program is distributed in the hope that it
11# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
12# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13# See the GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License along with
16# this program; if not, write to the Free Software Foundation, Inc., 51
17# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
18# trademarks that are incorporated in the source code or documentation are not
19# subject to the GNU General Public License and may only be used or replicated
20# with the express permission of Red Hat, Inc.
21#
22"""
23This module exports the classes that define a section of a kickstart file. A
24section is a chunk of the file starting with a %tag and ending with a %end.
25Examples of sections include %packages, %pre, and %post.
26
27You may use this module to define your own custom sections which will be
28treated just the same as a predefined one by the kickstart parser. All that
29is necessary is to create a new subclass of Section and call
30parser.registerSection with an instance of your new class.
31"""
32from constants import *
33from options import KSOptionParser
34from version import *
35
36class Section(object):
37 """The base class for defining kickstart sections. You are free to
38 subclass this as appropriate.
39
40 Class attributes:
41
42 allLines -- Does this section require the parser to call handleLine
43 for every line in the section, even blanks and comments?
44 sectionOpen -- The string that denotes the start of this section. You
45 must start your tag with a percent sign.
46 timesSeen -- This attribute is for informational purposes only. It is
47 incremented every time handleHeader is called to keep
48 track of the number of times a section of this type is
49 seen.
50 """
51 allLines = False
52 sectionOpen = ""
53 timesSeen = 0
54
55 def __init__(self, handler, **kwargs):
56 """Create a new Script instance. At the least, you must pass in an
57 instance of a baseHandler subclass.
58
59 Valid kwargs:
60
61 dataObj --
62 """
63 self.handler = handler
64
65 self.version = self.handler.version
66
67 self.dataObj = kwargs.get("dataObj", None)
68
69 def finalize(self):
70 """This method is called when the %end tag for a section is seen. It
71 is not required to be provided.
72 """
73 pass
74
75 def handleLine(self, line):
76 """This method is called for every line of a section. Take whatever
77 action is appropriate. While this method is not required to be
78 provided, not providing it does not make a whole lot of sense.
79
80 Arguments:
81
82 line -- The complete line, with any trailing newline.
83 """
84 pass
85
86 def handleHeader(self, lineno, args):
87 """This method is called when the opening tag for a section is seen.
88 Not all sections will need this method, though all provided with
89 kickstart include one.
90
91 Arguments:
92
93 args -- A list of all strings passed as arguments to the section
94 opening tag.
95 """
96 self.timesSeen += 1
97
98class NullSection(Section):
99 """This defines a section that pykickstart will recognize but do nothing
100 with. If the parser runs across a %section that has no object registered,
101 it will raise an error. Sometimes, you may want to simply ignore those
102 sections instead. This class is useful for that purpose.
103 """
104 def __init__(self, *args, **kwargs):
105 """Create a new NullSection instance. You must pass a sectionOpen
106 parameter (including a leading '%') for the section you wish to
107 ignore.
108 """
109 Section.__init__(self, *args, **kwargs)
110 self.sectionOpen = kwargs.get("sectionOpen")
111
112class ScriptSection(Section):
113 allLines = True
114
115 def __init__(self, *args, **kwargs):
116 Section.__init__(self, *args, **kwargs)
117 self._script = {}
118 self._resetScript()
119
120 def _getParser(self):
121 op = KSOptionParser(self.version)
122 op.add_option("--erroronfail", dest="errorOnFail", action="store_true",
123 default=False)
124 op.add_option("--interpreter", dest="interpreter", default="/bin/sh")
125 op.add_option("--log", "--logfile", dest="log")
126 return op
127
128 def _resetScript(self):
129 self._script = {"interp": "/bin/sh", "log": None, "errorOnFail": False,
130 "lineno": None, "chroot": False, "body": []}
131
132 def handleLine(self, line):
133 self._script["body"].append(line)
134
135 def finalize(self):
136 if " ".join(self._script["body"]).strip() == "":
137 return
138
139 kwargs = {"interp": self._script["interp"],
140 "inChroot": self._script["chroot"],
141 "lineno": self._script["lineno"],
142 "logfile": self._script["log"],
143 "errorOnFail": self._script["errorOnFail"],
144 "type": self._script["type"]}
145
146 s = self.dataObj (self._script["body"], **kwargs)
147 self._resetScript()
148
149 if self.handler:
150 self.handler.scripts.append(s)
151
152 def handleHeader(self, lineno, args):
153 """Process the arguments to a %pre/%post/%traceback header for later
154 setting on a Script instance once the end of the script is found.
155 This method may be overridden in a subclass if necessary.
156 """
157 Section.handleHeader(self, lineno, args)
158 op = self._getParser()
159
160 (opts, extra) = op.parse_args(args=args[1:], lineno=lineno)
161
162 self._script["interp"] = opts.interpreter
163 self._script["lineno"] = lineno
164 self._script["log"] = opts.log
165 self._script["errorOnFail"] = opts.errorOnFail
166 if hasattr(opts, "nochroot"):
167 self._script["chroot"] = not opts.nochroot
168
169class PreScriptSection(ScriptSection):
170 sectionOpen = "%pre"
171
172 def _resetScript(self):
173 ScriptSection._resetScript(self)
174 self._script["type"] = KS_SCRIPT_PRE
175
176class PostScriptSection(ScriptSection):
177 sectionOpen = "%post"
178
179 def _getParser(self):
180 op = ScriptSection._getParser(self)
181 op.add_option("--nochroot", dest="nochroot", action="store_true",
182 default=False)
183 return op
184
185 def _resetScript(self):
186 ScriptSection._resetScript(self)
187 self._script["chroot"] = True
188 self._script["type"] = KS_SCRIPT_POST
189
190class TracebackScriptSection(ScriptSection):
191 sectionOpen = "%traceback"
192
193 def _resetScript(self):
194 ScriptSection._resetScript(self)
195 self._script["type"] = KS_SCRIPT_TRACEBACK
196
197class PackageSection(Section):
198 sectionOpen = "%packages"
199
200 def handleLine(self, line):
201 if not self.handler:
202 return
203
204 (h, s, t) = line.partition('#')
205 line = h.rstrip()
206
207 self.handler.packages.add([line])
208
209 def handleHeader(self, lineno, args):
210 """Process the arguments to the %packages header and set attributes
211 on the Version's Packages instance appropriate. This method may be
212 overridden in a subclass if necessary.
213 """
214 Section.handleHeader(self, lineno, args)
215 op = KSOptionParser(version=self.version)
216 op.add_option("--excludedocs", dest="excludedocs", action="store_true",
217 default=False)
218 op.add_option("--ignoremissing", dest="ignoremissing",
219 action="store_true", default=False)
220 op.add_option("--nobase", dest="nobase", action="store_true",
221 default=False)
222 op.add_option("--ignoredeps", dest="resolveDeps", action="store_false",
223 deprecated=FC4, removed=F9)
224 op.add_option("--resolvedeps", dest="resolveDeps", action="store_true",
225 deprecated=FC4, removed=F9)
226 op.add_option("--default", dest="defaultPackages", action="store_true",
227 default=False, introduced=F7)
228 op.add_option("--instLangs", dest="instLangs", type="string",
229 default="", introduced=F9)
230
231 (opts, extra) = op.parse_args(args=args[1:], lineno=lineno)
232
233 self.handler.packages.excludeDocs = opts.excludedocs
234 self.handler.packages.addBase = not opts.nobase
235 if opts.ignoremissing:
236 self.handler.packages.handleMissing = KS_MISSING_IGNORE
237 else:
238 self.handler.packages.handleMissing = KS_MISSING_PROMPT
239
240 if opts.defaultPackages:
241 self.handler.packages.default = True
242
243 if opts.instLangs:
244 self.handler.packages.instLangs = opts.instLangs
diff --git a/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/__init__.py b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/__init__.py
new file mode 100644
index 0000000000..7bcd9d5541
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/__init__.py
@@ -0,0 +1,53 @@
1# This program is free software; you can redistribute it and/or modify
2# it under the terms of the GNU General Public License as published by
3# the Free Software Foundation; either version 2 of the License, or
4# (at your option) any later version.
5#
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU Library General Public License for more details.
10#
11# You should have received a copy of the GNU General Public License
12# along with this program; if not, write to the Free Software
13# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
14
15# Copyright 2002-2006 Michael D. Stenner, Ryan Tomayko
16
17# $Id: __init__.py,v 1.20 2006/09/22 00:58:55 mstenner Exp $
18
19"""A high-level cross-protocol url-grabber.
20
21Using urlgrabber, data can be fetched in three basic ways:
22
23 urlgrab(url) copy the file to the local filesystem
24 urlopen(url) open the remote file and return a file object
25 (like urllib2.urlopen)
26 urlread(url) return the contents of the file as a string
27
28When using these functions (or methods), urlgrabber supports the
29following features:
30
31 * identical behavior for http://, ftp://, and file:// urls
32 * http keepalive - faster downloads of many files by using
33 only a single connection
34 * byte ranges - fetch only a portion of the file
35 * reget - for a urlgrab, resume a partial download
36 * progress meters - the ability to report download progress
37 automatically, even when using urlopen!
38 * throttling - restrict bandwidth usage
39 * retries - automatically retry a download if it fails. The
40 number of retries and failure types are configurable.
41 * authenticated server access for http and ftp
42 * proxy support - support for authenticated http and ftp proxies
43 * mirror groups - treat a list of mirrors as a single source,
44 automatically switching mirrors if there is a failure.
45"""
46
47__version__ = '3.1.0'
48__date__ = '2006/09/21'
49__author__ = 'Michael D. Stenner <mstenner@linux.duke.edu>, ' \
50 'Ryan Tomayko <rtomayko@naeblis.cx>'
51__url__ = 'http://linux.duke.edu/projects/urlgrabber/'
52
53from grabber import urlgrab, urlopen, urlread
diff --git a/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/byterange.py b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/byterange.py
new file mode 100644
index 0000000000..001b4e32d6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/byterange.py
@@ -0,0 +1,463 @@
1# This library is free software; you can redistribute it and/or
2# modify it under the terms of the GNU Lesser General Public
3# License as published by the Free Software Foundation; either
4# version 2.1 of the License, or (at your option) any later version.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the
13# Free Software Foundation, Inc.,
14# 59 Temple Place, Suite 330,
15# Boston, MA 02111-1307 USA
16
17# This file is part of urlgrabber, a high-level cross-protocol url-grabber
18# Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
19
20# $Id: byterange.py,v 1.12 2006/07/20 20:15:58 mstenner Exp $
21
22import os
23import stat
24import urllib
25import urllib2
26import rfc822
27
28DEBUG = None
29
30try:
31 from cStringIO import StringIO
32except ImportError, msg:
33 from StringIO import StringIO
34
35class RangeError(IOError):
36 """Error raised when an unsatisfiable range is requested."""
37 pass
38
39class HTTPRangeHandler(urllib2.BaseHandler):
40 """Handler that enables HTTP Range headers.
41
42 This was extremely simple. The Range header is a HTTP feature to
43 begin with so all this class does is tell urllib2 that the
44 "206 Partial Content" reponse from the HTTP server is what we
45 expected.
46
47 Example:
48 import urllib2
49 import byterange
50
51 range_handler = range.HTTPRangeHandler()
52 opener = urllib2.build_opener(range_handler)
53
54 # install it
55 urllib2.install_opener(opener)
56
57 # create Request and set Range header
58 req = urllib2.Request('http://www.python.org/')
59 req.header['Range'] = 'bytes=30-50'
60 f = urllib2.urlopen(req)
61 """
62
63 def http_error_206(self, req, fp, code, msg, hdrs):
64 # 206 Partial Content Response
65 r = urllib.addinfourl(fp, hdrs, req.get_full_url())
66 r.code = code
67 r.msg = msg
68 return r
69
70 def http_error_416(self, req, fp, code, msg, hdrs):
71 # HTTP's Range Not Satisfiable error
72 raise RangeError('Requested Range Not Satisfiable')
73
74class HTTPSRangeHandler(HTTPRangeHandler):
75 """ Range Header support for HTTPS. """
76
77 def https_error_206(self, req, fp, code, msg, hdrs):
78 return self.http_error_206(req, fp, code, msg, hdrs)
79
80 def https_error_416(self, req, fp, code, msg, hdrs):
81 self.https_error_416(req, fp, code, msg, hdrs)
82
83class RangeableFileObject:
84 """File object wrapper to enable raw range handling.
85 This was implemented primarilary for handling range
86 specifications for file:// urls. This object effectively makes
87 a file object look like it consists only of a range of bytes in
88 the stream.
89
90 Examples:
91 # expose 10 bytes, starting at byte position 20, from
92 # /etc/aliases.
93 >>> fo = RangeableFileObject(file('/etc/passwd', 'r'), (20,30))
94 # seek seeks within the range (to position 23 in this case)
95 >>> fo.seek(3)
96 # tell tells where your at _within the range_ (position 3 in
97 # this case)
98 >>> fo.tell()
99 # read EOFs if an attempt is made to read past the last
100 # byte in the range. the following will return only 7 bytes.
101 >>> fo.read(30)
102 """
103
104 def __init__(self, fo, rangetup):
105 """Create a RangeableFileObject.
106 fo -- a file like object. only the read() method need be
107 supported but supporting an optimized seek() is
108 preferable.
109 rangetup -- a (firstbyte,lastbyte) tuple specifying the range
110 to work over.
111 The file object provided is assumed to be at byte offset 0.
112 """
113 self.fo = fo
114 (self.firstbyte, self.lastbyte) = range_tuple_normalize(rangetup)
115 self.realpos = 0
116 self._do_seek(self.firstbyte)
117
118 def __getattr__(self, name):
119 """This effectively allows us to wrap at the instance level.
120 Any attribute not found in _this_ object will be searched for
121 in self.fo. This includes methods."""
122 if hasattr(self.fo, name):
123 return getattr(self.fo, name)
124 raise AttributeError, name
125
126 def tell(self):
127 """Return the position within the range.
128 This is different from fo.seek in that position 0 is the
129 first byte position of the range tuple. For example, if
130 this object was created with a range tuple of (500,899),
131 tell() will return 0 when at byte position 500 of the file.
132 """
133 return (self.realpos - self.firstbyte)
134
135 def seek(self,offset,whence=0):
136 """Seek within the byte range.
137 Positioning is identical to that described under tell().
138 """
139 assert whence in (0, 1, 2)
140 if whence == 0: # absolute seek
141 realoffset = self.firstbyte + offset
142 elif whence == 1: # relative seek
143 realoffset = self.realpos + offset
144 elif whence == 2: # absolute from end of file
145 # XXX: are we raising the right Error here?
146 raise IOError('seek from end of file not supported.')
147
148 # do not allow seek past lastbyte in range
149 if self.lastbyte and (realoffset >= self.lastbyte):
150 realoffset = self.lastbyte
151
152 self._do_seek(realoffset - self.realpos)
153
154 def read(self, size=-1):
155 """Read within the range.
156 This method will limit the size read based on the range.
157 """
158 size = self._calc_read_size(size)
159 rslt = self.fo.read(size)
160 self.realpos += len(rslt)
161 return rslt
162
163 def readline(self, size=-1):
164 """Read lines within the range.
165 This method will limit the size read based on the range.
166 """
167 size = self._calc_read_size(size)
168 rslt = self.fo.readline(size)
169 self.realpos += len(rslt)
170 return rslt
171
172 def _calc_read_size(self, size):
173 """Handles calculating the amount of data to read based on
174 the range.
175 """
176 if self.lastbyte:
177 if size > -1:
178 if ((self.realpos + size) >= self.lastbyte):
179 size = (self.lastbyte - self.realpos)
180 else:
181 size = (self.lastbyte - self.realpos)
182 return size
183
184 def _do_seek(self,offset):
185 """Seek based on whether wrapped object supports seek().
186 offset is relative to the current position (self.realpos).
187 """
188 assert offset >= 0
189 if not hasattr(self.fo, 'seek'):
190 self._poor_mans_seek(offset)
191 else:
192 self.fo.seek(self.realpos + offset)
193 self.realpos+= offset
194
195 def _poor_mans_seek(self,offset):
196 """Seek by calling the wrapped file objects read() method.
197 This is used for file like objects that do not have native
198 seek support. The wrapped objects read() method is called
199 to manually seek to the desired position.
200 offset -- read this number of bytes from the wrapped
201 file object.
202 raise RangeError if we encounter EOF before reaching the
203 specified offset.
204 """
205 pos = 0
206 bufsize = 1024
207 while pos < offset:
208 if (pos + bufsize) > offset:
209 bufsize = offset - pos
210 buf = self.fo.read(bufsize)
211 if len(buf) != bufsize:
212 raise RangeError('Requested Range Not Satisfiable')
213 pos+= bufsize
214
215class FileRangeHandler(urllib2.FileHandler):
216 """FileHandler subclass that adds Range support.
217 This class handles Range headers exactly like an HTTP
218 server would.
219 """
220 def open_local_file(self, req):
221 import mimetypes
222 import mimetools
223 host = req.get_host()
224 file = req.get_selector()
225 localfile = urllib.url2pathname(file)
226 stats = os.stat(localfile)
227 size = stats[stat.ST_SIZE]
228 modified = rfc822.formatdate(stats[stat.ST_MTIME])
229 mtype = mimetypes.guess_type(file)[0]
230 if host:
231 host, port = urllib.splitport(host)
232 if port or socket.gethostbyname(host) not in self.get_names():
233 raise urllib2.URLError('file not on local host')
234 fo = open(localfile,'rb')
235 brange = req.headers.get('Range',None)
236 brange = range_header_to_tuple(brange)
237 assert brange != ()
238 if brange:
239 (fb,lb) = brange
240 if lb == '': lb = size
241 if fb < 0 or fb > size or lb > size:
242 raise RangeError('Requested Range Not Satisfiable')
243 size = (lb - fb)
244 fo = RangeableFileObject(fo, (fb,lb))
245 headers = mimetools.Message(StringIO(
246 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
247 (mtype or 'text/plain', size, modified)))
248 return urllib.addinfourl(fo, headers, 'file:'+file)
249
250
251# FTP Range Support
252# Unfortunately, a large amount of base FTP code had to be copied
253# from urllib and urllib2 in order to insert the FTP REST command.
254# Code modifications for range support have been commented as
255# follows:
256# -- range support modifications start/end here
257
258from urllib import splitport, splituser, splitpasswd, splitattr, \
259 unquote, addclosehook, addinfourl
260import ftplib
261import socket
262import sys
263import ftplib
264import mimetypes
265import mimetools
266
267class FTPRangeHandler(urllib2.FTPHandler):
268 def ftp_open(self, req):
269 host = req.get_host()
270 if not host:
271 raise IOError, ('ftp error', 'no host given')
272 host, port = splitport(host)
273 if port is None:
274 port = ftplib.FTP_PORT
275
276 # username/password handling
277 user, host = splituser(host)
278 if user:
279 user, passwd = splitpasswd(user)
280 else:
281 passwd = None
282 host = unquote(host)
283 user = unquote(user or '')
284 passwd = unquote(passwd or '')
285
286 try:
287 host = socket.gethostbyname(host)
288 except socket.error, msg:
289 raise urllib2.URLError(msg)
290 path, attrs = splitattr(req.get_selector())
291 dirs = path.split('/')
292 dirs = map(unquote, dirs)
293 dirs, file = dirs[:-1], dirs[-1]
294 if dirs and not dirs[0]:
295 dirs = dirs[1:]
296 try:
297 fw = self.connect_ftp(user, passwd, host, port, dirs)
298 type = file and 'I' or 'D'
299 for attr in attrs:
300 attr, value = splitattr(attr)
301 if attr.lower() == 'type' and \
302 value in ('a', 'A', 'i', 'I', 'd', 'D'):
303 type = value.upper()
304
305 # -- range support modifications start here
306 rest = None
307 range_tup = range_header_to_tuple(req.headers.get('Range',None))
308 assert range_tup != ()
309 if range_tup:
310 (fb,lb) = range_tup
311 if fb > 0: rest = fb
312 # -- range support modifications end here
313
314 fp, retrlen = fw.retrfile(file, type, rest)
315
316 # -- range support modifications start here
317 if range_tup:
318 (fb,lb) = range_tup
319 if lb == '':
320 if retrlen is None or retrlen == 0:
321 raise RangeError('Requested Range Not Satisfiable due to unobtainable file length.')
322 lb = retrlen
323 retrlen = lb - fb
324 if retrlen < 0:
325 # beginning of range is larger than file
326 raise RangeError('Requested Range Not Satisfiable')
327 else:
328 retrlen = lb - fb
329 fp = RangeableFileObject(fp, (0,retrlen))
330 # -- range support modifications end here
331
332 headers = ""
333 mtype = mimetypes.guess_type(req.get_full_url())[0]
334 if mtype:
335 headers += "Content-Type: %s\n" % mtype
336 if retrlen is not None and retrlen >= 0:
337 headers += "Content-Length: %d\n" % retrlen
338 sf = StringIO(headers)
339 headers = mimetools.Message(sf)
340 return addinfourl(fp, headers, req.get_full_url())
341 except ftplib.all_errors, msg:
342 raise IOError, ('ftp error', msg), sys.exc_info()[2]
343
344 def connect_ftp(self, user, passwd, host, port, dirs):
345 fw = ftpwrapper(user, passwd, host, port, dirs)
346 return fw
347
348class ftpwrapper(urllib.ftpwrapper):
349 # range support note:
350 # this ftpwrapper code is copied directly from
351 # urllib. The only enhancement is to add the rest
352 # argument and pass it on to ftp.ntransfercmd
353 def retrfile(self, file, type, rest=None):
354 self.endtransfer()
355 if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1
356 else: cmd = 'TYPE ' + type; isdir = 0
357 try:
358 self.ftp.voidcmd(cmd)
359 except ftplib.all_errors:
360 self.init()
361 self.ftp.voidcmd(cmd)
362 conn = None
363 if file and not isdir:
364 # Use nlst to see if the file exists at all
365 try:
366 self.ftp.nlst(file)
367 except ftplib.error_perm, reason:
368 raise IOError, ('ftp error', reason), sys.exc_info()[2]
369 # Restore the transfer mode!
370 self.ftp.voidcmd(cmd)
371 # Try to retrieve as a file
372 try:
373 cmd = 'RETR ' + file
374 conn = self.ftp.ntransfercmd(cmd, rest)
375 except ftplib.error_perm, reason:
376 if str(reason)[:3] == '501':
377 # workaround for REST not supported error
378 fp, retrlen = self.retrfile(file, type)
379 fp = RangeableFileObject(fp, (rest,''))
380 return (fp, retrlen)
381 elif str(reason)[:3] != '550':
382 raise IOError, ('ftp error', reason), sys.exc_info()[2]
383 if not conn:
384 # Set transfer mode to ASCII!
385 self.ftp.voidcmd('TYPE A')
386 # Try a directory listing
387 if file: cmd = 'LIST ' + file
388 else: cmd = 'LIST'
389 conn = self.ftp.ntransfercmd(cmd)
390 self.busy = 1
391 # Pass back both a suitably decorated object and a retrieval length
392 return (addclosehook(conn[0].makefile('rb'),
393 self.endtransfer), conn[1])
394
395
396####################################################################
397# Range Tuple Functions
398# XXX: These range tuple functions might go better in a class.
399
400_rangere = None
401def range_header_to_tuple(range_header):
402 """Get a (firstbyte,lastbyte) tuple from a Range header value.
403
404 Range headers have the form "bytes=<firstbyte>-<lastbyte>". This
405 function pulls the firstbyte and lastbyte values and returns
406 a (firstbyte,lastbyte) tuple. If lastbyte is not specified in
407 the header value, it is returned as an empty string in the
408 tuple.
409
410 Return None if range_header is None
411 Return () if range_header does not conform to the range spec
412 pattern.
413
414 """
415 global _rangere
416 if range_header is None: return None
417 if _rangere is None:
418 import re
419 _rangere = re.compile(r'^bytes=(\d{1,})-(\d*)')
420 match = _rangere.match(range_header)
421 if match:
422 tup = range_tuple_normalize(match.group(1,2))
423 if tup and tup[1]:
424 tup = (tup[0],tup[1]+1)
425 return tup
426 return ()
427
428def range_tuple_to_header(range_tup):
429 """Convert a range tuple to a Range header value.
430 Return a string of the form "bytes=<firstbyte>-<lastbyte>" or None
431 if no range is needed.
432 """
433 if range_tup is None: return None
434 range_tup = range_tuple_normalize(range_tup)
435 if range_tup:
436 if range_tup[1]:
437 range_tup = (range_tup[0],range_tup[1] - 1)
438 return 'bytes=%s-%s' % range_tup
439
440def range_tuple_normalize(range_tup):
441 """Normalize a (first_byte,last_byte) range tuple.
442 Return a tuple whose first element is guaranteed to be an int
443 and whose second element will be '' (meaning: the last byte) or
444 an int. Finally, return None if the normalized tuple == (0,'')
445 as that is equivelant to retrieving the entire file.
446 """
447 if range_tup is None: return None
448 # handle first byte
449 fb = range_tup[0]
450 if fb in (None,''): fb = 0
451 else: fb = int(fb)
452 # handle last byte
453 try: lb = range_tup[1]
454 except IndexError: lb = ''
455 else:
456 if lb is None: lb = ''
457 elif lb != '': lb = int(lb)
458 # check if range is over the entire file
459 if (fb,lb) == (0,''): return None
460 # check that the range is valid
461 if lb < fb: raise RangeError('Invalid byte range: %s-%s' % (fb,lb))
462 return (fb,lb)
463
diff --git a/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/grabber.py b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/grabber.py
new file mode 100644
index 0000000000..fefdab36f6
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/grabber.py
@@ -0,0 +1,1477 @@
1# This library is free software; you can redistribute it and/or
2# modify it under the terms of the GNU Lesser General Public
3# License as published by the Free Software Foundation; either
4# version 2.1 of the License, or (at your option) any later version.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the
13# Free Software Foundation, Inc.,
14# 59 Temple Place, Suite 330,
15# Boston, MA 02111-1307 USA
16
17# This file is part of urlgrabber, a high-level cross-protocol url-grabber
18# Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
19
20"""A high-level cross-protocol url-grabber.
21
22GENERAL ARGUMENTS (kwargs)
23
24 Where possible, the module-level default is indicated, and legal
25 values are provided.
26
27 copy_local = 0 [0|1]
28
29 ignored except for file:// urls, in which case it specifies
30 whether urlgrab should still make a copy of the file, or simply
31 point to the existing copy. The module level default for this
32 option is 0.
33
34 close_connection = 0 [0|1]
35
36 tells URLGrabber to close the connection after a file has been
37 transfered. This is ignored unless the download happens with the
38 http keepalive handler (keepalive=1). Otherwise, the connection
39 is left open for further use. The module level default for this
40 option is 0 (keepalive connections will not be closed).
41
42 keepalive = 1 [0|1]
43
44 specifies whether keepalive should be used for HTTP/1.1 servers
45 that support it. The module level default for this option is 1
46 (keepalive is enabled).
47
48 progress_obj = None
49
50 a class instance that supports the following methods:
51 po.start(filename, url, basename, length, text)
52 # length will be None if unknown
53 po.update(read) # read == bytes read so far
54 po.end()
55
56 text = None
57
58 specifies an alternativ text item in the beginning of the progress
59 bar line. If not given, the basename of the file is used.
60
61 throttle = 1.0
62
63 a number - if it's an int, it's the bytes/second throttle limit.
64 If it's a float, it is first multiplied by bandwidth. If throttle
65 == 0, throttling is disabled. If None, the module-level default
66 (which can be set on default_grabber.throttle) is used. See
67 BANDWIDTH THROTTLING for more information.
68
69 timeout = None
70
71 a positive float expressing the number of seconds to wait for socket
72 operations. If the value is None or 0.0, socket operations will block
73 forever. Setting this option causes urlgrabber to call the settimeout
74 method on the Socket object used for the request. See the Python
75 documentation on settimeout for more information.
76 http://www.python.org/doc/current/lib/socket-objects.html
77
78 bandwidth = 0
79
80 the nominal max bandwidth in bytes/second. If throttle is a float
81 and bandwidth == 0, throttling is disabled. If None, the
82 module-level default (which can be set on
83 default_grabber.bandwidth) is used. See BANDWIDTH THROTTLING for
84 more information.
85
86 range = None
87
88 a tuple of the form (first_byte, last_byte) describing a byte
89 range to retrieve. Either or both of the values may set to
90 None. If first_byte is None, byte offset 0 is assumed. If
91 last_byte is None, the last byte available is assumed. Note that
92 the range specification is python-like in that (0,10) will yeild
93 the first 10 bytes of the file.
94
95 If set to None, no range will be used.
96
97 reget = None [None|'simple'|'check_timestamp']
98
99 whether to attempt to reget a partially-downloaded file. Reget
100 only applies to .urlgrab and (obviously) only if there is a
101 partially downloaded file. Reget has two modes:
102
103 'simple' -- the local file will always be trusted. If there
104 are 100 bytes in the local file, then the download will always
105 begin 100 bytes into the requested file.
106
107 'check_timestamp' -- the timestamp of the server file will be
108 compared to the timestamp of the local file. ONLY if the
109 local file is newer than or the same age as the server file
110 will reget be used. If the server file is newer, or the
111 timestamp is not returned, the entire file will be fetched.
112
113 NOTE: urlgrabber can do very little to verify that the partial
114 file on disk is identical to the beginning of the remote file.
115 You may want to either employ a custom "checkfunc" or simply avoid
116 using reget in situations where corruption is a concern.
117
118 user_agent = 'urlgrabber/VERSION'
119
120 a string, usually of the form 'AGENT/VERSION' that is provided to
121 HTTP servers in the User-agent header. The module level default
122 for this option is "urlgrabber/VERSION".
123
124 http_headers = None
125
126 a tuple of 2-tuples, each containing a header and value. These
127 will be used for http and https requests only. For example, you
128 can do
129 http_headers = (('Pragma', 'no-cache'),)
130
131 ftp_headers = None
132
133 this is just like http_headers, but will be used for ftp requests.
134
135 proxies = None
136
137 a dictionary that maps protocol schemes to proxy hosts. For
138 example, to use a proxy server on host "foo" port 3128 for http
139 and https URLs:
140 proxies={ 'http' : 'http://foo:3128', 'https' : 'http://foo:3128' }
141 note that proxy authentication information may be provided using
142 normal URL constructs:
143 proxies={ 'http' : 'http://user:host@foo:3128' }
144 Lastly, if proxies is None, the default environment settings will
145 be used.
146
147 prefix = None
148
149 a url prefix that will be prepended to all requested urls. For
150 example:
151 g = URLGrabber(prefix='http://foo.com/mirror/')
152 g.urlgrab('some/file.txt')
153 ## this will fetch 'http://foo.com/mirror/some/file.txt'
154 This option exists primarily to allow identical behavior to
155 MirrorGroup (and derived) instances. Note: a '/' will be inserted
156 if necessary, so you cannot specify a prefix that ends with a
157 partial file or directory name.
158
159 opener = None
160
161 Overrides the default urllib2.OpenerDirector provided to urllib2
162 when making requests. This option exists so that the urllib2
163 handler chain may be customized. Note that the range, reget,
164 proxy, and keepalive features require that custom handlers be
165 provided to urllib2 in order to function properly. If an opener
166 option is provided, no attempt is made by urlgrabber to ensure
167 chain integrity. You are responsible for ensuring that any
168 extension handlers are present if said features are required.
169
170 data = None
171
172 Only relevant for the HTTP family (and ignored for other
173 protocols), this allows HTTP POSTs. When the data kwarg is
174 present (and not None), an HTTP request will automatically become
175 a POST rather than GET. This is done by direct passthrough to
176 urllib2. If you use this, you may also want to set the
177 'Content-length' and 'Content-type' headers with the http_headers
178 option. Note that python 2.2 handles the case of these
179 badly and if you do not use the proper case (shown here), your
180 values will be overridden with the defaults.
181
182
183RETRY RELATED ARGUMENTS
184
185 retry = None
186
187 the number of times to retry the grab before bailing. If this is
188 zero, it will retry forever. This was intentional... really, it
189 was :). If this value is not supplied or is supplied but is None
190 retrying does not occur.
191
192 retrycodes = [-1,2,4,5,6,7]
193
194 a sequence of errorcodes (values of e.errno) for which it should
195 retry. See the doc on URLGrabError for more details on this. You
196 might consider modifying a copy of the default codes rather than
197 building yours from scratch so that if the list is extended in the
198 future (or one code is split into two) you can still enjoy the
199 benefits of the default list. You can do that with something like
200 this:
201
202 retrycodes = urlgrabber.grabber.URLGrabberOptions().retrycodes
203 if 12 not in retrycodes:
204 retrycodes.append(12)
205
206 checkfunc = None
207
208 a function to do additional checks. This defaults to None, which
209 means no additional checking. The function should simply return
210 on a successful check. It should raise URLGrabError on an
211 unsuccessful check. Raising of any other exception will be
212 considered immediate failure and no retries will occur.
213
214 If it raises URLGrabError, the error code will determine the retry
215 behavior. Negative error numbers are reserved for use by these
216 passed in functions, so you can use many negative numbers for
217 different types of failure. By default, -1 results in a retry,
218 but this can be customized with retrycodes.
219
220 If you simply pass in a function, it will be given exactly one
221 argument: a CallbackObject instance with the .url attribute
222 defined and either .filename (for urlgrab) or .data (for urlread).
223 For urlgrab, .filename is the name of the local file. For
224 urlread, .data is the actual string data. If you need other
225 arguments passed to the callback (program state of some sort), you
226 can do so like this:
227
228 checkfunc=(function, ('arg1', 2), {'kwarg': 3})
229
230 if the downloaded file has filename /tmp/stuff, then this will
231 result in this call (for urlgrab):
232
233 function(obj, 'arg1', 2, kwarg=3)
234 # obj.filename = '/tmp/stuff'
235 # obj.url = 'http://foo.com/stuff'
236
237 NOTE: both the "args" tuple and "kwargs" dict must be present if
238 you use this syntax, but either (or both) can be empty.
239
240 failure_callback = None
241
242 The callback that gets called during retries when an attempt to
243 fetch a file fails. The syntax for specifying the callback is
244 identical to checkfunc, except for the attributes defined in the
245 CallbackObject instance. The attributes for failure_callback are:
246
247 exception = the raised exception
248 url = the url we're trying to fetch
249 tries = the number of tries so far (including this one)
250 retry = the value of the retry option
251
252 The callback is present primarily to inform the calling program of
253 the failure, but if it raises an exception (including the one it's
254 passed) that exception will NOT be caught and will therefore cause
255 future retries to be aborted.
256
257 The callback is called for EVERY failure, including the last one.
258 On the last try, the callback can raise an alternate exception,
259 but it cannot (without severe trickiness) prevent the exception
260 from being raised.
261
262 interrupt_callback = None
263
264 This callback is called if KeyboardInterrupt is received at any
265 point in the transfer. Basically, this callback can have three
266 impacts on the fetch process based on the way it exits:
267
268 1) raise no exception: the current fetch will be aborted, but
269 any further retries will still take place
270
271 2) raise a URLGrabError: if you're using a MirrorGroup, then
272 this will prompt a failover to the next mirror according to
273 the behavior of the MirrorGroup subclass. It is recommended
274 that you raise URLGrabError with code 15, 'user abort'. If
275 you are NOT using a MirrorGroup subclass, then this is the
276 same as (3).
277
278 3) raise some other exception (such as KeyboardInterrupt), which
279 will not be caught at either the grabber or mirror levels.
280 That is, it will be raised up all the way to the caller.
281
282 This callback is very similar to failure_callback. They are
283 passed the same arguments, so you could use the same function for
284 both.
285
286 urlparser = URLParser()
287
288 The URLParser class handles pre-processing of URLs, including
289 auth-handling for user/pass encoded in http urls, file handing
290 (that is, filenames not sent as a URL), and URL quoting. If you
291 want to override any of this behavior, you can pass in a
292 replacement instance. See also the 'quote' option.
293
294 quote = None
295
296 Whether or not to quote the path portion of a url.
297 quote = 1 -> quote the URLs (they're not quoted yet)
298 quote = 0 -> do not quote them (they're already quoted)
299 quote = None -> guess what to do
300
301 This option only affects proper urls like 'file:///etc/passwd'; it
302 does not affect 'raw' filenames like '/etc/passwd'. The latter
303 will always be quoted as they are converted to URLs. Also, only
304 the path part of a url is quoted. If you need more fine-grained
305 control, you should probably subclass URLParser and pass it in via
306 the 'urlparser' option.
307
308BANDWIDTH THROTTLING
309
310 urlgrabber supports throttling via two values: throttle and
311 bandwidth Between the two, you can either specify and absolute
312 throttle threshold or specify a theshold as a fraction of maximum
313 available bandwidth.
314
315 throttle is a number - if it's an int, it's the bytes/second
316 throttle limit. If it's a float, it is first multiplied by
317 bandwidth. If throttle == 0, throttling is disabled. If None, the
318 module-level default (which can be set with set_throttle) is used.
319
320 bandwidth is the nominal max bandwidth in bytes/second. If throttle
321 is a float and bandwidth == 0, throttling is disabled. If None, the
322 module-level default (which can be set with set_bandwidth) is used.
323
324 THROTTLING EXAMPLES:
325
326 Lets say you have a 100 Mbps connection. This is (about) 10^8 bits
327 per second, or 12,500,000 Bytes per second. You have a number of
328 throttling options:
329
330 *) set_bandwidth(12500000); set_throttle(0.5) # throttle is a float
331
332 This will limit urlgrab to use half of your available bandwidth.
333
334 *) set_throttle(6250000) # throttle is an int
335
336 This will also limit urlgrab to use half of your available
337 bandwidth, regardless of what bandwidth is set to.
338
339 *) set_throttle(6250000); set_throttle(1.0) # float
340
341 Use half your bandwidth
342
343 *) set_throttle(6250000); set_throttle(2.0) # float
344
345 Use up to 12,500,000 Bytes per second (your nominal max bandwidth)
346
347 *) set_throttle(6250000); set_throttle(0) # throttle = 0
348
349 Disable throttling - this is more efficient than a very large
350 throttle setting.
351
352 *) set_throttle(0); set_throttle(1.0) # throttle is float, bandwidth = 0
353
354 Disable throttling - this is the default when the module is loaded.
355
356 SUGGESTED AUTHOR IMPLEMENTATION (THROTTLING)
357
358 While this is flexible, it's not extremely obvious to the user. I
359 suggest you implement a float throttle as a percent to make the
360 distinction between absolute and relative throttling very explicit.
361
362 Also, you may want to convert the units to something more convenient
363 than bytes/second, such as kbps or kB/s, etc.
364
365"""
366
367# $Id: grabber.py,v 1.48 2006/09/22 00:58:05 mstenner Exp $
368
369import os
370import os.path
371import sys
372import urlparse
373import rfc822
374import time
375import string
376import urllib
377import urllib2
378from stat import * # S_* and ST_*
379
380########################################################################
381# MODULE INITIALIZATION
382########################################################################
383try:
384 exec('from ' + (__name__.split('.'))[0] + ' import __version__')
385except:
386 __version__ = '???'
387
388import sslfactory
389
390auth_handler = urllib2.HTTPBasicAuthHandler( \
391 urllib2.HTTPPasswordMgrWithDefaultRealm())
392
393try:
394 from i18n import _
395except ImportError, msg:
396 def _(st): return st
397
398try:
399 from httplib import HTTPException
400except ImportError, msg:
401 HTTPException = None
402
403try:
404 # This is a convenient way to make keepalive optional.
405 # Just rename the module so it can't be imported.
406 import keepalive
407 from keepalive import HTTPHandler, HTTPSHandler
408 have_keepalive = True
409except ImportError, msg:
410 have_keepalive = False
411
412try:
413 # add in range support conditionally too
414 import byterange
415 from byterange import HTTPRangeHandler, HTTPSRangeHandler, \
416 FileRangeHandler, FTPRangeHandler, range_tuple_normalize, \
417 range_tuple_to_header, RangeError
418except ImportError, msg:
419 range_handlers = ()
420 RangeError = None
421 have_range = 0
422else:
423 range_handlers = (HTTPRangeHandler(), HTTPSRangeHandler(),
424 FileRangeHandler(), FTPRangeHandler())
425 have_range = 1
426
427
428# check whether socket timeout support is available (Python >= 2.3)
429import socket
430try:
431 TimeoutError = socket.timeout
432 have_socket_timeout = True
433except AttributeError:
434 TimeoutError = None
435 have_socket_timeout = False
436
437########################################################################
438# functions for debugging output. These functions are here because they
439# are also part of the module initialization.
440DEBUG = None
441def set_logger(DBOBJ):
442 """Set the DEBUG object. This is called by _init_default_logger when
443 the environment variable URLGRABBER_DEBUG is set, but can also be
444 called by a calling program. Basically, if the calling program uses
445 the logging module and would like to incorporate urlgrabber logging,
446 then it can do so this way. It's probably not necessary as most
447 internal logging is only for debugging purposes.
448
449 The passed-in object should be a logging.Logger instance. It will
450 be pushed into the keepalive and byterange modules if they're
451 being used. The mirror module pulls this object in on import, so
452 you will need to manually push into it. In fact, you may find it
453 tidier to simply push your logging object (or objects) into each
454 of these modules independently.
455 """
456
457 global DEBUG
458 DEBUG = DBOBJ
459 if have_keepalive and keepalive.DEBUG is None:
460 keepalive.DEBUG = DBOBJ
461 if have_range and byterange.DEBUG is None:
462 byterange.DEBUG = DBOBJ
463 if sslfactory.DEBUG is None:
464 sslfactory.DEBUG = DBOBJ
465
466def _init_default_logger():
467 '''Examines the environment variable URLGRABBER_DEBUG and creates
468 a logging object (logging.logger) based on the contents. It takes
469 the form
470
471 URLGRABBER_DEBUG=level,filename
472
473 where "level" can be either an integer or a log level from the
474 logging module (DEBUG, INFO, etc). If the integer is zero or
475 less, logging will be disabled. Filename is the filename where
476 logs will be sent. If it is "-", then stdout will be used. If
477 the filename is empty or missing, stderr will be used. If the
478 variable cannot be processed or the logging module cannot be
479 imported (python < 2.3) then logging will be disabled. Here are
480 some examples:
481
482 URLGRABBER_DEBUG=1,debug.txt # log everything to debug.txt
483 URLGRABBER_DEBUG=WARNING,- # log warning and higher to stdout
484 URLGRABBER_DEBUG=INFO # log info and higher to stderr
485
486 This funtion is called during module initialization. It is not
487 intended to be called from outside. The only reason it is a
488 function at all is to keep the module-level namespace tidy and to
489 collect the code into a nice block.'''
490
491 try:
492 dbinfo = os.environ['URLGRABBER_DEBUG'].split(',')
493 import logging
494 level = logging._levelNames.get(dbinfo[0], int(dbinfo[0]))
495 if level < 1: raise ValueError()
496
497 formatter = logging.Formatter('%(asctime)s %(message)s')
498 if len(dbinfo) > 1: filename = dbinfo[1]
499 else: filename = ''
500 if filename == '': handler = logging.StreamHandler(sys.stderr)
501 elif filename == '-': handler = logging.StreamHandler(sys.stdout)
502 else: handler = logging.FileHandler(filename)
503 handler.setFormatter(formatter)
504 DBOBJ = logging.getLogger('urlgrabber')
505 DBOBJ.addHandler(handler)
506 DBOBJ.setLevel(level)
507 except (KeyError, ImportError, ValueError):
508 DBOBJ = None
509 set_logger(DBOBJ)
510
511_init_default_logger()
512########################################################################
513# END MODULE INITIALIZATION
514########################################################################
515
516
517
518class URLGrabError(IOError):
519 """
520 URLGrabError error codes:
521
522 URLGrabber error codes (0 -- 255)
523 0 - everything looks good (you should never see this)
524 1 - malformed url
525 2 - local file doesn't exist
526 3 - request for non-file local file (dir, etc)
527 4 - IOError on fetch
528 5 - OSError on fetch
529 6 - no content length header when we expected one
530 7 - HTTPException
531 8 - Exceeded read limit (for urlread)
532 9 - Requested byte range not satisfiable.
533 10 - Byte range requested, but range support unavailable
534 11 - Illegal reget mode
535 12 - Socket timeout
536 13 - malformed proxy url
537 14 - HTTPError (includes .code and .exception attributes)
538 15 - user abort
539
540 MirrorGroup error codes (256 -- 511)
541 256 - No more mirrors left to try
542
543 Custom (non-builtin) classes derived from MirrorGroup (512 -- 767)
544 [ this range reserved for application-specific error codes ]
545
546 Retry codes (< 0)
547 -1 - retry the download, unknown reason
548
549 Note: to test which group a code is in, you can simply do integer
550 division by 256: e.errno / 256
551
552 Negative codes are reserved for use by functions passed in to
553 retrygrab with checkfunc. The value -1 is built in as a generic
554 retry code and is already included in the retrycodes list.
555 Therefore, you can create a custom check function that simply
556 returns -1 and the fetch will be re-tried. For more customized
557 retries, you can use other negative number and include them in
558 retry-codes. This is nice for outputting useful messages about
559 what failed.
560
561 You can use these error codes like so:
562 try: urlgrab(url)
563 except URLGrabError, e:
564 if e.errno == 3: ...
565 # or
566 print e.strerror
567 # or simply
568 print e #### print '[Errno %i] %s' % (e.errno, e.strerror)
569 """
570 pass
571
572class CallbackObject:
573 """Container for returned callback data.
574
575 This is currently a dummy class into which urlgrabber can stuff
576 information for passing to callbacks. This way, the prototype for
577 all callbacks is the same, regardless of the data that will be
578 passed back. Any function that accepts a callback function as an
579 argument SHOULD document what it will define in this object.
580
581 It is possible that this class will have some greater
582 functionality in the future.
583 """
584 def __init__(self, **kwargs):
585 self.__dict__.update(kwargs)
586
587def urlgrab(url, filename=None, **kwargs):
588 """grab the file at <url> and make a local copy at <filename>
589 If filename is none, the basename of the url is used.
590 urlgrab returns the filename of the local file, which may be different
591 from the passed-in filename if the copy_local kwarg == 0.
592
593 See module documentation for a description of possible kwargs.
594 """
595 return default_grabber.urlgrab(url, filename, **kwargs)
596
597def urlopen(url, **kwargs):
598 """open the url and return a file object
599 If a progress object or throttle specifications exist, then
600 a special file object will be returned that supports them.
601 The file object can be treated like any other file object.
602
603 See module documentation for a description of possible kwargs.
604 """
605 return default_grabber.urlopen(url, **kwargs)
606
607def urlread(url, limit=None, **kwargs):
608 """read the url into a string, up to 'limit' bytes
609 If the limit is exceeded, an exception will be thrown. Note that urlread
610 is NOT intended to be used as a way of saying "I want the first N bytes"
611 but rather 'read the whole file into memory, but don't use too much'
612
613 See module documentation for a description of possible kwargs.
614 """
615 return default_grabber.urlread(url, limit, **kwargs)
616
617
618class URLParser:
619 """Process the URLs before passing them to urllib2.
620
621 This class does several things:
622
623 * add any prefix
624 * translate a "raw" file to a proper file: url
625 * handle any http or https auth that's encoded within the url
626 * quote the url
627
628 Only the "parse" method is called directly, and it calls sub-methods.
629
630 An instance of this class is held in the options object, which
631 means that it's easy to change the behavior by sub-classing and
632 passing the replacement in. It need only have a method like:
633
634 url, parts = urlparser.parse(url, opts)
635 """
636
637 def parse(self, url, opts):
638 """parse the url and return the (modified) url and its parts
639
640 Note: a raw file WILL be quoted when it's converted to a URL.
641 However, other urls (ones which come with a proper scheme) may
642 or may not be quoted according to opts.quote
643
644 opts.quote = 1 --> quote it
645 opts.quote = 0 --> do not quote it
646 opts.quote = None --> guess
647 """
648 quote = opts.quote
649
650 if opts.prefix:
651 url = self.add_prefix(url, opts.prefix)
652
653 parts = urlparse.urlparse(url)
654 (scheme, host, path, parm, query, frag) = parts
655
656 if not scheme or (len(scheme) == 1 and scheme in string.letters):
657 # if a scheme isn't specified, we guess that it's "file:"
658 if url[0] not in '/\\': url = os.path.abspath(url)
659 url = 'file:' + urllib.pathname2url(url)
660 parts = urlparse.urlparse(url)
661 quote = 0 # pathname2url quotes, so we won't do it again
662
663 if scheme in ['http', 'https']:
664 parts = self.process_http(parts)
665
666 if quote is None:
667 quote = self.guess_should_quote(parts)
668 if quote:
669 parts = self.quote(parts)
670
671 url = urlparse.urlunparse(parts)
672 return url, parts
673
674 def add_prefix(self, url, prefix):
675 if prefix[-1] == '/' or url[0] == '/':
676 url = prefix + url
677 else:
678 url = prefix + '/' + url
679 return url
680
681 def process_http(self, parts):
682 (scheme, host, path, parm, query, frag) = parts
683
684 if '@' in host and auth_handler:
685 try:
686 user_pass, host = host.split('@', 1)
687 if ':' in user_pass:
688 user, password = user_pass.split(':', 1)
689 except ValueError, e:
690 raise URLGrabError(1, _('Bad URL: %s') % url)
691 if DEBUG: DEBUG.info('adding HTTP auth: %s, XXXXXXXX', user)
692 auth_handler.add_password(None, host, user, password)
693
694 return (scheme, host, path, parm, query, frag)
695
696 def quote(self, parts):
697 """quote the URL
698
699 This method quotes ONLY the path part. If you need to quote
700 other parts, you should override this and pass in your derived
701 class. The other alternative is to quote other parts before
702 passing into urlgrabber.
703 """
704 (scheme, host, path, parm, query, frag) = parts
705 path = urllib.quote(path)
706 return (scheme, host, path, parm, query, frag)
707
708 hexvals = '0123456789ABCDEF'
709 def guess_should_quote(self, parts):
710 """
711 Guess whether we should quote a path. This amounts to
712 guessing whether it's already quoted.
713
714 find ' ' -> 1
715 find '%' -> 1
716 find '%XX' -> 0
717 else -> 1
718 """
719 (scheme, host, path, parm, query, frag) = parts
720 if ' ' in path:
721 return 1
722 ind = string.find(path, '%')
723 if ind > -1:
724 while ind > -1:
725 if len(path) < ind+3:
726 return 1
727 code = path[ind+1:ind+3].upper()
728 if code[0] not in self.hexvals or \
729 code[1] not in self.hexvals:
730 return 1
731 ind = string.find(path, '%', ind+1)
732 return 0
733 return 1
734
735class URLGrabberOptions:
736 """Class to ease kwargs handling."""
737
738 def __init__(self, delegate=None, **kwargs):
739 """Initialize URLGrabberOptions object.
740 Set default values for all options and then update options specified
741 in kwargs.
742 """
743 self.delegate = delegate
744 if delegate is None:
745 self._set_defaults()
746 self._set_attributes(**kwargs)
747
748 def __getattr__(self, name):
749 if self.delegate and hasattr(self.delegate, name):
750 return getattr(self.delegate, name)
751 raise AttributeError, name
752
753 def raw_throttle(self):
754 """Calculate raw throttle value from throttle and bandwidth
755 values.
756 """
757 if self.throttle <= 0:
758 return 0
759 elif type(self.throttle) == type(0):
760 return float(self.throttle)
761 else: # throttle is a float
762 return self.bandwidth * self.throttle
763
764 def derive(self, **kwargs):
765 """Create a derived URLGrabberOptions instance.
766 This method creates a new instance and overrides the
767 options specified in kwargs.
768 """
769 return URLGrabberOptions(delegate=self, **kwargs)
770
771 def _set_attributes(self, **kwargs):
772 """Update object attributes with those provided in kwargs."""
773 self.__dict__.update(kwargs)
774 if have_range and kwargs.has_key('range'):
775 # normalize the supplied range value
776 self.range = range_tuple_normalize(self.range)
777 if not self.reget in [None, 'simple', 'check_timestamp']:
778 raise URLGrabError(11, _('Illegal reget mode: %s') \
779 % (self.reget, ))
780
781 def _set_defaults(self):
782 """Set all options to their default values.
783 When adding new options, make sure a default is
784 provided here.
785 """
786 self.progress_obj = None
787 self.throttle = 1.0
788 self.bandwidth = 0
789 self.retry = None
790 self.retrycodes = [-1,2,4,5,6,7]
791 self.checkfunc = None
792 self.copy_local = 0
793 self.close_connection = 0
794 self.range = None
795 self.user_agent = 'urlgrabber/%s' % __version__
796 self.keepalive = 1
797 self.proxies = None
798 self.reget = None
799 self.failure_callback = None
800 self.interrupt_callback = None
801 self.prefix = None
802 self.opener = None
803 self.cache_openers = True
804 self.timeout = None
805 self.text = None
806 self.http_headers = None
807 self.ftp_headers = None
808 self.data = None
809 self.urlparser = URLParser()
810 self.quote = None
811 self.ssl_ca_cert = None
812 self.ssl_context = None
813
814class URLGrabber:
815 """Provides easy opening of URLs with a variety of options.
816
817 All options are specified as kwargs. Options may be specified when
818 the class is created and may be overridden on a per request basis.
819
820 New objects inherit default values from default_grabber.
821 """
822
823 def __init__(self, **kwargs):
824 self.opts = URLGrabberOptions(**kwargs)
825
826 def _retry(self, opts, func, *args):
827 tries = 0
828 while 1:
829 # there are only two ways out of this loop. The second has
830 # several "sub-ways"
831 # 1) via the return in the "try" block
832 # 2) by some exception being raised
833 # a) an excepton is raised that we don't "except"
834 # b) a callback raises ANY exception
835 # c) we're not retry-ing or have run out of retries
836 # d) the URLGrabError code is not in retrycodes
837 # beware of infinite loops :)
838 tries = tries + 1
839 exception = None
840 retrycode = None
841 callback = None
842 if DEBUG: DEBUG.info('attempt %i/%s: %s',
843 tries, opts.retry, args[0])
844 try:
845 r = apply(func, (opts,) + args, {})
846 if DEBUG: DEBUG.info('success')
847 return r
848 except URLGrabError, e:
849 exception = e
850 callback = opts.failure_callback
851 retrycode = e.errno
852 except KeyboardInterrupt, e:
853 exception = e
854 callback = opts.interrupt_callback
855
856 if DEBUG: DEBUG.info('exception: %s', exception)
857 if callback:
858 if DEBUG: DEBUG.info('calling callback: %s', callback)
859 cb_func, cb_args, cb_kwargs = self._make_callback(callback)
860 obj = CallbackObject(exception=exception, url=args[0],
861 tries=tries, retry=opts.retry)
862 cb_func(obj, *cb_args, **cb_kwargs)
863
864 if (opts.retry is None) or (tries == opts.retry):
865 if DEBUG: DEBUG.info('retries exceeded, re-raising')
866 raise
867
868 if (retrycode is not None) and (retrycode not in opts.retrycodes):
869 if DEBUG: DEBUG.info('retrycode (%i) not in list %s, re-raising',
870 retrycode, opts.retrycodes)
871 raise
872
873 def urlopen(self, url, **kwargs):
874 """open the url and return a file object
875 If a progress object or throttle value specified when this
876 object was created, then a special file object will be
877 returned that supports them. The file object can be treated
878 like any other file object.
879 """
880 opts = self.opts.derive(**kwargs)
881 (url,parts) = opts.urlparser.parse(url, opts)
882 def retryfunc(opts, url):
883 return URLGrabberFileObject(url, filename=None, opts=opts)
884 return self._retry(opts, retryfunc, url)
885
886 def urlgrab(self, url, filename=None, **kwargs):
887 """grab the file at <url> and make a local copy at <filename>
888 If filename is none, the basename of the url is used.
889 urlgrab returns the filename of the local file, which may be
890 different from the passed-in filename if copy_local == 0.
891 """
892 opts = self.opts.derive(**kwargs)
893 (url,parts) = opts.urlparser.parse(url, opts)
894 (scheme, host, path, parm, query, frag) = parts
895 if filename is None:
896 filename = os.path.basename( urllib.unquote(path) )
897 if scheme == 'file' and not opts.copy_local:
898 # just return the name of the local file - don't make a
899 # copy currently
900 path = urllib.url2pathname(path)
901 if host:
902 path = os.path.normpath('//' + host + path)
903 if not os.path.exists(path):
904 raise URLGrabError(2,
905 _('Local file does not exist: %s') % (path, ))
906 elif not os.path.isfile(path):
907 raise URLGrabError(3,
908 _('Not a normal file: %s') % (path, ))
909 elif not opts.range:
910 return path
911
912 def retryfunc(opts, url, filename):
913 fo = URLGrabberFileObject(url, filename, opts)
914 try:
915 fo._do_grab()
916 if not opts.checkfunc is None:
917 cb_func, cb_args, cb_kwargs = \
918 self._make_callback(opts.checkfunc)
919 obj = CallbackObject()
920 obj.filename = filename
921 obj.url = url
922 apply(cb_func, (obj, )+cb_args, cb_kwargs)
923 finally:
924 fo.close()
925 return filename
926
927 return self._retry(opts, retryfunc, url, filename)
928
929 def urlread(self, url, limit=None, **kwargs):
930 """read the url into a string, up to 'limit' bytes
931 If the limit is exceeded, an exception will be thrown. Note
932 that urlread is NOT intended to be used as a way of saying
933 "I want the first N bytes" but rather 'read the whole file
934 into memory, but don't use too much'
935 """
936 opts = self.opts.derive(**kwargs)
937 (url,parts) = opts.urlparser.parse(url, opts)
938 if limit is not None:
939 limit = limit + 1
940
941 def retryfunc(opts, url, limit):
942 fo = URLGrabberFileObject(url, filename=None, opts=opts)
943 s = ''
944 try:
945 # this is an unfortunate thing. Some file-like objects
946 # have a default "limit" of None, while the built-in (real)
947 # file objects have -1. They each break the other, so for
948 # now, we just force the default if necessary.
949 if limit is None: s = fo.read()
950 else: s = fo.read(limit)
951
952 if not opts.checkfunc is None:
953 cb_func, cb_args, cb_kwargs = \
954 self._make_callback(opts.checkfunc)
955 obj = CallbackObject()
956 obj.data = s
957 obj.url = url
958 apply(cb_func, (obj, )+cb_args, cb_kwargs)
959 finally:
960 fo.close()
961 return s
962
963 s = self._retry(opts, retryfunc, url, limit)
964 if limit and len(s) > limit:
965 raise URLGrabError(8,
966 _('Exceeded limit (%i): %s') % (limit, url))
967 return s
968
969 def _make_callback(self, callback_obj):
970 if callable(callback_obj):
971 return callback_obj, (), {}
972 else:
973 return callback_obj
974
975# create the default URLGrabber used by urlXXX functions.
976# NOTE: actual defaults are set in URLGrabberOptions
977default_grabber = URLGrabber()
978
979class URLGrabberFileObject:
980 """This is a file-object wrapper that supports progress objects
981 and throttling.
982
983 This exists to solve the following problem: lets say you want to
984 drop-in replace a normal open with urlopen. You want to use a
985 progress meter and/or throttling, but how do you do that without
986 rewriting your code? Answer: urlopen will return a wrapped file
987 object that does the progress meter and-or throttling internally.
988 """
989
990 def __init__(self, url, filename, opts):
991 self.url = url
992 self.filename = filename
993 self.opts = opts
994 self.fo = None
995 self._rbuf = ''
996 self._rbufsize = 1024*8
997 self._ttime = time.time()
998 self._tsize = 0
999 self._amount_read = 0
1000 self._opener = None
1001 self._do_open()
1002
1003 def __getattr__(self, name):
1004 """This effectively allows us to wrap at the instance level.
1005 Any attribute not found in _this_ object will be searched for
1006 in self.fo. This includes methods."""
1007 if hasattr(self.fo, name):
1008 return getattr(self.fo, name)
1009 raise AttributeError, name
1010
1011 def _get_opener(self):
1012 """Build a urllib2 OpenerDirector based on request options."""
1013 if self.opts.opener:
1014 return self.opts.opener
1015 elif self._opener is None:
1016 handlers = []
1017 need_keepalive_handler = (have_keepalive and self.opts.keepalive)
1018 need_range_handler = (range_handlers and \
1019 (self.opts.range or self.opts.reget))
1020 # if you specify a ProxyHandler when creating the opener
1021 # it _must_ come before all other handlers in the list or urllib2
1022 # chokes.
1023 if self.opts.proxies:
1024 handlers.append( CachedProxyHandler(self.opts.proxies) )
1025
1026 # -------------------------------------------------------
1027 # OK, these next few lines are a serious kludge to get
1028 # around what I think is a bug in python 2.2's
1029 # urllib2. The basic idea is that default handlers
1030 # get applied first. If you override one (like a
1031 # proxy handler), then the default gets pulled, but
1032 # the replacement goes on the end. In the case of
1033 # proxies, this means the normal handler picks it up
1034 # first and the proxy isn't used. Now, this probably
1035 # only happened with ftp or non-keepalive http, so not
1036 # many folks saw it. The simple approach to fixing it
1037 # is just to make sure you override the other
1038 # conflicting defaults as well. I would LOVE to see
1039 # these go way or be dealt with more elegantly. The
1040 # problem isn't there after 2.2. -MDS 2005/02/24
1041 if not need_keepalive_handler:
1042 handlers.append( urllib2.HTTPHandler() )
1043 if not need_range_handler:
1044 handlers.append( urllib2.FTPHandler() )
1045 # -------------------------------------------------------
1046
1047 ssl_factory = sslfactory.get_factory(self.opts.ssl_ca_cert,
1048 self.opts.ssl_context)
1049
1050 if need_keepalive_handler:
1051 handlers.append(HTTPHandler())
1052 handlers.append(HTTPSHandler(ssl_factory))
1053 if need_range_handler:
1054 handlers.extend( range_handlers )
1055 handlers.append( auth_handler )
1056 if self.opts.cache_openers:
1057 self._opener = CachedOpenerDirector(ssl_factory, *handlers)
1058 else:
1059 self._opener = ssl_factory.create_opener(*handlers)
1060 # OK, I don't like to do this, but otherwise, we end up with
1061 # TWO user-agent headers.
1062 self._opener.addheaders = []
1063 return self._opener
1064
1065 def _do_open(self):
1066 opener = self._get_opener()
1067
1068 req = urllib2.Request(self.url, self.opts.data) # build request object
1069 self._add_headers(req) # add misc headers that we need
1070 self._build_range(req) # take care of reget and byterange stuff
1071
1072 fo, hdr = self._make_request(req, opener)
1073 if self.reget_time and self.opts.reget == 'check_timestamp':
1074 # do this if we have a local file with known timestamp AND
1075 # we're in check_timestamp reget mode.
1076 fetch_again = 0
1077 try:
1078 modified_tuple = hdr.getdate_tz('last-modified')
1079 modified_stamp = rfc822.mktime_tz(modified_tuple)
1080 if modified_stamp > self.reget_time: fetch_again = 1
1081 except (TypeError,):
1082 fetch_again = 1
1083
1084 if fetch_again:
1085 # the server version is newer than the (incomplete) local
1086 # version, so we should abandon the version we're getting
1087 # and fetch the whole thing again.
1088 fo.close()
1089 self.opts.reget = None
1090 del req.headers['Range']
1091 self._build_range(req)
1092 fo, hdr = self._make_request(req, opener)
1093
1094 (scheme, host, path, parm, query, frag) = urlparse.urlparse(self.url)
1095 path = urllib.unquote(path)
1096 if not (self.opts.progress_obj or self.opts.raw_throttle() \
1097 or self.opts.timeout):
1098 # if we're not using the progress_obj, throttling, or timeout
1099 # we can get a performance boost by going directly to
1100 # the underlying fileobject for reads.
1101 self.read = fo.read
1102 if hasattr(fo, 'readline'):
1103 self.readline = fo.readline
1104 elif self.opts.progress_obj:
1105 try:
1106 length = int(hdr['Content-Length'])
1107 length = length + self._amount_read # Account for regets
1108 except (KeyError, ValueError, TypeError):
1109 length = None
1110
1111 self.opts.progress_obj.start(str(self.filename),
1112 urllib.unquote(self.url),
1113 os.path.basename(path),
1114 length, text=self.opts.text)
1115 self.opts.progress_obj.update(0)
1116 (self.fo, self.hdr) = (fo, hdr)
1117
1118 def _add_headers(self, req):
1119 if self.opts.user_agent:
1120 req.add_header('User-agent', self.opts.user_agent)
1121 try: req_type = req.get_type()
1122 except ValueError: req_type = None
1123 if self.opts.http_headers and req_type in ('http', 'https'):
1124 for h, v in self.opts.http_headers:
1125 req.add_header(h, v)
1126 if self.opts.ftp_headers and req_type == 'ftp':
1127 for h, v in self.opts.ftp_headers:
1128 req.add_header(h, v)
1129
1130 def _build_range(self, req):
1131 self.reget_time = None
1132 self.append = 0
1133 reget_length = 0
1134 rt = None
1135 if have_range and self.opts.reget and type(self.filename) == type(''):
1136 # we have reget turned on and we're dumping to a file
1137 try:
1138 s = os.stat(self.filename)
1139 except OSError:
1140 pass
1141 else:
1142 self.reget_time = s[ST_MTIME]
1143 reget_length = s[ST_SIZE]
1144
1145 # Set initial length when regetting
1146 self._amount_read = reget_length
1147
1148 rt = reget_length, ''
1149 self.append = 1
1150
1151 if self.opts.range:
1152 if not have_range:
1153 raise URLGrabError(10, _('Byte range requested but range '\
1154 'support unavailable'))
1155 rt = self.opts.range
1156 if rt[0]: rt = (rt[0] + reget_length, rt[1])
1157
1158 if rt:
1159 header = range_tuple_to_header(rt)
1160 if header: req.add_header('Range', header)
1161
1162 def _make_request(self, req, opener):
1163 try:
1164 if have_socket_timeout and self.opts.timeout:
1165 old_to = socket.getdefaulttimeout()
1166 socket.setdefaulttimeout(self.opts.timeout)
1167 try:
1168 fo = opener.open(req)
1169 finally:
1170 socket.setdefaulttimeout(old_to)
1171 else:
1172 fo = opener.open(req)
1173 hdr = fo.info()
1174 except ValueError, e:
1175 raise URLGrabError(1, _('Bad URL: %s') % (e, ))
1176 except RangeError, e:
1177 raise URLGrabError(9, str(e))
1178 except urllib2.HTTPError, e:
1179 new_e = URLGrabError(14, str(e))
1180 new_e.code = e.code
1181 new_e.exception = e
1182 raise new_e
1183 except IOError, e:
1184 if hasattr(e, 'reason') and have_socket_timeout and \
1185 isinstance(e.reason, TimeoutError):
1186 raise URLGrabError(12, _('Timeout: %s') % (e, ))
1187 else:
1188 raise URLGrabError(4, _('IOError: %s') % (e, ))
1189 except OSError, e:
1190 raise URLGrabError(5, _('OSError: %s') % (e, ))
1191 except HTTPException, e:
1192 raise URLGrabError(7, _('HTTP Exception (%s): %s') % \
1193 (e.__class__.__name__, e))
1194 else:
1195 return (fo, hdr)
1196
1197 def _do_grab(self):
1198 """dump the file to self.filename."""
1199 if self.append: new_fo = open(self.filename, 'ab')
1200 else: new_fo = open(self.filename, 'wb')
1201 bs = 1024*8
1202 size = 0
1203
1204 block = self.read(bs)
1205 size = size + len(block)
1206 while block:
1207 new_fo.write(block)
1208 block = self.read(bs)
1209 size = size + len(block)
1210
1211 new_fo.close()
1212 try:
1213 modified_tuple = self.hdr.getdate_tz('last-modified')
1214 modified_stamp = rfc822.mktime_tz(modified_tuple)
1215 os.utime(self.filename, (modified_stamp, modified_stamp))
1216 except (TypeError,), e: pass
1217
1218 return size
1219
1220 def _fill_buffer(self, amt=None):
1221 """fill the buffer to contain at least 'amt' bytes by reading
1222 from the underlying file object. If amt is None, then it will
1223 read until it gets nothing more. It updates the progress meter
1224 and throttles after every self._rbufsize bytes."""
1225 # the _rbuf test is only in this first 'if' for speed. It's not
1226 # logically necessary
1227 if self._rbuf and not amt is None:
1228 L = len(self._rbuf)
1229 if amt > L:
1230 amt = amt - L
1231 else:
1232 return
1233
1234 # if we've made it here, then we don't have enough in the buffer
1235 # and we need to read more.
1236
1237 buf = [self._rbuf]
1238 bufsize = len(self._rbuf)
1239 while amt is None or amt:
1240 # first, delay if necessary for throttling reasons
1241 if self.opts.raw_throttle():
1242 diff = self._tsize/self.opts.raw_throttle() - \
1243 (time.time() - self._ttime)
1244 if diff > 0: time.sleep(diff)
1245 self._ttime = time.time()
1246
1247 # now read some data, up to self._rbufsize
1248 if amt is None: readamount = self._rbufsize
1249 else: readamount = min(amt, self._rbufsize)
1250 try:
1251 new = self.fo.read(readamount)
1252 except socket.error, e:
1253 raise URLGrabError(4, _('Socket Error: %s') % (e, ))
1254 except TimeoutError, e:
1255 raise URLGrabError(12, _('Timeout: %s') % (e, ))
1256 except IOError, e:
1257 raise URLGrabError(4, _('IOError: %s') %(e,))
1258 newsize = len(new)
1259 if not newsize: break # no more to read
1260
1261 if amt: amt = amt - newsize
1262 buf.append(new)
1263 bufsize = bufsize + newsize
1264 self._tsize = newsize
1265 self._amount_read = self._amount_read + newsize
1266 if self.opts.progress_obj:
1267 self.opts.progress_obj.update(self._amount_read)
1268
1269 self._rbuf = string.join(buf, '')
1270 return
1271
1272 def read(self, amt=None):
1273 self._fill_buffer(amt)
1274 if amt is None:
1275 s, self._rbuf = self._rbuf, ''
1276 else:
1277 s, self._rbuf = self._rbuf[:amt], self._rbuf[amt:]
1278 return s
1279
1280 def readline(self, limit=-1):
1281 i = string.find(self._rbuf, '\n')
1282 while i < 0 and not (0 < limit <= len(self._rbuf)):
1283 L = len(self._rbuf)
1284 self._fill_buffer(L + self._rbufsize)
1285 if not len(self._rbuf) > L: break
1286 i = string.find(self._rbuf, '\n', L)
1287
1288 if i < 0: i = len(self._rbuf)
1289 else: i = i+1
1290 if 0 <= limit < len(self._rbuf): i = limit
1291
1292 s, self._rbuf = self._rbuf[:i], self._rbuf[i:]
1293 return s
1294
1295 def close(self):
1296 if self.opts.progress_obj:
1297 self.opts.progress_obj.end(self._amount_read)
1298 self.fo.close()
1299 if self.opts.close_connection:
1300 try: self.fo.close_connection()
1301 except: pass
1302
1303_handler_cache = []
1304def CachedOpenerDirector(ssl_factory = None, *handlers):
1305 for (cached_handlers, opener) in _handler_cache:
1306 if cached_handlers == handlers:
1307 for handler in opener.handlers:
1308 handler.add_parent(opener)
1309 return opener
1310 if not ssl_factory:
1311 ssl_factory = sslfactory.get_factory()
1312 opener = ssl_factory.create_opener(*handlers)
1313 _handler_cache.append( (handlers, opener) )
1314 return opener
1315
1316_proxy_cache = []
1317def CachedProxyHandler(proxies):
1318 for (pdict, handler) in _proxy_cache:
1319 if pdict == proxies:
1320 if DEBUG: DEBUG.debug('re-using proxy settings: %s', proxies)
1321 break
1322 else:
1323 for k, v in proxies.items():
1324 utype, url = urllib.splittype(v)
1325 host, other = urllib.splithost(url)
1326 if (utype is None) or (host is None):
1327 raise URLGrabError(13, _('Bad proxy URL: %s') % v)
1328
1329 if DEBUG: DEBUG.info('creating new proxy handler: %s', proxies)
1330 handler = urllib2.ProxyHandler(proxies)
1331 _proxy_cache.append( (proxies, handler) )
1332 return handler
1333
1334#####################################################################
1335# DEPRECATED FUNCTIONS
1336def set_throttle(new_throttle):
1337 """Deprecated. Use: default_grabber.throttle = new_throttle"""
1338 default_grabber.throttle = new_throttle
1339
1340def set_bandwidth(new_bandwidth):
1341 """Deprecated. Use: default_grabber.bandwidth = new_bandwidth"""
1342 default_grabber.bandwidth = new_bandwidth
1343
1344def set_progress_obj(new_progress_obj):
1345 """Deprecated. Use: default_grabber.progress_obj = new_progress_obj"""
1346 default_grabber.progress_obj = new_progress_obj
1347
1348def set_user_agent(new_user_agent):
1349 """Deprecated. Use: default_grabber.user_agent = new_user_agent"""
1350 default_grabber.user_agent = new_user_agent
1351
1352def retrygrab(url, filename=None, copy_local=0, close_connection=0,
1353 progress_obj=None, throttle=None, bandwidth=None,
1354 numtries=3, retrycodes=[-1,2,4,5,6,7], checkfunc=None):
1355 """Deprecated. Use: urlgrab() with the retry arg instead"""
1356 kwargs = {'copy_local' : copy_local,
1357 'close_connection' : close_connection,
1358 'progress_obj' : progress_obj,
1359 'throttle' : throttle,
1360 'bandwidth' : bandwidth,
1361 'retry' : numtries,
1362 'retrycodes' : retrycodes,
1363 'checkfunc' : checkfunc
1364 }
1365 return urlgrab(url, filename, **kwargs)
1366
1367
1368#####################################################################
1369# TESTING
1370def _main_test():
1371 import sys
1372 try: url, filename = sys.argv[1:3]
1373 except ValueError:
1374 print 'usage:', sys.argv[0], \
1375 '<url> <filename> [copy_local=0|1] [close_connection=0|1]'
1376 sys.exit()
1377
1378 kwargs = {}
1379 for a in sys.argv[3:]:
1380 k, v = string.split(a, '=', 1)
1381 kwargs[k] = int(v)
1382
1383 set_throttle(1.0)
1384 set_bandwidth(32 * 1024)
1385 print "throttle: %s, throttle bandwidth: %s B/s" % (default_grabber.throttle,
1386 default_grabber.bandwidth)
1387
1388 try: from progress import text_progress_meter
1389 except ImportError, e: pass
1390 else: kwargs['progress_obj'] = text_progress_meter()
1391
1392 try: name = apply(urlgrab, (url, filename), kwargs)
1393 except URLGrabError, e: print e
1394 else: print 'LOCAL FILE:', name
1395
1396
1397def _retry_test():
1398 import sys
1399 try: url, filename = sys.argv[1:3]
1400 except ValueError:
1401 print 'usage:', sys.argv[0], \
1402 '<url> <filename> [copy_local=0|1] [close_connection=0|1]'
1403 sys.exit()
1404
1405 kwargs = {}
1406 for a in sys.argv[3:]:
1407 k, v = string.split(a, '=', 1)
1408 kwargs[k] = int(v)
1409
1410 try: from progress import text_progress_meter
1411 except ImportError, e: pass
1412 else: kwargs['progress_obj'] = text_progress_meter()
1413
1414 def cfunc(filename, hello, there='foo'):
1415 print hello, there
1416 import random
1417 rnum = random.random()
1418 if rnum < .5:
1419 print 'forcing retry'
1420 raise URLGrabError(-1, 'forcing retry')
1421 if rnum < .75:
1422 print 'forcing failure'
1423 raise URLGrabError(-2, 'forcing immediate failure')
1424 print 'success'
1425 return
1426
1427 kwargs['checkfunc'] = (cfunc, ('hello',), {'there':'there'})
1428 try: name = apply(retrygrab, (url, filename), kwargs)
1429 except URLGrabError, e: print e
1430 else: print 'LOCAL FILE:', name
1431
1432def _file_object_test(filename=None):
1433 import random, cStringIO, sys
1434 if filename is None:
1435 filename = __file__
1436 print 'using file "%s" for comparisons' % filename
1437 fo = open(filename)
1438 s_input = fo.read()
1439 fo.close()
1440
1441 for testfunc in [_test_file_object_smallread,
1442 _test_file_object_readall,
1443 _test_file_object_readline,
1444 _test_file_object_readlines]:
1445 fo_input = cStringIO.StringIO(s_input)
1446 fo_output = cStringIO.StringIO()
1447 wrapper = URLGrabberFileObject(fo_input, None, 0)
1448 print 'testing %-30s ' % testfunc.__name__,
1449 testfunc(wrapper, fo_output)
1450 s_output = fo_output.getvalue()
1451 if s_output == s_input: print 'passed'
1452 else: print 'FAILED'
1453
1454def _test_file_object_smallread(wrapper, fo_output):
1455 while 1:
1456 s = wrapper.read(23)
1457 fo_output.write(s)
1458 if not s: return
1459
1460def _test_file_object_readall(wrapper, fo_output):
1461 s = wrapper.read()
1462 fo_output.write(s)
1463
1464def _test_file_object_readline(wrapper, fo_output):
1465 while 1:
1466 s = wrapper.readline()
1467 fo_output.write(s)
1468 if not s: return
1469
1470def _test_file_object_readlines(wrapper, fo_output):
1471 li = wrapper.readlines()
1472 fo_output.write(string.join(li, ''))
1473
1474if __name__ == '__main__':
1475 _main_test()
1476 _retry_test()
1477 _file_object_test('test')
diff --git a/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/keepalive.py b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/keepalive.py
new file mode 100644
index 0000000000..71393e2b8d
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/keepalive.py
@@ -0,0 +1,617 @@
1# This library is free software; you can redistribute it and/or
2# modify it under the terms of the GNU Lesser General Public
3# License as published by the Free Software Foundation; either
4# version 2.1 of the License, or (at your option) any later version.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the
13# Free Software Foundation, Inc.,
14# 59 Temple Place, Suite 330,
15# Boston, MA 02111-1307 USA
16
17# This file is part of urlgrabber, a high-level cross-protocol url-grabber
18# Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
19
20"""An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive.
21
22>>> import urllib2
23>>> from keepalive import HTTPHandler
24>>> keepalive_handler = HTTPHandler()
25>>> opener = urllib2.build_opener(keepalive_handler)
26>>> urllib2.install_opener(opener)
27>>>
28>>> fo = urllib2.urlopen('http://www.python.org')
29
30If a connection to a given host is requested, and all of the existing
31connections are still in use, another connection will be opened. If
32the handler tries to use an existing connection but it fails in some
33way, it will be closed and removed from the pool.
34
35To remove the handler, simply re-run build_opener with no arguments, and
36install that opener.
37
38You can explicitly close connections by using the close_connection()
39method of the returned file-like object (described below) or you can
40use the handler methods:
41
42 close_connection(host)
43 close_all()
44 open_connections()
45
46NOTE: using the close_connection and close_all methods of the handler
47should be done with care when using multiple threads.
48 * there is nothing that prevents another thread from creating new
49 connections immediately after connections are closed
50 * no checks are done to prevent in-use connections from being closed
51
52>>> keepalive_handler.close_all()
53
54EXTRA ATTRIBUTES AND METHODS
55
56 Upon a status of 200, the object returned has a few additional
57 attributes and methods, which should not be used if you want to
58 remain consistent with the normal urllib2-returned objects:
59
60 close_connection() - close the connection to the host
61 readlines() - you know, readlines()
62 status - the return status (ie 404)
63 reason - english translation of status (ie 'File not found')
64
65 If you want the best of both worlds, use this inside an
66 AttributeError-catching try:
67
68 >>> try: status = fo.status
69 >>> except AttributeError: status = None
70
71 Unfortunately, these are ONLY there if status == 200, so it's not
72 easy to distinguish between non-200 responses. The reason is that
73 urllib2 tries to do clever things with error codes 301, 302, 401,
74 and 407, and it wraps the object upon return.
75
76 For python versions earlier than 2.4, you can avoid this fancy error
77 handling by setting the module-level global HANDLE_ERRORS to zero.
78 You see, prior to 2.4, it's the HTTP Handler's job to determine what
79 to handle specially, and what to just pass up. HANDLE_ERRORS == 0
80 means "pass everything up". In python 2.4, however, this job no
81 longer belongs to the HTTP Handler and is now done by a NEW handler,
82 HTTPErrorProcessor. Here's the bottom line:
83
84 python version < 2.4
85 HANDLE_ERRORS == 1 (default) pass up 200, treat the rest as
86 errors
87 HANDLE_ERRORS == 0 pass everything up, error processing is
88 left to the calling code
89 python version >= 2.4
90 HANDLE_ERRORS == 1 pass up 200, treat the rest as errors
91 HANDLE_ERRORS == 0 (default) pass everything up, let the
92 other handlers (specifically,
93 HTTPErrorProcessor) decide what to do
94
95 In practice, setting the variable either way makes little difference
96 in python 2.4, so for the most consistent behavior across versions,
97 you probably just want to use the defaults, which will give you
98 exceptions on errors.
99
100"""
101
102# $Id: keepalive.py,v 1.16 2006/09/22 00:58:05 mstenner Exp $
103
104import urllib2
105import httplib
106import socket
107import thread
108
109DEBUG = None
110
111import sslfactory
112
113import sys
114if sys.version_info < (2, 4): HANDLE_ERRORS = 1
115else: HANDLE_ERRORS = 0
116
117class ConnectionManager:
118 """
119 The connection manager must be able to:
120 * keep track of all existing
121 """
122 def __init__(self):
123 self._lock = thread.allocate_lock()
124 self._hostmap = {} # map hosts to a list of connections
125 self._connmap = {} # map connections to host
126 self._readymap = {} # map connection to ready state
127
128 def add(self, host, connection, ready):
129 self._lock.acquire()
130 try:
131 if not self._hostmap.has_key(host): self._hostmap[host] = []
132 self._hostmap[host].append(connection)
133 self._connmap[connection] = host
134 self._readymap[connection] = ready
135 finally:
136 self._lock.release()
137
138 def remove(self, connection):
139 self._lock.acquire()
140 try:
141 try:
142 host = self._connmap[connection]
143 except KeyError:
144 pass
145 else:
146 del self._connmap[connection]
147 del self._readymap[connection]
148 self._hostmap[host].remove(connection)
149 if not self._hostmap[host]: del self._hostmap[host]
150 finally:
151 self._lock.release()
152
153 def set_ready(self, connection, ready):
154 try: self._readymap[connection] = ready
155 except KeyError: pass
156
157 def get_ready_conn(self, host):
158 conn = None
159 self._lock.acquire()
160 try:
161 if self._hostmap.has_key(host):
162 for c in self._hostmap[host]:
163 if self._readymap[c]:
164 self._readymap[c] = 0
165 conn = c
166 break
167 finally:
168 self._lock.release()
169 return conn
170
171 def get_all(self, host=None):
172 if host:
173 return list(self._hostmap.get(host, []))
174 else:
175 return dict(self._hostmap)
176
177class KeepAliveHandler:
178 def __init__(self):
179 self._cm = ConnectionManager()
180
181 #### Connection Management
182 def open_connections(self):
183 """return a list of connected hosts and the number of connections
184 to each. [('foo.com:80', 2), ('bar.org', 1)]"""
185 return [(host, len(li)) for (host, li) in self._cm.get_all().items()]
186
187 def close_connection(self, host):
188 """close connection(s) to <host>
189 host is the host:port spec, as in 'www.cnn.com:8080' as passed in.
190 no error occurs if there is no connection to that host."""
191 for h in self._cm.get_all(host):
192 self._cm.remove(h)
193 h.close()
194
195 def close_all(self):
196 """close all open connections"""
197 for host, conns in self._cm.get_all().items():
198 for h in conns:
199 self._cm.remove(h)
200 h.close()
201
202 def _request_closed(self, request, host, connection):
203 """tells us that this request is now closed and the the
204 connection is ready for another request"""
205 self._cm.set_ready(connection, 1)
206
207 def _remove_connection(self, host, connection, close=0):
208 if close: connection.close()
209 self._cm.remove(connection)
210
211 #### Transaction Execution
212 def do_open(self, req):
213 host = req.get_host()
214 if not host:
215 raise urllib2.URLError('no host given')
216
217 try:
218 h = self._cm.get_ready_conn(host)
219 while h:
220 r = self._reuse_connection(h, req, host)
221
222 # if this response is non-None, then it worked and we're
223 # done. Break out, skipping the else block.
224 if r: break
225
226 # connection is bad - possibly closed by server
227 # discard it and ask for the next free connection
228 h.close()
229 self._cm.remove(h)
230 h = self._cm.get_ready_conn(host)
231 else:
232 # no (working) free connections were found. Create a new one.
233 h = self._get_connection(host)
234 if DEBUG: DEBUG.info("creating new connection to %s (%d)",
235 host, id(h))
236 self._cm.add(host, h, 0)
237 self._start_transaction(h, req)
238 r = h.getresponse()
239 except (socket.error, httplib.HTTPException), err:
240 raise urllib2.URLError(err)
241
242 # if not a persistent connection, don't try to reuse it
243 if r.will_close: self._cm.remove(h)
244
245 if DEBUG: DEBUG.info("STATUS: %s, %s", r.status, r.reason)
246 r._handler = self
247 r._host = host
248 r._url = req.get_full_url()
249 r._connection = h
250 r.code = r.status
251 r.headers = r.msg
252 r.msg = r.reason
253
254 if r.status == 200 or not HANDLE_ERRORS:
255 return r
256 else:
257 return self.parent.error('http', req, r,
258 r.status, r.msg, r.headers)
259
260 def _reuse_connection(self, h, req, host):
261 """start the transaction with a re-used connection
262 return a response object (r) upon success or None on failure.
263 This DOES not close or remove bad connections in cases where
264 it returns. However, if an unexpected exception occurs, it
265 will close and remove the connection before re-raising.
266 """
267 try:
268 self._start_transaction(h, req)
269 r = h.getresponse()
270 # note: just because we got something back doesn't mean it
271 # worked. We'll check the version below, too.
272 except (socket.error, httplib.HTTPException):
273 r = None
274 except:
275 # adding this block just in case we've missed
276 # something we will still raise the exception, but
277 # lets try and close the connection and remove it
278 # first. We previously got into a nasty loop
279 # where an exception was uncaught, and so the
280 # connection stayed open. On the next try, the
281 # same exception was raised, etc. The tradeoff is
282 # that it's now possible this call will raise
283 # a DIFFERENT exception
284 if DEBUG: DEBUG.error("unexpected exception - closing " + \
285 "connection to %s (%d)", host, id(h))
286 self._cm.remove(h)
287 h.close()
288 raise
289
290 if r is None or r.version == 9:
291 # httplib falls back to assuming HTTP 0.9 if it gets a
292 # bad header back. This is most likely to happen if
293 # the socket has been closed by the server since we
294 # last used the connection.
295 if DEBUG: DEBUG.info("failed to re-use connection to %s (%d)",
296 host, id(h))
297 r = None
298 else:
299 if DEBUG: DEBUG.info("re-using connection to %s (%d)", host, id(h))
300
301 return r
302
303 def _start_transaction(self, h, req):
304 try:
305 if req.has_data():
306 data = req.get_data()
307 h.putrequest('POST', req.get_selector())
308 if not req.headers.has_key('Content-type'):
309 h.putheader('Content-type',
310 'application/x-www-form-urlencoded')
311 if not req.headers.has_key('Content-length'):
312 h.putheader('Content-length', '%d' % len(data))
313 else:
314 h.putrequest('GET', req.get_selector())
315 except (socket.error, httplib.HTTPException), err:
316 raise urllib2.URLError(err)
317
318 for args in self.parent.addheaders:
319 h.putheader(*args)
320 for k, v in req.headers.items():
321 h.putheader(k, v)
322 h.endheaders()
323 if req.has_data():
324 h.send(data)
325
326 def _get_connection(self, host):
327 return NotImplementedError
328
329class HTTPHandler(KeepAliveHandler, urllib2.HTTPHandler):
330 def __init__(self):
331 KeepAliveHandler.__init__(self)
332
333 def http_open(self, req):
334 return self.do_open(req)
335
336 def _get_connection(self, host):
337 return HTTPConnection(host)
338
339class HTTPSHandler(KeepAliveHandler, urllib2.HTTPSHandler):
340 def __init__(self, ssl_factory=None):
341 KeepAliveHandler.__init__(self)
342 if not ssl_factory:
343 ssl_factory = sslfactory.get_factory()
344 self._ssl_factory = ssl_factory
345
346 def https_open(self, req):
347 return self.do_open(req)
348
349 def _get_connection(self, host):
350 return self._ssl_factory.get_https_connection(host)
351
352class HTTPResponse(httplib.HTTPResponse):
353 # we need to subclass HTTPResponse in order to
354 # 1) add readline() and readlines() methods
355 # 2) add close_connection() methods
356 # 3) add info() and geturl() methods
357
358 # in order to add readline(), read must be modified to deal with a
359 # buffer. example: readline must read a buffer and then spit back
360 # one line at a time. The only real alternative is to read one
361 # BYTE at a time (ick). Once something has been read, it can't be
362 # put back (ok, maybe it can, but that's even uglier than this),
363 # so if you THEN do a normal read, you must first take stuff from
364 # the buffer.
365
366 # the read method wraps the original to accomodate buffering,
367 # although read() never adds to the buffer.
368 # Both readline and readlines have been stolen with almost no
369 # modification from socket.py
370
371
372 def __init__(self, sock, debuglevel=0, strict=0, method=None):
373 if method: # the httplib in python 2.3 uses the method arg
374 httplib.HTTPResponse.__init__(self, sock, debuglevel, method)
375 else: # 2.2 doesn't
376 httplib.HTTPResponse.__init__(self, sock, debuglevel)
377 self.fileno = sock.fileno
378 self.code = None
379 self._rbuf = ''
380 self._rbufsize = 8096
381 self._handler = None # inserted by the handler later
382 self._host = None # (same)
383 self._url = None # (same)
384 self._connection = None # (same)
385
386 _raw_read = httplib.HTTPResponse.read
387
388 def close(self):
389 if self.fp:
390 self.fp.close()
391 self.fp = None
392 if self._handler:
393 self._handler._request_closed(self, self._host,
394 self._connection)
395
396 def close_connection(self):
397 self._handler._remove_connection(self._host, self._connection, close=1)
398 self.close()
399
400 def info(self):
401 return self.headers
402
403 def geturl(self):
404 return self._url
405
406 def read(self, amt=None):
407 # the _rbuf test is only in this first if for speed. It's not
408 # logically necessary
409 if self._rbuf and not amt is None:
410 L = len(self._rbuf)
411 if amt > L:
412 amt -= L
413 else:
414 s = self._rbuf[:amt]
415 self._rbuf = self._rbuf[amt:]
416 return s
417
418 s = self._rbuf + self._raw_read(amt)
419 self._rbuf = ''
420 return s
421
422 def readline(self, limit=-1):
423 data = ""
424 i = self._rbuf.find('\n')
425 while i < 0 and not (0 < limit <= len(self._rbuf)):
426 new = self._raw_read(self._rbufsize)
427 if not new: break
428 i = new.find('\n')
429 if i >= 0: i = i + len(self._rbuf)
430 self._rbuf = self._rbuf + new
431 if i < 0: i = len(self._rbuf)
432 else: i = i+1
433 if 0 <= limit < len(self._rbuf): i = limit
434 data, self._rbuf = self._rbuf[:i], self._rbuf[i:]
435 return data
436
437 def readlines(self, sizehint = 0):
438 total = 0
439 list = []
440 while 1:
441 line = self.readline()
442 if not line: break
443 list.append(line)
444 total += len(line)
445 if sizehint and total >= sizehint:
446 break
447 return list
448
449
450class HTTPConnection(httplib.HTTPConnection):
451 # use the modified response class
452 response_class = HTTPResponse
453
454class HTTPSConnection(httplib.HTTPSConnection):
455 response_class = HTTPResponse
456
457#########################################################################
458##### TEST FUNCTIONS
459#########################################################################
460
461def error_handler(url):
462 global HANDLE_ERRORS
463 orig = HANDLE_ERRORS
464 keepalive_handler = HTTPHandler()
465 opener = urllib2.build_opener(keepalive_handler)
466 urllib2.install_opener(opener)
467 pos = {0: 'off', 1: 'on'}
468 for i in (0, 1):
469 print " fancy error handling %s (HANDLE_ERRORS = %i)" % (pos[i], i)
470 HANDLE_ERRORS = i
471 try:
472 fo = urllib2.urlopen(url)
473 foo = fo.read()
474 fo.close()
475 try: status, reason = fo.status, fo.reason
476 except AttributeError: status, reason = None, None
477 except IOError, e:
478 print " EXCEPTION: %s" % e
479 raise
480 else:
481 print " status = %s, reason = %s" % (status, reason)
482 HANDLE_ERRORS = orig
483 hosts = keepalive_handler.open_connections()
484 print "open connections:", hosts
485 keepalive_handler.close_all()
486
487def continuity(url):
488 import md5
489 format = '%25s: %s'
490
491 # first fetch the file with the normal http handler
492 opener = urllib2.build_opener()
493 urllib2.install_opener(opener)
494 fo = urllib2.urlopen(url)
495 foo = fo.read()
496 fo.close()
497 m = md5.new(foo)
498 print format % ('normal urllib', m.hexdigest())
499
500 # now install the keepalive handler and try again
501 opener = urllib2.build_opener(HTTPHandler())
502 urllib2.install_opener(opener)
503
504 fo = urllib2.urlopen(url)
505 foo = fo.read()
506 fo.close()
507 m = md5.new(foo)
508 print format % ('keepalive read', m.hexdigest())
509
510 fo = urllib2.urlopen(url)
511 foo = ''
512 while 1:
513 f = fo.readline()
514 if f: foo = foo + f
515 else: break
516 fo.close()
517 m = md5.new(foo)
518 print format % ('keepalive readline', m.hexdigest())
519
520def comp(N, url):
521 print ' making %i connections to:\n %s' % (N, url)
522
523 sys.stdout.write(' first using the normal urllib handlers')
524 # first use normal opener
525 opener = urllib2.build_opener()
526 urllib2.install_opener(opener)
527 t1 = fetch(N, url)
528 print ' TIME: %.3f s' % t1
529
530 sys.stdout.write(' now using the keepalive handler ')
531 # now install the keepalive handler and try again
532 opener = urllib2.build_opener(HTTPHandler())
533 urllib2.install_opener(opener)
534 t2 = fetch(N, url)
535 print ' TIME: %.3f s' % t2
536 print ' improvement factor: %.2f' % (t1/t2, )
537
538def fetch(N, url, delay=0):
539 import time
540 lens = []
541 starttime = time.time()
542 for i in range(N):
543 if delay and i > 0: time.sleep(delay)
544 fo = urllib2.urlopen(url)
545 foo = fo.read()
546 fo.close()
547 lens.append(len(foo))
548 diff = time.time() - starttime
549
550 j = 0
551 for i in lens[1:]:
552 j = j + 1
553 if not i == lens[0]:
554 print "WARNING: inconsistent length on read %i: %i" % (j, i)
555
556 return diff
557
558def test_timeout(url):
559 global DEBUG
560 dbbackup = DEBUG
561 class FakeLogger:
562 def debug(self, msg, *args): print msg % args
563 info = warning = error = debug
564 DEBUG = FakeLogger()
565 print " fetching the file to establish a connection"
566 fo = urllib2.urlopen(url)
567 data1 = fo.read()
568 fo.close()
569
570 i = 20
571 print " waiting %i seconds for the server to close the connection" % i
572 while i > 0:
573 sys.stdout.write('\r %2i' % i)
574 sys.stdout.flush()
575 time.sleep(1)
576 i -= 1
577 sys.stderr.write('\r')
578
579 print " fetching the file a second time"
580 fo = urllib2.urlopen(url)
581 data2 = fo.read()
582 fo.close()
583
584 if data1 == data2:
585 print ' data are identical'
586 else:
587 print ' ERROR: DATA DIFFER'
588
589 DEBUG = dbbackup
590
591
592def test(url, N=10):
593 print "checking error hander (do this on a non-200)"
594 try: error_handler(url)
595 except IOError, e:
596 print "exiting - exception will prevent further tests"
597 sys.exit()
598 print
599 print "performing continuity test (making sure stuff isn't corrupted)"
600 continuity(url)
601 print
602 print "performing speed comparison"
603 comp(N, url)
604 print
605 print "performing dropped-connection check"
606 test_timeout(url)
607
608if __name__ == '__main__':
609 import time
610 import sys
611 try:
612 N = int(sys.argv[1])
613 url = sys.argv[2]
614 except:
615 print "%s <integer> <url>" % sys.argv[0]
616 else:
617 test(url, N)
diff --git a/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/mirror.py b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/mirror.py
new file mode 100644
index 0000000000..9664c6b5c5
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/mirror.py
@@ -0,0 +1,458 @@
1# This library is free software; you can redistribute it and/or
2# modify it under the terms of the GNU Lesser General Public
3# License as published by the Free Software Foundation; either
4# version 2.1 of the License, or (at your option) any later version.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the
13# Free Software Foundation, Inc.,
14# 59 Temple Place, Suite 330,
15# Boston, MA 02111-1307 USA
16
17# This file is part of urlgrabber, a high-level cross-protocol url-grabber
18# Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
19
20"""Module for downloading files from a pool of mirrors
21
22DESCRIPTION
23
24 This module provides support for downloading files from a pool of
25 mirrors with configurable failover policies. To a large extent, the
26 failover policy is chosen by using different classes derived from
27 the main class, MirrorGroup.
28
29 Instances of MirrorGroup (and cousins) act very much like URLGrabber
30 instances in that they have urlread, urlgrab, and urlopen methods.
31 They can therefore, be used in very similar ways.
32
33 from urlgrabber.grabber import URLGrabber
34 from urlgrabber.mirror import MirrorGroup
35 gr = URLGrabber()
36 mg = MirrorGroup(gr, ['http://foo.com/some/directory/',
37 'http://bar.org/maybe/somewhere/else/',
38 'ftp://baz.net/some/other/place/entirely/']
39 mg.urlgrab('relative/path.zip')
40
41 The assumption is that all mirrors are identical AFTER the base urls
42 specified, so that any mirror can be used to fetch any file.
43
44FAILOVER
45
46 The failover mechanism is designed to be customized by subclassing
47 from MirrorGroup to change the details of the behavior. In general,
48 the classes maintain a master mirror list and a "current mirror"
49 index. When a download is initiated, a copy of this list and index
50 is created for that download only. The specific failover policy
51 depends on the class used, and so is documented in the class
52 documentation. Note that ANY behavior of the class can be
53 overridden, so any failover policy at all is possible (although
54 you may need to change the interface in extreme cases).
55
56CUSTOMIZATION
57
58 Most customization of a MirrorGroup object is done at instantiation
59 time (or via subclassing). There are four major types of
60 customization:
61
62 1) Pass in a custom urlgrabber - The passed in urlgrabber will be
63 used (by default... see #2) for the grabs, so options to it
64 apply for the url-fetching
65
66 2) Custom mirror list - Mirror lists can simply be a list of
67 stings mirrors (as shown in the example above) but each can
68 also be a dict, allowing for more options. For example, the
69 first mirror in the list above could also have been:
70
71 {'mirror': 'http://foo.com/some/directory/',
72 'grabber': <a custom grabber to be used for this mirror>,
73 'kwargs': { <a dict of arguments passed to the grabber> }}
74
75 All mirrors are converted to this format internally. If
76 'grabber' is omitted, the default grabber will be used. If
77 kwargs are omitted, then (duh) they will not be used.
78
79 3) Pass keyword arguments when instantiating the mirror group.
80 See, for example, the failure_callback argument.
81
82 4) Finally, any kwargs passed in for the specific file (to the
83 urlgrab method, for example) will be folded in. The options
84 passed into the grabber's urlXXX methods will override any
85 options specified in a custom mirror dict.
86
87"""
88
89# $Id: mirror.py,v 1.14 2006/02/22 18:26:46 mstenner Exp $
90
91import random
92import thread # needed for locking to make this threadsafe
93
94from grabber import URLGrabError, CallbackObject, DEBUG
95
96try:
97 from i18n import _
98except ImportError, msg:
99 def _(st): return st
100
101class GrabRequest:
102 """This is a dummy class used to hold information about the specific
103 request. For example, a single file. By maintaining this information
104 separately, we can accomplish two things:
105
106 1) make it a little easier to be threadsafe
107 2) have request-specific parameters
108 """
109 pass
110
111class MirrorGroup:
112 """Base Mirror class
113
114 Instances of this class are built with a grabber object and a list
115 of mirrors. Then all calls to urlXXX should be passed relative urls.
116 The requested file will be searched for on the first mirror. If the
117 grabber raises an exception (possibly after some retries) then that
118 mirror will be removed from the list, and the next will be attempted.
119 If all mirrors are exhausted, then an exception will be raised.
120
121 MirrorGroup has the following failover policy:
122
123 * downloads begin with the first mirror
124
125 * by default (see default_action below) a failure (after retries)
126 causes it to increment the local AND master indices. Also,
127 the current mirror is removed from the local list (but NOT the
128 master list - the mirror can potentially be used for other
129 files)
130
131 * if the local list is ever exhausted, a URLGrabError will be
132 raised (errno=256, no more mirrors)
133
134 OPTIONS
135
136 In addition to the required arguments "grabber" and "mirrors",
137 MirrorGroup also takes the following optional arguments:
138
139 default_action
140
141 A dict that describes the actions to be taken upon failure
142 (after retries). default_action can contain any of the
143 following keys (shown here with their default values):
144
145 default_action = {'increment': 1,
146 'increment_master': 1,
147 'remove': 1,
148 'remove_master': 0,
149 'fail': 0}
150
151 In this context, 'increment' means "use the next mirror" and
152 'remove' means "never use this mirror again". The two
153 'master' values refer to the instance-level mirror list (used
154 for all files), whereas the non-master values refer to the
155 current download only.
156
157 The 'fail' option will cause immediate failure by re-raising
158 the exception and no further attempts to get the current
159 download.
160
161 This dict can be set at instantiation time,
162 mg = MirrorGroup(grabber, mirrors, default_action={'fail':1})
163 at method-execution time (only applies to current fetch),
164 filename = mg.urlgrab(url, default_action={'increment': 0})
165 or by returning an action dict from the failure_callback
166 return {'fail':0}
167 in increasing precedence.
168
169 If all three of these were done, the net result would be:
170 {'increment': 0, # set in method
171 'increment_master': 1, # class default
172 'remove': 1, # class default
173 'remove_master': 0, # class default
174 'fail': 0} # set at instantiation, reset
175 # from callback
176
177 failure_callback
178
179 this is a callback that will be called when a mirror "fails",
180 meaning the grabber raises some URLGrabError. If this is a
181 tuple, it is interpreted to be of the form (cb, args, kwargs)
182 where cb is the actual callable object (function, method,
183 etc). Otherwise, it is assumed to be the callable object
184 itself. The callback will be passed a grabber.CallbackObject
185 instance along with args and kwargs (if present). The following
186 attributes are defined withing the instance:
187
188 obj.exception = < exception that was raised >
189 obj.mirror = < the mirror that was tried >
190 obj.relative_url = < url relative to the mirror >
191 obj.url = < full url that failed >
192 # .url is just the combination of .mirror
193 # and .relative_url
194
195 The failure callback can return an action dict, as described
196 above.
197
198 Like default_action, the failure_callback can be set at
199 instantiation time or when the urlXXX method is called. In
200 the latter case, it applies only for that fetch.
201
202 The callback can re-raise the exception quite easily. For
203 example, this is a perfectly adequate callback function:
204
205 def callback(obj): raise obj.exception
206
207 WARNING: do not save the exception object (or the
208 CallbackObject instance). As they contain stack frame
209 references, they can lead to circular references.
210
211 Notes:
212 * The behavior can be customized by deriving and overriding the
213 'CONFIGURATION METHODS'
214 * The 'grabber' instance is kept as a reference, not copied.
215 Therefore, the grabber instance can be modified externally
216 and changes will take effect immediately.
217 """
218
219 # notes on thread-safety:
220
221 # A GrabRequest should never be shared by multiple threads because
222 # it's never saved inside the MG object and never returned outside it.
223 # therefore, it should be safe to access/modify grabrequest data
224 # without a lock. However, accessing the mirrors and _next attributes
225 # of the MG itself must be done when locked to prevent (for example)
226 # removal of the wrong mirror.
227
228 ##############################################################
229 # CONFIGURATION METHODS - intended to be overridden to
230 # customize behavior
231 def __init__(self, grabber, mirrors, **kwargs):
232 """Initialize the MirrorGroup object.
233
234 REQUIRED ARGUMENTS
235
236 grabber - URLGrabber instance
237 mirrors - a list of mirrors
238
239 OPTIONAL ARGUMENTS
240
241 failure_callback - callback to be used when a mirror fails
242 default_action - dict of failure actions
243
244 See the module-level and class level documentation for more
245 details.
246 """
247
248 # OVERRIDE IDEAS:
249 # shuffle the list to randomize order
250 self.grabber = grabber
251 self.mirrors = self._parse_mirrors(mirrors)
252 self._next = 0
253 self._lock = thread.allocate_lock()
254 self.default_action = None
255 self._process_kwargs(kwargs)
256
257 # if these values are found in **kwargs passed to one of the urlXXX
258 # methods, they will be stripped before getting passed on to the
259 # grabber
260 options = ['default_action', 'failure_callback']
261
262 def _process_kwargs(self, kwargs):
263 self.failure_callback = kwargs.get('failure_callback')
264 self.default_action = kwargs.get('default_action')
265
266 def _parse_mirrors(self, mirrors):
267 parsed_mirrors = []
268 for m in mirrors:
269 if type(m) == type(''): m = {'mirror': m}
270 parsed_mirrors.append(m)
271 return parsed_mirrors
272
273 def _load_gr(self, gr):
274 # OVERRIDE IDEAS:
275 # shuffle gr list
276 self._lock.acquire()
277 gr.mirrors = list(self.mirrors)
278 gr._next = self._next
279 self._lock.release()
280
281 def _get_mirror(self, gr):
282 # OVERRIDE IDEAS:
283 # return a random mirror so that multiple mirrors get used
284 # even without failures.
285 if not gr.mirrors:
286 raise URLGrabError(256, _('No more mirrors to try.'))
287 return gr.mirrors[gr._next]
288
289 def _failure(self, gr, cb_obj):
290 # OVERRIDE IDEAS:
291 # inspect the error - remove=1 for 404, remove=2 for connection
292 # refused, etc. (this can also be done via
293 # the callback)
294 cb = gr.kw.get('failure_callback') or self.failure_callback
295 if cb:
296 if type(cb) == type( () ):
297 cb, args, kwargs = cb
298 else:
299 args, kwargs = (), {}
300 action = cb(cb_obj, *args, **kwargs) or {}
301 else:
302 action = {}
303 # XXXX - decide - there are two ways to do this
304 # the first is action-overriding as a whole - use the entire action
305 # or fall back on module level defaults
306 #action = action or gr.kw.get('default_action') or self.default_action
307 # the other is to fall through for each element in the action dict
308 a = dict(self.default_action or {})
309 a.update(gr.kw.get('default_action', {}))
310 a.update(action)
311 action = a
312 self.increment_mirror(gr, action)
313 if action and action.get('fail', 0): raise
314
315 def increment_mirror(self, gr, action={}):
316 """Tell the mirror object increment the mirror index
317
318 This increments the mirror index, which amounts to telling the
319 mirror object to use a different mirror (for this and future
320 downloads).
321
322 This is a SEMI-public method. It will be called internally,
323 and you may never need to call it. However, it is provided
324 (and is made public) so that the calling program can increment
325 the mirror choice for methods like urlopen. For example, with
326 urlopen, there's no good way for the mirror group to know that
327 an error occurs mid-download (it's already returned and given
328 you the file object).
329
330 remove --- can have several values
331 0 do not remove the mirror from the list
332 1 remove the mirror for this download only
333 2 remove the mirror permanently
334
335 beware of remove=0 as it can lead to infinite loops
336 """
337 badmirror = gr.mirrors[gr._next]
338
339 self._lock.acquire()
340 try:
341 ind = self.mirrors.index(badmirror)
342 except ValueError:
343 pass
344 else:
345 if action.get('remove_master', 0):
346 del self.mirrors[ind]
347 elif self._next == ind and action.get('increment_master', 1):
348 self._next += 1
349 if self._next >= len(self.mirrors): self._next = 0
350 self._lock.release()
351
352 if action.get('remove', 1):
353 del gr.mirrors[gr._next]
354 elif action.get('increment', 1):
355 gr._next += 1
356 if gr._next >= len(gr.mirrors): gr._next = 0
357
358 if DEBUG:
359 grm = [m['mirror'] for m in gr.mirrors]
360 DEBUG.info('GR mirrors: [%s] %i', ' '.join(grm), gr._next)
361 selfm = [m['mirror'] for m in self.mirrors]
362 DEBUG.info('MAIN mirrors: [%s] %i', ' '.join(selfm), self._next)
363
364 #####################################################################
365 # NON-CONFIGURATION METHODS
366 # these methods are designed to be largely workhorse methods that
367 # are not intended to be overridden. That doesn't mean you can't;
368 # if you want to, feel free, but most things can be done by
369 # by overriding the configuration methods :)
370
371 def _join_url(self, base_url, rel_url):
372 if base_url.endswith('/') or rel_url.startswith('/'):
373 return base_url + rel_url
374 else:
375 return base_url + '/' + rel_url
376
377 def _mirror_try(self, func, url, kw):
378 gr = GrabRequest()
379 gr.func = func
380 gr.url = url
381 gr.kw = dict(kw)
382 self._load_gr(gr)
383
384 for k in self.options:
385 try: del kw[k]
386 except KeyError: pass
387
388 while 1:
389 mirrorchoice = self._get_mirror(gr)
390 fullurl = self._join_url(mirrorchoice['mirror'], gr.url)
391 kwargs = dict(mirrorchoice.get('kwargs', {}))
392 kwargs.update(kw)
393 grabber = mirrorchoice.get('grabber') or self.grabber
394 func_ref = getattr(grabber, func)
395 if DEBUG: DEBUG.info('MIRROR: trying %s -> %s', url, fullurl)
396 try:
397 return func_ref( *(fullurl,), **kwargs )
398 except URLGrabError, e:
399 if DEBUG: DEBUG.info('MIRROR: failed')
400 obj = CallbackObject()
401 obj.exception = e
402 obj.mirror = mirrorchoice['mirror']
403 obj.relative_url = gr.url
404 obj.url = fullurl
405 self._failure(gr, obj)
406
407 def urlgrab(self, url, filename=None, **kwargs):
408 kw = dict(kwargs)
409 kw['filename'] = filename
410 func = 'urlgrab'
411 return self._mirror_try(func, url, kw)
412
413 def urlopen(self, url, **kwargs):
414 kw = dict(kwargs)
415 func = 'urlopen'
416 return self._mirror_try(func, url, kw)
417
418 def urlread(self, url, limit=None, **kwargs):
419 kw = dict(kwargs)
420 kw['limit'] = limit
421 func = 'urlread'
422 return self._mirror_try(func, url, kw)
423
424
425class MGRandomStart(MirrorGroup):
426 """A mirror group that starts at a random mirror in the list.
427
428 This behavior of this class is identical to MirrorGroup, except that
429 it starts at a random location in the mirror list.
430 """
431
432 def __init__(self, grabber, mirrors, **kwargs):
433 """Initialize the object
434
435 The arguments for intialization are the same as for MirrorGroup
436 """
437 MirrorGroup.__init__(self, grabber, mirrors, **kwargs)
438 self._next = random.randrange(len(mirrors))
439
440class MGRandomOrder(MirrorGroup):
441 """A mirror group that uses mirrors in a random order.
442
443 This behavior of this class is identical to MirrorGroup, except that
444 it uses the mirrors in a random order. Note that the order is set at
445 initialization time and fixed thereafter. That is, it does not pick a
446 random mirror after each failure.
447 """
448
449 def __init__(self, grabber, mirrors, **kwargs):
450 """Initialize the object
451
452 The arguments for intialization are the same as for MirrorGroup
453 """
454 MirrorGroup.__init__(self, grabber, mirrors, **kwargs)
455 random.shuffle(self.mirrors)
456
457if __name__ == '__main__':
458 pass
diff --git a/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/progress.py b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/progress.py
new file mode 100644
index 0000000000..02db524e76
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/progress.py
@@ -0,0 +1,530 @@
1# This library is free software; you can redistribute it and/or
2# modify it under the terms of the GNU Lesser General Public
3# License as published by the Free Software Foundation; either
4# version 2.1 of the License, or (at your option) any later version.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the
13# Free Software Foundation, Inc.,
14# 59 Temple Place, Suite 330,
15# Boston, MA 02111-1307 USA
16
17# This file is part of urlgrabber, a high-level cross-protocol url-grabber
18# Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
19
20# $Id: progress.py,v 1.7 2005/08/19 21:59:07 mstenner Exp $
21
22import sys
23import time
24import math
25import thread
26
27class BaseMeter:
28 def __init__(self):
29 self.update_period = 0.3 # seconds
30
31 self.filename = None
32 self.url = None
33 self.basename = None
34 self.text = None
35 self.size = None
36 self.start_time = None
37 self.last_amount_read = 0
38 self.last_update_time = None
39 self.re = RateEstimator()
40
41 def start(self, filename=None, url=None, basename=None,
42 size=None, now=None, text=None):
43 self.filename = filename
44 self.url = url
45 self.basename = basename
46 self.text = text
47
48 #size = None ######### TESTING
49 self.size = size
50 if not size is None: self.fsize = format_number(size) + 'B'
51
52 if now is None: now = time.time()
53 self.start_time = now
54 self.re.start(size, now)
55 self.last_amount_read = 0
56 self.last_update_time = now
57 self._do_start(now)
58
59 def _do_start(self, now=None):
60 pass
61
62 def update(self, amount_read, now=None):
63 # for a real gui, you probably want to override and put a call
64 # to your mainloop iteration function here
65 if now is None: now = time.time()
66 if (now >= self.last_update_time + self.update_period) or \
67 not self.last_update_time:
68 self.re.update(amount_read, now)
69 self.last_amount_read = amount_read
70 self.last_update_time = now
71 self._do_update(amount_read, now)
72
73 def _do_update(self, amount_read, now=None):
74 pass
75
76 def end(self, amount_read, now=None):
77 if now is None: now = time.time()
78 self.re.update(amount_read, now)
79 self.last_amount_read = amount_read
80 self.last_update_time = now
81 self._do_end(amount_read, now)
82
83 def _do_end(self, amount_read, now=None):
84 pass
85
86class TextMeter(BaseMeter):
87 def __init__(self, fo=sys.stderr):
88 BaseMeter.__init__(self)
89 self.fo = fo
90
91 def _do_update(self, amount_read, now=None):
92 etime = self.re.elapsed_time()
93 fetime = format_time(etime)
94 fread = format_number(amount_read)
95 #self.size = None
96 if self.text is not None:
97 text = self.text
98 else:
99 text = self.basename
100 if self.size is None:
101 out = '\r%-60.60s %5sB %s ' % \
102 (text, fread, fetime)
103 else:
104 rtime = self.re.remaining_time()
105 frtime = format_time(rtime)
106 frac = self.re.fraction_read()
107 bar = '='*int(25 * frac)
108
109 out = '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ETA ' % \
110 (text, frac*100, bar, fread, frtime)
111
112 self.fo.write(out)
113 self.fo.flush()
114
115 def _do_end(self, amount_read, now=None):
116 total_time = format_time(self.re.elapsed_time())
117 total_size = format_number(amount_read)
118 if self.text is not None:
119 text = self.text
120 else:
121 text = self.basename
122 if self.size is None:
123 out = '\r%-60.60s %5sB %s ' % \
124 (text, total_size, total_time)
125 else:
126 bar = '='*25
127 out = '\r%-25.25s %3i%% |%-25.25s| %5sB %8s ' % \
128 (text, 100, bar, total_size, total_time)
129 self.fo.write(out + '\n')
130 self.fo.flush()
131
132text_progress_meter = TextMeter
133
134class MultiFileHelper(BaseMeter):
135 def __init__(self, master):
136 BaseMeter.__init__(self)
137 self.master = master
138
139 def _do_start(self, now):
140 self.master.start_meter(self, now)
141
142 def _do_update(self, amount_read, now):
143 # elapsed time since last update
144 self.master.update_meter(self, now)
145
146 def _do_end(self, amount_read, now):
147 self.ftotal_time = format_time(now - self.start_time)
148 self.ftotal_size = format_number(self.last_amount_read)
149 self.master.end_meter(self, now)
150
151 def failure(self, message, now=None):
152 self.master.failure_meter(self, message, now)
153
154 def message(self, message):
155 self.master.message_meter(self, message)
156
157class MultiFileMeter:
158 helperclass = MultiFileHelper
159 def __init__(self):
160 self.meters = []
161 self.in_progress_meters = []
162 self._lock = thread.allocate_lock()
163 self.update_period = 0.3 # seconds
164
165 self.numfiles = None
166 self.finished_files = 0
167 self.failed_files = 0
168 self.open_files = 0
169 self.total_size = None
170 self.failed_size = 0
171 self.start_time = None
172 self.finished_file_size = 0
173 self.last_update_time = None
174 self.re = RateEstimator()
175
176 def start(self, numfiles=None, total_size=None, now=None):
177 if now is None: now = time.time()
178 self.numfiles = numfiles
179 self.finished_files = 0
180 self.failed_files = 0
181 self.open_files = 0
182 self.total_size = total_size
183 self.failed_size = 0
184 self.start_time = now
185 self.finished_file_size = 0
186 self.last_update_time = now
187 self.re.start(total_size, now)
188 self._do_start(now)
189
190 def _do_start(self, now):
191 pass
192
193 def end(self, now=None):
194 if now is None: now = time.time()
195 self._do_end(now)
196
197 def _do_end(self, now):
198 pass
199
200 def lock(self): self._lock.acquire()
201 def unlock(self): self._lock.release()
202
203 ###########################################################
204 # child meter creation and destruction
205 def newMeter(self):
206 newmeter = self.helperclass(self)
207 self.meters.append(newmeter)
208 return newmeter
209
210 def removeMeter(self, meter):
211 self.meters.remove(meter)
212
213 ###########################################################
214 # child functions - these should only be called by helpers
215 def start_meter(self, meter, now):
216 if not meter in self.meters:
217 raise ValueError('attempt to use orphaned meter')
218 self._lock.acquire()
219 try:
220 if not meter in self.in_progress_meters:
221 self.in_progress_meters.append(meter)
222 self.open_files += 1
223 finally:
224 self._lock.release()
225 self._do_start_meter(meter, now)
226
227 def _do_start_meter(self, meter, now):
228 pass
229
230 def update_meter(self, meter, now):
231 if not meter in self.meters:
232 raise ValueError('attempt to use orphaned meter')
233 if (now >= self.last_update_time + self.update_period) or \
234 not self.last_update_time:
235 self.re.update(self._amount_read(), now)
236 self.last_update_time = now
237 self._do_update_meter(meter, now)
238
239 def _do_update_meter(self, meter, now):
240 pass
241
242 def end_meter(self, meter, now):
243 if not meter in self.meters:
244 raise ValueError('attempt to use orphaned meter')
245 self._lock.acquire()
246 try:
247 try: self.in_progress_meters.remove(meter)
248 except ValueError: pass
249 self.open_files -= 1
250 self.finished_files += 1
251 self.finished_file_size += meter.last_amount_read
252 finally:
253 self._lock.release()
254 self._do_end_meter(meter, now)
255
256 def _do_end_meter(self, meter, now):
257 pass
258
259 def failure_meter(self, meter, message, now):
260 if not meter in self.meters:
261 raise ValueError('attempt to use orphaned meter')
262 self._lock.acquire()
263 try:
264 try: self.in_progress_meters.remove(meter)
265 except ValueError: pass
266 self.open_files -= 1
267 self.failed_files += 1
268 if meter.size and self.failed_size is not None:
269 self.failed_size += meter.size
270 else:
271 self.failed_size = None
272 finally:
273 self._lock.release()
274 self._do_failure_meter(meter, message, now)
275
276 def _do_failure_meter(self, meter, message, now):
277 pass
278
279 def message_meter(self, meter, message):
280 pass
281
282 ########################################################
283 # internal functions
284 def _amount_read(self):
285 tot = self.finished_file_size
286 for m in self.in_progress_meters:
287 tot += m.last_amount_read
288 return tot
289
290
291class TextMultiFileMeter(MultiFileMeter):
292 def __init__(self, fo=sys.stderr):
293 self.fo = fo
294 MultiFileMeter.__init__(self)
295
296 # files: ###/### ###% data: ######/###### ###% time: ##:##:##/##:##:##
297 def _do_update_meter(self, meter, now):
298 self._lock.acquire()
299 try:
300 format = "files: %3i/%-3i %3i%% data: %6.6s/%-6.6s %3i%% " \
301 "time: %8.8s/%8.8s"
302 df = self.finished_files
303 tf = self.numfiles or 1
304 pf = 100 * float(df)/tf + 0.49
305 dd = self.re.last_amount_read
306 td = self.total_size
307 pd = 100 * (self.re.fraction_read() or 0) + 0.49
308 dt = self.re.elapsed_time()
309 rt = self.re.remaining_time()
310 if rt is None: tt = None
311 else: tt = dt + rt
312
313 fdd = format_number(dd) + 'B'
314 ftd = format_number(td) + 'B'
315 fdt = format_time(dt, 1)
316 ftt = format_time(tt, 1)
317
318 out = '%-79.79s' % (format % (df, tf, pf, fdd, ftd, pd, fdt, ftt))
319 self.fo.write('\r' + out)
320 self.fo.flush()
321 finally:
322 self._lock.release()
323
324 def _do_end_meter(self, meter, now):
325 self._lock.acquire()
326 try:
327 format = "%-30.30s %6.6s %8.8s %9.9s"
328 fn = meter.basename
329 size = meter.last_amount_read
330 fsize = format_number(size) + 'B'
331 et = meter.re.elapsed_time()
332 fet = format_time(et, 1)
333 frate = format_number(size / et) + 'B/s'
334
335 out = '%-79.79s' % (format % (fn, fsize, fet, frate))
336 self.fo.write('\r' + out + '\n')
337 finally:
338 self._lock.release()
339 self._do_update_meter(meter, now)
340
341 def _do_failure_meter(self, meter, message, now):
342 self._lock.acquire()
343 try:
344 format = "%-30.30s %6.6s %s"
345 fn = meter.basename
346 if type(message) in (type(''), type(u'')):
347 message = message.splitlines()
348 if not message: message = ['']
349 out = '%-79s' % (format % (fn, 'FAILED', message[0] or ''))
350 self.fo.write('\r' + out + '\n')
351 for m in message[1:]: self.fo.write(' ' + m + '\n')
352 self._lock.release()
353 finally:
354 self._do_update_meter(meter, now)
355
356 def message_meter(self, meter, message):
357 self._lock.acquire()
358 try:
359 pass
360 finally:
361 self._lock.release()
362
363 def _do_end(self, now):
364 self._do_update_meter(None, now)
365 self._lock.acquire()
366 try:
367 self.fo.write('\n')
368 self.fo.flush()
369 finally:
370 self._lock.release()
371
372######################################################################
373# support classes and functions
374
375class RateEstimator:
376 def __init__(self, timescale=5.0):
377 self.timescale = timescale
378
379 def start(self, total=None, now=None):
380 if now is None: now = time.time()
381 self.total = total
382 self.start_time = now
383 self.last_update_time = now
384 self.last_amount_read = 0
385 self.ave_rate = None
386
387 def update(self, amount_read, now=None):
388 if now is None: now = time.time()
389 if amount_read == 0:
390 # if we just started this file, all bets are off
391 self.last_update_time = now
392 self.last_amount_read = 0
393 self.ave_rate = None
394 return
395
396 #print 'times', now, self.last_update_time
397 time_diff = now - self.last_update_time
398 read_diff = amount_read - self.last_amount_read
399 self.last_update_time = now
400 self.last_amount_read = amount_read
401 self.ave_rate = self._temporal_rolling_ave(\
402 time_diff, read_diff, self.ave_rate, self.timescale)
403 #print 'results', time_diff, read_diff, self.ave_rate
404
405 #####################################################################
406 # result methods
407 def average_rate(self):
408 "get the average transfer rate (in bytes/second)"
409 return self.ave_rate
410
411 def elapsed_time(self):
412 "the time between the start of the transfer and the most recent update"
413 return self.last_update_time - self.start_time
414
415 def remaining_time(self):
416 "estimated time remaining"
417 if not self.ave_rate or not self.total: return None
418 return (self.total - self.last_amount_read) / self.ave_rate
419
420 def fraction_read(self):
421 """the fraction of the data that has been read
422 (can be None for unknown transfer size)"""
423 if self.total is None: return None
424 elif self.total == 0: return 1.0
425 else: return float(self.last_amount_read)/self.total
426
427 #########################################################################
428 # support methods
429 def _temporal_rolling_ave(self, time_diff, read_diff, last_ave, timescale):
430 """a temporal rolling average performs smooth averaging even when
431 updates come at irregular intervals. This is performed by scaling
432 the "epsilon" according to the time since the last update.
433 Specifically, epsilon = time_diff / timescale
434
435 As a general rule, the average will take on a completely new value
436 after 'timescale' seconds."""
437 epsilon = time_diff / timescale
438 if epsilon > 1: epsilon = 1.0
439 return self._rolling_ave(time_diff, read_diff, last_ave, epsilon)
440
441 def _rolling_ave(self, time_diff, read_diff, last_ave, epsilon):
442 """perform a "rolling average" iteration
443 a rolling average "folds" new data into an existing average with
444 some weight, epsilon. epsilon must be between 0.0 and 1.0 (inclusive)
445 a value of 0.0 means only the old value (initial value) counts,
446 and a value of 1.0 means only the newest value is considered."""
447
448 try:
449 recent_rate = read_diff / time_diff
450 except ZeroDivisionError:
451 recent_rate = None
452 if last_ave is None: return recent_rate
453 elif recent_rate is None: return last_ave
454
455 # at this point, both last_ave and recent_rate are numbers
456 return epsilon * recent_rate + (1 - epsilon) * last_ave
457
458 def _round_remaining_time(self, rt, start_time=15.0):
459 """round the remaining time, depending on its size
460 If rt is between n*start_time and (n+1)*start_time round downward
461 to the nearest multiple of n (for any counting number n).
462 If rt < start_time, round down to the nearest 1.
463 For example (for start_time = 15.0):
464 2.7 -> 2.0
465 25.2 -> 25.0
466 26.4 -> 26.0
467 35.3 -> 34.0
468 63.6 -> 60.0
469 """
470
471 if rt < 0: return 0.0
472 shift = int(math.log(rt/start_time)/math.log(2))
473 rt = int(rt)
474 if shift <= 0: return rt
475 return float(int(rt) >> shift << shift)
476
477
478def format_time(seconds, use_hours=0):
479 if seconds is None or seconds < 0:
480 if use_hours: return '--:--:--'
481 else: return '--:--'
482 else:
483 seconds = int(seconds)
484 minutes = seconds / 60
485 seconds = seconds % 60
486 if use_hours:
487 hours = minutes / 60
488 minutes = minutes % 60
489 return '%02i:%02i:%02i' % (hours, minutes, seconds)
490 else:
491 return '%02i:%02i' % (minutes, seconds)
492
493def format_number(number, SI=0, space=' '):
494 """Turn numbers into human-readable metric-like numbers"""
495 symbols = ['', # (none)
496 'k', # kilo
497 'M', # mega
498 'G', # giga
499 'T', # tera
500 'P', # peta
501 'E', # exa
502 'Z', # zetta
503 'Y'] # yotta
504
505 if SI: step = 1000.0
506 else: step = 1024.0
507
508 thresh = 999
509 depth = 0
510 max_depth = len(symbols) - 1
511
512 # we want numbers between 0 and thresh, but don't exceed the length
513 # of our list. In that event, the formatting will be screwed up,
514 # but it'll still show the right number.
515 while number > thresh and depth < max_depth:
516 depth = depth + 1
517 number = number / step
518
519 if type(number) == type(1) or type(number) == type(1L):
520 # it's an int or a long, which means it didn't get divided,
521 # which means it's already short enough
522 format = '%i%s%s'
523 elif number < 9.95:
524 # must use 9.95 for proper sizing. For example, 9.99 will be
525 # rounded to 10.0 with the .1f format string (which is too long)
526 format = '%.1f%s%s'
527 else:
528 format = '%.0f%s%s'
529
530 return(format % (float(number or 0), space, symbols[depth]))
diff --git a/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/sslfactory.py b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/sslfactory.py
new file mode 100644
index 0000000000..07848dac7c
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/urlgrabber/sslfactory.py
@@ -0,0 +1,90 @@
1# This library is free software; you can redistribute it and/or
2# modify it under the terms of the GNU Lesser General Public
3# License as published by the Free Software Foundation; either
4# version 2.1 of the License, or (at your option) any later version.
5#
6# This library is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9# Lesser General Public License for more details.
10#
11# You should have received a copy of the GNU Lesser General Public
12# License along with this library; if not, write to the
13# Free Software Foundation, Inc.,
14# 59 Temple Place, Suite 330,
15# Boston, MA 02111-1307 USA
16
17# This file is part of urlgrabber, a high-level cross-protocol url-grabber
18
19import httplib
20import urllib2
21
22try:
23 from M2Crypto import SSL
24 from M2Crypto import httpslib
25 from M2Crypto import m2urllib2
26
27 SSL.Connection.clientPostConnectionCheck = None
28 have_m2crypto = True
29except ImportError:
30 have_m2crypto = False
31
32DEBUG = None
33
34if have_m2crypto:
35
36 class M2SSLFactory:
37
38 def __init__(self, ssl_ca_cert, ssl_context):
39 self.ssl_context = self._get_ssl_context(ssl_ca_cert, ssl_context)
40
41 def _get_ssl_context(self, ssl_ca_cert, ssl_context):
42 """
43 Create an ssl context using the CA cert file or ssl context.
44
45 The CA cert is used first if it was passed as an option. If not,
46 then the supplied ssl context is used. If no ssl context was supplied,
47 None is returned.
48 """
49 if ssl_ca_cert:
50 context = SSL.Context()
51 context.load_verify_locations(ssl_ca_cert)
52 context.set_verify(SSL.verify_none, -1)
53 return context
54 else:
55 return ssl_context
56
57 def create_https_connection(self, host, response_class = None):
58 connection = httplib.HTTPSConnection(host, self.ssl_context)
59 if response_class:
60 connection.response_class = response_class
61 return connection
62
63 def create_opener(self, *handlers):
64 return m2urllib2.build_opener(self.ssl_context, *handlers)
65
66
67class SSLFactory:
68
69 def create_https_connection(self, host, response_class = None):
70 connection = httplib.HTTPSConnection(host)
71 if response_class:
72 connection.response_class = response_class
73 return connection
74
75 def create_opener(self, *handlers):
76 return urllib2.build_opener(*handlers)
77
78
79
80def get_factory(ssl_ca_cert = None, ssl_context = None):
81 """ Return an SSLFactory, based on if M2Crypto is available. """
82 if have_m2crypto:
83 return M2SSLFactory(ssl_ca_cert, ssl_context)
84 else:
85 # Log here if someone provides the args but we don't use them.
86 if ssl_ca_cert or ssl_context:
87 if DEBUG:
88 DEBUG.warning("SSL arguments supplied, but M2Crypto is not available. "
89 "Using Python SSL.")
90 return SSLFactory()
diff --git a/scripts/lib/mic/3rdparty/pykickstart/version.py b/scripts/lib/mic/3rdparty/pykickstart/version.py
new file mode 100644
index 0000000000..102cc37d80
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/version.py
@@ -0,0 +1,197 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2006, 2007, 2008, 2009, 2010 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20"""
21Methods for working with kickstart versions.
22
23This module defines several symbolic constants that specify kickstart syntax
24versions. Each version corresponds roughly to one release of Red Hat Linux,
25Red Hat Enterprise Linux, or Fedora Core as these are where most syntax
26changes take place.
27
28This module also exports several functions:
29
30 makeVersion - Given a version number, return an instance of the
31 matching handler class.
32
33 returnClassForVersion - Given a version number, return the matching
34 handler class. This does not return an
35 instance of that class, however.
36
37 stringToVersion - Convert a string representation of a version number
38 into the symbolic constant.
39
40 versionToString - Perform the reverse mapping.
41
42 versionFromFile - Read a kickstart file and determine the version of
43 syntax it uses. This requires the kickstart file to
44 have a version= comment in it.
45"""
46import imputil, re, sys
47from urlgrabber import urlopen
48
49import gettext
50_ = lambda x: gettext.ldgettext("pykickstart", x)
51
52from pykickstart.errors import KickstartVersionError
53
54# Symbolic names for internal version numbers.
55RHEL3 = 900
56FC3 = 1000
57RHEL4 = 1100
58FC4 = 2000
59FC5 = 3000
60FC6 = 4000
61RHEL5 = 4100
62F7 = 5000
63F8 = 6000
64F9 = 7000
65F10 = 8000
66F11 = 9000
67F12 = 10000
68F13 = 11000
69RHEL6 = 11100
70F14 = 12000
71F15 = 13000
72F16 = 14000
73
74# This always points at the latest version and is the default.
75DEVEL = F16
76
77# A one-to-one mapping from string representations to version numbers.
78versionMap = {
79 "DEVEL": DEVEL,
80 "FC3": FC3, "FC4": FC4, "FC5": FC5, "FC6": FC6, "F7": F7, "F8": F8,
81 "F9": F9, "F10": F10, "F11": F11, "F12": F12, "F13": F13,
82 "F14": F14, "F15": F15, "F16": F16,
83 "RHEL3": RHEL3, "RHEL4": RHEL4, "RHEL5": RHEL5, "RHEL6": RHEL6
84}
85
86def stringToVersion(s):
87 """Convert string into one of the provided version constants. Raises
88 KickstartVersionError if string does not match anything.
89 """
90 # First try these short forms.
91 try:
92 return versionMap[s.upper()]
93 except KeyError:
94 pass
95
96 # Now try the Fedora versions.
97 m = re.match("^fedora.* (\d+)$", s, re.I)
98
99 if m and m.group(1):
100 if versionMap.has_key("FC" + m.group(1)):
101 return versionMap["FC" + m.group(1)]
102 elif versionMap.has_key("F" + m.group(1)):
103 return versionMap["F" + m.group(1)]
104 else:
105 raise KickstartVersionError(_("Unsupported version specified: %s") % s)
106
107 # Now try the RHEL versions.
108 m = re.match("^red hat enterprise linux.* (\d+)([\.\d]*)$", s, re.I)
109
110 if m and m.group(1):
111 if versionMap.has_key("RHEL" + m.group(1)):
112 return versionMap["RHEL" + m.group(1)]
113 else:
114 raise KickstartVersionError(_("Unsupported version specified: %s") % s)
115
116 # If nothing else worked, we're out of options.
117 raise KickstartVersionError(_("Unsupported version specified: %s") % s)
118
119def versionToString(version, skipDevel=False):
120 """Convert version into a string representation of the version number.
121 This is the reverse operation of stringToVersion. Raises
122 KickstartVersionError if version does not match anything.
123 """
124 if not skipDevel and version == versionMap["DEVEL"]:
125 return "DEVEL"
126
127 for (key, val) in versionMap.iteritems():
128 if key == "DEVEL":
129 continue
130 elif val == version:
131 return key
132
133 raise KickstartVersionError(_("Unsupported version specified: %s") % version)
134
135def versionFromFile(f):
136 """Given a file or URL, look for a line starting with #version= and
137 return the version number. If no version is found, return DEVEL.
138 """
139 v = DEVEL
140
141 fh = urlopen(f)
142
143 while True:
144 try:
145 l = fh.readline()
146 except StopIteration:
147 break
148
149 # At the end of the file?
150 if l == "":
151 break
152
153 if l.isspace() or l.strip() == "":
154 continue
155
156 if l[:9] == "#version=":
157 v = stringToVersion(l[9:].rstrip())
158 break
159
160 fh.close()
161 return v
162
163def returnClassForVersion(version=DEVEL):
164 """Return the class of the syntax handler for version. version can be
165 either a string or the matching constant. Raises KickstartValueError
166 if version does not match anything.
167 """
168 try:
169 version = int(version)
170 module = "%s" % versionToString(version, skipDevel=True)
171 except ValueError:
172 module = "%s" % version
173 version = stringToVersion(version)
174
175 module = module.lower()
176
177 try:
178 import pykickstart.handlers
179 sys.path.extend(pykickstart.handlers.__path__)
180 found = imputil.imp.find_module(module)
181 loaded = imputil.imp.load_module(module, found[0], found[1], found[2])
182
183 for (k, v) in loaded.__dict__.iteritems():
184 if k.lower().endswith("%shandler" % module):
185 return v
186 except:
187 raise KickstartVersionError(_("Unsupported version specified: %s") % version)
188
189def makeVersion(version=DEVEL):
190 """Return a new instance of the syntax handler for version. version can be
191 either a string or the matching constant. This function is useful for
192 standalone programs which just need to handle a specific version of
193 kickstart syntax (as provided by a command line argument, for example)
194 and need to instantiate the correct object.
195 """
196 cl = returnClassForVersion(version)
197 return cl()