diff options
189 files changed, 16723 insertions, 4471 deletions
@@ -1,3 +1,11 @@ +Release 0.28.19 - Thu Apr. 13 2023 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Fix mic create image error with rpm 4.14 if %prepackages section exists in ks file. + +Release 0.28.18 - Thu Jan. 12 2023 - Biao Wang <biao716.wang@samsung.com> +===================================================================== + * Add support for RISC-V arch. + Release 0.28.17 - Wed Aug. 10 2022 - Biao Wang <biao716.wang@samsung.com> ===================================================================== * Add --block-recommends option to allow not install recommended packages diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..ba74fbb --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include etc/mic.conf.in diff --git a/debian/changelog b/debian/changelog index e803282..8aab8b3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +mic (0.28.19) unstable; urgency=low + * Fix mic create image error with rpm 4.14 if %prepackages section exists in + ks file. + + -- Biao Wang <biao716.wang@samsung.com> Thu, 13 Apr 2023 15:00:00 +0800 + +mic (0.28.18) unstable; urgency=low + * Add support for RISC-V arch. + + -- Biao Wang <biao716.wang@samsung.com> Thu, 12 Jan 2023 15:00:00 +0800 + mic (0.28.17) unstable; urgency=low * Add --block-recommends option to allow not install recommended packages diff --git a/debian/control b/debian/control index 9647472..52ed82a 100644 --- a/debian/control +++ b/debian/control @@ -2,16 +2,18 @@ Source: mic Section: devel Priority: extra Maintainer: Jian-feng Ding <jian-feng.ding@intel.com> -Build-Depends: debhelper (>= 7.0.15), cdbs, python-dev, dh-python, python-docutils +Build-Depends: debhelper (>= 7.0.15), cdbs, python3, python3-requests, python3-all, python3-dev, dh-python, python3-docutils Standards-Version: 3.8.0 Homepage: http://www.tizen.org Package: mic Architecture: all -Depends: ${misc:Depends}, ${python:Depends}, +Depends: ${misc:Depends}, ${python3:Depends}, rpm, - python-rpm, - python-urlgrabber, + python3-rpm, + python3-urlgrabber, + python3-requests, + python3-distro, cpio, bzip2, gzip, diff --git a/debian/rules b/debian/rules index b877fe9..dd312e2 100755 --- a/debian/rules +++ b/debian/rules @@ -1,28 +1,10 @@ #!/usr/bin/make -f - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -build: build-stamp -build-stamp: - dh_testdir - - python setup.py build +%: + dh $@ --with python3 --buildsystem=pybuild +build: make man - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - +override_dh_auto_install: + dh_auto_install # Installing package mkdir -p $(CURDIR)/debian/tmp/ mkdir -p $(CURDIR)/debian/tmp/usr/bin @@ -32,27 +14,9 @@ install: build install -m644 doc/mic.1 $(CURDIR)/debian/tmp/usr/share/man/man1 install -m755 etc/bash_completion.d/mic.sh $(CURDIR)/debian/tmp/etc/bash_completion.d/ install -m755 etc/zsh_completion.d/_mic $(CURDIR)/debian/tmp/etc/zsh_completion.d/_mic - python setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr - -binary-indep: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_install - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms - dh_python2 - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb + python3 setup.py install --root=$(CURDIR)/debian/tmp --prefix=/usr -binary-arch: build install +override_dh_installchangelogs: + dh_installchangelogs ChangeLog +override_dh_auto_test: -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install diff --git a/doc/RELEASE_NOTES b/doc/RELEASE_NOTES index c207ac3..ec8744d 100644 --- a/doc/RELEASE_NOTES +++ b/doc/RELEASE_NOTES @@ -1,3 +1,25 @@ +MIC Image Creator 0.28.19 Release Notes +====================================== +Released Apr 13 2023 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Fix mic create image error with rpm 4.14 if %prepackages section exists in ks file. + +MIC Image Creator 0.28.18 Release Notes +====================================== +Released Jan 12 2023 + +This release note documents the changes included in the new release. And +the release contains new features. + +new features +-------------------------- + * Add support for RIS-V arch. + MIC Image Creator 0.28.17 Release Notes ====================================== Released Aug 10 2022 diff --git a/etc/bash_completion.d/mic.sh b/etc/bash_completion.d/mic.sh index 4f467ca..38d5555 100644 --- a/etc/bash_completion.d/mic.sh +++ b/etc/bash_completion.d/mic.sh @@ -110,6 +110,7 @@ __mic_complete_val() armv5tel armv5tejl armv7tnhl + riscv64 " pkgmgr_values=" yum diff --git a/mic/3rdparty/pykickstart/__init__.py b/mic/3rdparty/pykickstart/__init__.py index e69de29..c4f8ae1 100644 --- a/mic/3rdparty/pykickstart/__init__.py +++ b/mic/3rdparty/pykickstart/__init__.py @@ -0,0 +1 @@ +__version__ = '3.41' diff --git a/mic/3rdparty/pykickstart/base.py b/mic/3rdparty/pykickstart/base.py index 75ce249..b1b7c19 100644 --- a/mic/3rdparty/pykickstart/base.py +++ b/mic/3rdparty/pykickstart/base.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2006, 2007, 2008 Red Hat, Inc. +# Copyright 2006, 2007, 2008, 2012 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,7 +15,7 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # """ Base classes for creating commands and syntax version object. @@ -34,20 +34,23 @@ This module exports several important base classes: a subclass is used, a warning message will be printed. + RemovedCommand - an abstract subclass of KickstartCommand that should + be subclassed to update the description with the version + it was removed in. + Any use of the command will raise an error. + KickstartCommand - The base abstract class for all kickstart commands. Command objects are contained within a BaseHandler object. """ -import gettext -gettext.textdomain("pykickstart") -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ -import types import warnings -from pykickstart.errors import * -from pykickstart.ko import * -from pykickstart.parser import Packages,TpkPackages +from pykickstart import __version__ +from pykickstart.errors import KickstartParseError, KickstartParseWarning, KickstartDeprecationWarning +from pykickstart.ko import KickstartObject from pykickstart.version import versionToString +from pykickstart.parser import Packages ### ### COMMANDS @@ -70,6 +73,10 @@ class KickstartCommand(KickstartObject): command is contained withing. This is needed to allow referencing of Data objects. lineno -- The current line number in the input file. + seen -- If this command was ever used in the kickstart file, + this attribute will be set to True. This allows + for differentiating commands that were omitted + from those that default to unset. writePriority -- An integer specifying when this command should be printed when iterating over all commands' __str__ methods. The higher the number, the later this @@ -79,7 +86,7 @@ class KickstartCommand(KickstartObject): # We don't want people using this class by itself. if self.__class__ is KickstartCommand: - raise TypeError ("KickstartCommand is an abstract class.") + raise TypeError("KickstartCommand is an abstract class.") KickstartObject.__init__(self, *args, **kwargs) @@ -90,20 +97,21 @@ class KickstartCommand(KickstartObject): self.currentLine = "" self.handler = None self.lineno = 0 + self.seen = False - # If a subclass provides a removedKeywords list, remove all the - # members from the kwargs list before we start processing it. This - # ensures that subclasses don't continue to recognize arguments that - # were removed. - for arg in filter(kwargs.has_key, self.removedKeywords): - kwargs.pop(arg) + # If a subclass provides a removedKeywords list, warn if the user + # continues to use some of the removed keywords + for arg in (kw for kw in self.removedKeywords if kw in kwargs): + warnings.warn("The '%s' keyword has been removed." % arg, KickstartParseWarning, stacklevel=2) def __call__(self, *args, **kwargs): """Set multiple attributes on a subclass of KickstartCommand at once via keyword arguments. Valid attributes are anything specified in a subclass, but unknown attributes will be ignored. """ - for (key, val) in kwargs.items(): + self.seen = True + + for (key, val) in list(kwargs.items()): # Ignore setting attributes that were removed in a subclass, as # if they were unknown attributes. if key in self.removedAttrs: @@ -118,18 +126,13 @@ class KickstartCommand(KickstartObject): """ return KickstartObject.__str__(self) + # pylint: disable=unused-argument def parse(self, args): """Parse the list of args and set data on the KickstartCommand object. This method must be provided by all subclasses. """ - raise TypeError ("parse() not implemented for KickstartCommand") - - def apply(self, instroot="/"): - """Write out the configuration related to the KickstartCommand object. - Subclasses which do not provide this method will not have their - configuration written out. - """ - return + raise TypeError("parse() not implemented for KickstartCommand") + # pylint: enable=unused-argument def dataList(self): """For commands that can occur multiple times in a single kickstart @@ -138,29 +141,51 @@ class KickstartCommand(KickstartObject): """ return None + @property + def dataClass(self): + """For commands that can occur multiple times in a single kickstart + file, return the class that should be used to store the data from + each invocation. An instance of this class will be appended to + dataList. For all other commands, return None. + """ + return None + def deleteRemovedAttrs(self): """Remove all attributes from self that are given in the removedAttrs list. This method should be called from __init__ in a subclass, but only after the superclass's __init__ method has been called. """ - for attr in filter(lambda k: hasattr(self, k), self.removedAttrs): + for attr in [k for k in self.removedAttrs if hasattr(self, k)]: delattr(self, attr) - # Set the contents of the opts object (an instance of optparse.Values - # returned by parse_args) as attributes on the KickstartCommand object. - # It's useful to call this from KickstartCommand subclasses after parsing - # the arguments. - def _setToSelf(self, optParser, opts): - self._setToObj(optParser, opts, self) - - # Sets the contents of the opts object (an instance of optparse.Values - # returned by parse_args) as attributes on the provided object obj. It's - # useful to call this from KickstartCommand subclasses that handle lists - # of objects (like partitions, network devices, etc.) and need to populate - # a Data object. - def _setToObj(self, optParser, opts, obj): - for key in filter (lambda k: getattr(opts, k) != None, optParser.keys()): - setattr(obj, key, getattr(opts, key)) + def set_to_self(self, namespace): + """Set the contents of the namespace object (an instance of argparse.Namespace + returned by parse_arguments) as attributes on the KickstartCommand object. + It's useful to call this from KickstartCommand subclasses after parsing + the arguments. + """ + self.set_to_obj(namespace, self) + + # Just calls set_to_self - exists for backwards compatibility. + def _setToSelf(self, namespace): + warnings.warn("_setToSelf has been renamed to set_to_self. The old name will be removed in a future release.", PendingDeprecationWarning, stacklevel=2) + self.set_to_self(namespace) + + def set_to_obj(self, namespace, obj): + """Sets the contents of the namespace object (an instance of argparse.Namespace + returned by parse_arguments) as attributes on the provided object obj. It's + useful to call this from KickstartCommand subclasses that handle lists + of objects (like partitions, network devices, etc.) and need to populate + a Data object. + """ + for (key, val) in vars(namespace).items(): + if val is not None: + setattr(obj, key, val) + + # Just calls set_to_obj - exists for backwards compatibility. + def _setToObj(self, namespace, obj): + warnings.warn("_setToObj has been renamed to set_to_obj. The old name will be removed in a future release.", PendingDeprecationWarning, stacklevel=2) + self.set_to_obj(namespace, obj) class DeprecatedCommand(KickstartCommand): """Specify that a command is deprecated and no longer has any function. @@ -170,12 +195,21 @@ class DeprecatedCommand(KickstartCommand): """ def __init__(self, writePriority=None, *args, **kwargs): # We don't want people using this class by itself. - if self.__class__ is KickstartCommand: - raise TypeError ("DeprecatedCommand is an abstract class.") + if self.__class__ is DeprecatedCommand: + raise TypeError("DeprecatedCommand is an abstract class.") # Create a new DeprecatedCommand instance. KickstartCommand.__init__(self, writePriority, *args, **kwargs) + def dataList(self): + """Override the method of the deprecated command.""" + return None + + @property + def dataClass(self): + """Override the attribute of the deprecated command.""" + return None + def __str__(self): """Placeholder since DeprecatedCommands don't work anymore.""" return "" @@ -183,46 +217,56 @@ class DeprecatedCommand(KickstartCommand): def parse(self, args): """Print a warning message if the command is seen in the input file.""" mapping = {"lineno": self.lineno, "cmd": self.currentCmd} - 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) + 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, KickstartDeprecationWarning) + return None +class RemovedCommand(KickstartCommand): + """Specify that a command has been removed and no longer has any function. + Any command that is removed should be subclassed from this class, and + should set its description to add the version that the command was removed in. + This is an abstract class. + """ + def __init__(self, writePriority=None, *args, **kwargs): + # We don't want people using this class by itself. + if self.__class__ is RemovedCommand: + raise TypeError("RemovedCommand is an abstract class.") + + # Create a new RemovedCommand instance. + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + + def dataList(self): + """Override the method of the removed command.""" + return None + + @property + def dataClass(self): + """Override the attribute of the removed command.""" + return None + + def __str__(self): + """Placeholder since RemovedCommands don't work anymore.""" + return "" + + def parse(self, args): + """Raise an error if the command is found in the input file""" + raise KickstartParseError(_("%s has been removed.") % self.currentCmd, lineno=self.lineno) ### ### HANDLERS ### -class BaseHandler(KickstartObject): - """Each version of kickstart syntax is provided by a subclass of this - class. These subclasses are what users will interact with for parsing, - extracting data, and writing out kickstart files. This is an abstract - class. +class KickstartHandler(KickstartObject): + """An empty kickstart handler. + + This handler doesn't handle anything by default. version -- The version this syntax handler supports. This is set by - a class attribute of a BaseHandler subclass and is used to + a class attribute of a KickstartHandler subclass and is used to set up the command dict. It is for read-only use. """ version = None - def __init__(self, mapping=None, dataMapping=None, commandUpdates=None, - dataUpdates=None, *args, **kwargs): - """Create a new BaseHandler instance. This method must be provided by - all subclasses, but subclasses must call BaseHandler.__init__ first. - - mapping -- A custom map from command strings to classes, - useful when creating your own handler with - special command objects. It is otherwise unused - and rarely needed. If you give this argument, - the mapping takes the place of the default one - and so must include all commands you want - recognized. - dataMapping -- This is the same as mapping, but for data - objects. All the same comments apply. - commandUpdates -- This is similar to mapping, but does not take - the place of the defaults entirely. Instead, - this mapping is applied after the defaults and - updates it with just the commands you want to - modify. - dataUpdates -- This is the same as commandUpdates, but for - data objects. - + def __init__(self, *args, **kwargs): + """Create a new KickstartHandler instance. Instance attributes: @@ -234,31 +278,12 @@ class BaseHandler(KickstartObject): manipulated internally and called through dispatcher. currentLine -- The current unprocessed line from the input file that caused this handler to be run. - packages -- An instance of pykickstart.parser.Packages which - describes the packages section of the input file. - platform -- A string describing the hardware platform, which is - needed only by system-config-kickstart. - scripts -- A list of pykickstart.parser.Script instances, which is - populated by KickstartParser.addScript and describes the - %pre/%post/%traceback script section of the input file. """ - - # We don't want people using this class by itself. - if self.__class__ is BaseHandler: - raise TypeError ("BaseHandler is an abstract class.") - KickstartObject.__init__(self, *args, **kwargs) - # This isn't really a good place for these, but it's better than - # everything else I can think of. - self.scripts = [] - self.packages = Packages() - self.tpk_packages = TpkPackages() - self.platform = "" - # These will be set by the dispatcher. self.commands = {} - self.currentLine = 0 + self.currentLine = "" # A dict keyed by an integer priority number, with each value being a # list of KickstartCommand subclasses. This dict is maintained by @@ -266,32 +291,26 @@ class BaseHandler(KickstartObject): # it. self._writeOrder = {} - self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates) - def __str__(self): """Return a string formatted for output to a kickstart file.""" retval = "" - if self.platform != "": - retval += "#platform=%s\n" % self.platform - - retval += "#version=%s\n" % versionToString(self.version) - - lst = self._writeOrder.keys() + lst = list(self._writeOrder.keys()) lst.sort() for prio in lst: for obj in self._writeOrder[prio]: retval += obj.__str__() - for script in self.scripts: - retval += script.__str__() - - retval += self.packages.__str__() - return retval def _insertSorted(self, lst, obj): + def cmdName(cmdObj): + if cmdObj.__class__.__name__.find("_") != -1: + return cmdObj.__class__.__name__.split("_", 1)[1] + else: + return cmdObj.__class__.__name__ + length = len(lst) i = 0 @@ -299,12 +318,12 @@ class BaseHandler(KickstartObject): # If the two classes have the same name, it's because we are # overriding an existing class with one from a later kickstart # version, so remove the old one in favor of the new one. - if obj.__class__.__name__ > lst[i].__class__.__name__: + if cmdName(obj) > cmdName(lst[i]): i += 1 - elif obj.__class__.__name__ == lst[i].__class__.__name__: + elif cmdName(obj) == cmdName(lst[i]): lst[i] = obj return - elif obj.__class__.__name__ < lst[i].__class__.__name__: + elif cmdName(obj) < cmdName(lst[i]): break if i >= length: @@ -317,64 +336,62 @@ class BaseHandler(KickstartObject): # way for clients to access the command objects. We also need to strip # off the version part from the front of the name. if cmdObj.__class__.__name__.find("_") != -1: - name = unicode(cmdObj.__class__.__name__.split("_", 1)[1]) + name = cmdObj.__class__.__name__.split("_", 1)[1] else: - name = unicode(cmdObj.__class__.__name__).lower() + name = cmdObj.__class__.__name__.lower() setattr(self, name.lower(), cmdObj) # Also, add the object into the _writeOrder dict in the right place. if cmdObj.writePriority is not None: - if self._writeOrder.has_key(cmdObj.writePriority): + if cmdObj.writePriority in self._writeOrder: self._insertSorted(self._writeOrder[cmdObj.writePriority], cmdObj) else: self._writeOrder[cmdObj.writePriority] = [cmdObj] - def _registerCommands(self, mapping=None, dataMapping=None, commandUpdates=None, - dataUpdates=None): - if mapping == {} or mapping == None: - from pykickstart.handlers.control import commandMap - cMap = commandMap[self.version] - else: - cMap = mapping - - if dataMapping == {} or dataMapping == None: - from pykickstart.handlers.control import dataMap - dMap = dataMap[self.version] - else: - dMap = dataMapping + def registerCommand(self, cmdName, cmdClass): + # First make sure we haven't instantiated this command handler + # already. If we have, we just need to make another mapping to + # it in self.commands. + # NOTE: We can't use the resetCommand method here since that relies + # upon cmdClass already being instantiated. We'll just have to keep + # these two code blocks in sync. + cmdObj = None + + for (_key, val) in list(self.commands.items()): + if val.__class__.__name__ == cmdClass.__name__: + cmdObj = val + break - if type(commandUpdates) == types.DictType: - cMap.update(commandUpdates) + # If we didn't find an instance in self.commands, create one now. + if cmdObj is None: + cmdObj = cmdClass() + self._setCommand(cmdObj) - if type(dataUpdates) == types.DictType: - dMap.update(dataUpdates) + # Finally, add the mapping to the commands dict. + self.commands[cmdName] = cmdObj + self.commands[cmdName].handler = self - for (cmdName, cmdClass) in cMap.iteritems(): - # First make sure we haven't instantiated this command handler - # already. If we have, we just need to make another mapping to - # it in self.commands. - cmdObj = None + def registerData(self, dataName, dataClass): + # We also need to create attributes for the various data objects. + setattr(self, dataName, dataClass) - for (key, val) in self.commands.iteritems(): - if val.__class__.__name__ == cmdClass.__name__: - cmdObj = val - break + def resetCommand(self, cmdName): + """Given the name of a command that's already been instantiated, create + a new instance of it that will take the place of the existing + instance. This is equivalent to quickly blanking out all the + attributes that were previously set. - # If we didn't find an instance in self.commands, create one now. - if cmdObj == None: - cmdObj = cmdClass() - self._setCommand(cmdObj) + This method raises a KeyError if cmdName is invalid. + """ + if cmdName not in self.commands: + raise KeyError - # Finally, add the mapping to the commands dict. - self.commands[cmdName] = cmdObj - self.commands[cmdName].handler = self + cmdObj = self.commands[cmdName].__class__() - # We also need to create attributes for the various data objects. - # No checks here because dMap is a bijection. At least, that's what - # the comment says. Hope no one screws that up. - for (dataName, dataClass) in dMap.iteritems(): - setattr(self, dataName, dataClass) + self._setCommand(cmdObj) + self.commands[cmdName] = cmdObj + self.commands[cmdName].handler = self def dispatcher(self, args, lineno): """Call the appropriate KickstartCommand handler for the current line @@ -387,38 +404,164 @@ class BaseHandler(KickstartObject): """ cmd = args[0] - if not self.commands.has_key(cmd): - raise KickstartParseError (formatErrorMsg(lineno, msg=_("Unknown command: %s" % cmd))) - elif self.commands[cmd] != None: + if cmd not in self.commands: + raise KickstartParseError(_("Unknown command: %s") % cmd, lineno=lineno) + elif self.commands[cmd] is not None: self.commands[cmd].currentCmd = cmd self.commands[cmd].currentLine = self.currentLine self.commands[cmd].lineno = lineno - - # The parser returns the data object that was modified. This could - # be a BaseData subclass that should be put into a list, or it - # could be the command handler object itself. + self.commands[cmd].seen = True + + # The parser returns the data object that was modified. This is either + # the command handler object itself (a KickstartCommand object), or it's + # a BaseData subclass instance that should be put into the command's + # dataList. The latter is done via side effects. + # + # Regardless, return the object that was given to us by the parser. obj = self.commands[cmd].parse(args[1:]) + + # Here's the side effect part - don't worry about lst not being returned. lst = self.commands[cmd].dataList() - if lst is not None: + if isinstance(obj, BaseData) and lst is not None: lst.append(obj) return obj + +class BaseHandler(KickstartHandler): + """A base kickstart handler. + + Each version of kickstart syntax is provided by a subclass of this + class. These subclasses are what users will interact with for parsing, + extracting data, and writing out kickstart files. This is an abstract + class. + """ + + def __init__(self, mapping=None, dataMapping=None, commandUpdates=None, + dataUpdates=None, *args, **kwargs): + """Create a new BaseHandler instance. This method must be provided by + all subclasses, but subclasses must call BaseHandler.__init__ first. + + mapping -- A custom map from command strings to classes, + useful when creating your own handler with + special command objects. It is otherwise unused + and rarely needed. If you give this argument, + the mapping takes the place of the default one + and so must include all commands you want + recognized. + dataMapping -- This is the same as mapping, but for data + objects. All the same comments apply. + commandUpdates -- This is similar to mapping, but does not take + the place of the defaults entirely. Instead, + this mapping is applied after the defaults and + updates it with just the commands you want to + modify. + dataUpdates -- This is the same as commandUpdates, but for + data objects. + + + Instance attributes: + + packages -- An instance of pykickstart.parser.Packages which + describes the packages section of the input file. + platform -- A string describing the hardware platform, which is + needed only by system-config-kickstart. + scripts -- A list of pykickstart.parser.Script instances, which is + populated by KickstartParser.addScript and describes the + %pre/%pre-install/%post/%traceback script section of the + input file. + """ + + # We don't want people using this class by itself. + if self.__class__ is BaseHandler: + raise TypeError("BaseHandler is an abstract class.") + + KickstartHandler.__init__(self, *args, **kwargs) + + # This isn't really a good place for these, but it's better than + # everything else I can think of. + self.scripts = [] + self.packages = Packages() + self.platform = "" + + # Any sections that we do not understand but want to prevent causing errors + # are represented by a NullSection. We want to preserve those on output, so + # keep a list of their string representations here. This is likely to change + # in the future. Don't rely on this exact implementation. + self._null_section_strings = [] + + self._registerCommands(mapping, dataMapping, commandUpdates, dataUpdates) + + def __str__(self): + """Return a string formatted for output to a kickstart file.""" + retval = "# Generated by pykickstart v%s\n" % __version__ + + if self.platform: + retval += "#platform=%s\n" % self.platform + + retval += "#version=%s\n" % versionToString(self.version) + + retval += KickstartHandler.__str__(self) + + for script in self.scripts: + retval += script.__str__() + + if self._null_section_strings: + retval += "\n" + + for s in self._null_section_strings: + retval += s + + retval += self.packages.__str__() + + return retval + + def _registerCommands(self, mapping=None, dataMapping=None, commandUpdates=None, + dataUpdates=None): + if mapping == {} or mapping is None: + from pykickstart.handlers.control import commandMap + cMap = commandMap[self.version] + else: + cMap = mapping + + if dataMapping == {} or dataMapping is None: + from pykickstart.handlers.control import dataMap + dMap = dataMap[self.version] + else: + dMap = dataMapping + + # Apply the command and data updates, but do + # not modify the original command and data maps. + if isinstance(commandUpdates, dict): + cMap = dict(cMap) + cMap.update(commandUpdates) + + if isinstance(dataUpdates, dict): + dMap = dict(dMap) + dMap.update(dataUpdates) + + for (cmdName, cmdClass) in list(cMap.items()): + self.registerCommand(cmdName, cmdClass) + + # No checks here because dMap is a bijection. At least, that's what + # the comment says. Hope no one screws that up. + for (dataName, dataClass) in list(dMap.items()): + self.registerData(dataName, dataClass) + def maskAllExcept(self, lst): """Set all entries in the commands dict to None, except the ones in the lst. All other commands will not be processed. """ self._writeOrder = {} - for (key, val) in self.commands.iteritems(): - if not key in lst: + for (key, _val) in list(self.commands.items()): + if key not in lst: self.commands[key] = None def hasCommand(self, cmd): """Return true if there is a handler for the string cmd.""" return hasattr(self, cmd) - ### ### DATA ### @@ -430,16 +573,21 @@ class BaseData(KickstartObject): def __init__(self, *args, **kwargs): """Create a new BaseData instance. - lineno -- Line number in the ks-file where this object was defined + lineno -- Line number in the ks-file where this object was defined """ # We don't want people using this class by itself. if self.__class__ is BaseData: - raise TypeError ("BaseData is an abstract class.") + raise TypeError("BaseData is an abstract class.") KickstartObject.__init__(self, *args, **kwargs) self.lineno = 0 + # If a subclass provides a removedKeywords list, warn if the user + # continues to use some of the removed keywords + for arg in (kw for kw in self.removedKeywords if kw in kwargs): + warnings.warn("The '%s' keyword has been removed." % arg, KickstartParseWarning, stacklevel=2) + def __str__(self): """Return a string formatted for output to a kickstart file.""" return "" @@ -449,7 +597,7 @@ class BaseData(KickstartObject): keyword arguments. Valid attributes are anything specified in a subclass, but unknown attributes will be ignored. """ - for (key, val) in kwargs.items(): + for (key, val) in list(kwargs.items()): # Ignore setting attributes that were removed in a subclass, as # if they were unknown attributes. if key in self.removedAttrs: @@ -463,5 +611,5 @@ class BaseData(KickstartObject): list. This method should be called from __init__ in a subclass, but only after the superclass's __init__ method has been called. """ - for attr in filter(lambda k: hasattr(self, k), self.removedAttrs): + for attr in [k for k in self.removedAttrs if hasattr(self, k)]: delattr(self, attr) diff --git a/mic/3rdparty/pykickstart/commands/__init__.py b/mic/3rdparty/pykickstart/commands/__init__.py index da48ff5..170f7cc 100644 --- a/mic/3rdparty/pykickstart/commands/__init__.py +++ b/mic/3rdparty/pykickstart/commands/__init__.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2009 Red Hat, Inc. +# Copyright 2009, 2013 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,12 +15,80 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -import authconfig, autopart, autostep, bootloader, clearpart, device -import deviceprobe, displaymode, dmraid, driverdisk, fcoe, firewall, firstboot -import group, ignoredisk, interactive, iscsi, iscsiname, key, keyboard, lang -import langsupport, lilocheck, logging, logvol, mediacheck, method, monitor -import mouse, multipath, network, partition, raid, reboot, repo, rescue, rootpw -import selinux, services, skipx, sshpw, timezone, updates, upgrade, user, vnc -import volgroup, xconfig, zerombr, zfcp +from pykickstart.commands import ( + authconfig, + authselect, + autopart, + autostep, + bootloader, + btrfs, + clearpart, + cdrom, + device, + deviceprobe, + displaymode, + dmraid, + driverdisk, + module, + eula, + fcoe, + firewall, + firstboot, + group, + harddrive, + hmc, + ignoredisk, + install, + interactive, + iscsi, + iscsiname, + key, + keyboard, + lang, + langsupport, + lilocheck, + liveimg, + logging, + logvol, + mediacheck, + method, + monitor, + mount, + mouse, + multipath, + network, + nfs, + nvdimm, + timesource, + ostreesetup, + partition, + raid, + reqpart, + realm, + reboot, + repo, + rescue, + rhsm, + rootpw, + selinux, + services, + skipx, + snapshot, + sshpw, + sshkey, + syspurpose, + timezone, + updates, + upgrade, + url, + user, + unsupported_hardware, + vnc, + volgroup, + xconfig, + zerombr, + zfcp, + zipl, +) diff --git a/mic/3rdparty/pykickstart/commands/authconfig.py b/mic/3rdparty/pykickstart/commands/authconfig.py index 9af9c0f..01b36e1 100644 --- a/mic/3rdparty/pykickstart/commands/authconfig.py +++ b/mic/3rdparty/pykickstart/commands/authconfig.py @@ -15,16 +15,23 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * +import warnings +from textwrap import dedent + +from pykickstart.errors import KickstartDeprecationWarning +from pykickstart.version import FC3, versionToLongString, F28, F35 +from pykickstart.base import KickstartCommand, RemovedCommand +from pykickstart.options import KSOptionParser + class FC3_Authconfig(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs def __init__(self, writePriority=0, *args, **kwargs): - KickstartCommand.__init__(self, *args, **kwargs) + KickstartCommand.__init__(self, writePriority, *args, **kwargs) self.authconfig = kwargs.get("authconfig", "") def __str__(self): @@ -38,3 +45,48 @@ class FC3_Authconfig(KickstartCommand): def parse(self, args): self.authconfig = self.currentLine[len(self.currentCmd):].strip() return self + + def _getParser(self): + op = KSOptionParser(prog="auth|authconfig", description=""" + This required command sets up the authentication + options for the system. This is just a wrapper + around the authconfig program, so all options + recognized by that program are valid for this + command. See the manual page for authconfig for a + complete list. + + By default, passwords are normally encrypted and + are not shadowed.""", version=FC3) + op.add_argument("options", metavar="[options]", help=""" + See ``man authconfig``.""", version=FC3) + return op + + +class F28_Authconfig(FC3_Authconfig): + removedKeywords = FC3_Authconfig.removedKeywords + removedAttrs = FC3_Authconfig.removedAttrs + + def parse(self, args): + warnings.warn("The authconfig command will be deprecated, use authselect " + "instead.", KickstartDeprecationWarning) + + return super(F28_Authconfig, self).parse(args) + + def _getParser(self): + op = super(F28_Authconfig, self)._getParser() + op.description += dedent(""" + + .. versionchanged:: %s + + The authconfig program is deprecated. This command will use the + authconfig compatibility tool, but you should use the authselect + command instead. + + """ % versionToLongString(F28)) + return op + +class F35_Authconfig(RemovedCommand, F28_Authconfig): + def _getParser(self): + op = F28_Authconfig._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F35) + return op diff --git a/mic/3rdparty/pykickstart/commands/authselect.py b/mic/3rdparty/pykickstart/commands/authselect.py new file mode 100644 index 0000000..a1caa52 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/authselect.py @@ -0,0 +1,56 @@ +# +# Vendula Poncova <vponcova@redhat.com> +# +# Copyright 2018 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser +from pykickstart.version import F28 + + +class F28_Authselect(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.authselect = kwargs.get("authselect", "") + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.authselect: + retval += "# System authorization information\nauthselect %s\n" % self.authselect + + return retval + + def parse(self, args): + self.authselect = self.currentLine[len(self.currentCmd):].strip() + return self + + def _getParser(self): + op = KSOptionParser(prog="authselect", description=""" + This command sets up the authentication options + for the system. This is just a wrapper around the + authselect program, so all options recognized by + that program are valid for this command. See the + manual page for authselect for a complete list.""", + version=F28) + + op.add_argument("options", metavar="[options]", help=""" + See ``man authselect``.""", version=F28) + return op diff --git a/mic/3rdparty/pykickstart/commands/autopart.py b/mic/3rdparty/pykickstart/commands/autopart.py index 22c3b66..38d28d3 100644 --- a/mic/3rdparty/pykickstart/commands/autopart.py +++ b/mic/3rdparty/pykickstart/commands/autopart.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc. +# Copyright 2005, 2006, 2007, 2008, 2012 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,14 +15,16 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.base import KickstartCommand +from pykickstart.version import versionToLongString, RHEL6, RHEL7, RHEL8 +from pykickstart.version import FC3, F9, F12, F16, F17, F18, F20, F21, F26, F29 +from pykickstart.constants import AUTOPART_TYPE_BTRFS, AUTOPART_TYPE_LVM, AUTOPART_TYPE_LVM_THINP, AUTOPART_TYPE_PLAIN +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_AutoPart(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -42,11 +44,22 @@ class FC3_AutoPart(KickstartCommand): def parse(self, args): if len(args) > 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "autopart")) + raise KickstartParseError(_("Kickstart command %s does not take any arguments") % "autopart", lineno=self.lineno) self.autopart = True return self + def _getParser(self): + return KSOptionParser(prog="autopart", description=""" + Automatically create partitions -- a root (``/``) partition, + a swap partition, and an appropriate boot partition + for the architecture. On large enough drives, this + will also create a /home partition. + + The ``autopart`` command can't be used with the logvol, + part/partition, raid, reqpart, or volgroup in the same + kickstart file.""", version=FC3) + class F9_AutoPart(FC3_AutoPart): removedKeywords = FC3_AutoPart.removedKeywords removedAttrs = FC3_AutoPart.removedAttrs @@ -61,29 +74,36 @@ class F9_AutoPart(FC3_AutoPart): def __str__(self): retval = KickstartCommand.__str__(self) - if self.autopart: - retval += "autopart" + if not self.autopart: + return retval + + retval += "autopart" if self.encrypted: retval += " --encrypted" - if self.passphrase != "": + if self.passphrase: retval += " --passphrase=\"%s\""% self.passphrase - if retval != "": - retval += "\n" - + retval += "\n" return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--encrypted", action="store_true", default=False) - op.add_option("--passphrase") + op = FC3_AutoPart._getParser(self) + op.add_argument("--encrypted", action="store_true", default=False, + version=F9, help=""" + Should all devices with support be encrypted by default? + This is equivalent to checking the "Encrypt" checkbox on + the initial partitioning screen.""") + op.add_argument("--passphrase", version=F9, help=""" + Only relevant if ``--encrypted`` is specified. Provide + a default system-wide passphrase for all encrypted + devices.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) self.autopart = True return self @@ -100,7 +120,10 @@ class F12_AutoPart(F9_AutoPart): def __str__(self): retval = F9_AutoPart.__str__(self) - if self.encrypted and self.escrowcert != "": + if not self.autopart: + return retval + + if self.encrypted and self.escrowcert: retval = retval.strip() retval += " --escrowcert=\"%s\"" % self.escrowcert @@ -114,6 +137,520 @@ class F12_AutoPart(F9_AutoPart): def _getParser(self): op = F9_AutoPart._getParser(self) - op.add_option("--escrowcert") - op.add_option("--backuppassphrase", action="store_true", default=False) + op.add_argument("--escrowcert", metavar="<url>", version=F12, help=""" + Only relevant if ``--encrypted`` is specified. Load an + X.509 certificate from ``<url>``. Store the data + encryption keys of all encrypted volumes created during + installation, encrypted using the certificate, as files + in ``/root``.""") + op.add_argument("--backuppassphrase", action="store_true", + default=False, version=F12, help=""" + Only relevant if ``--escrowcert`` is specified. In + addition to storing the data encryption keys, generate + a random passphrase and add it to all encrypted volumes + created during installation. Then store the passphrase, + encrypted using the certificate specified by + ``--escrowcert``, as files in ``/root`` (one file for + each encrypted volume).""") + return op + +class RHEL6_AutoPart(F12_AutoPart): + removedKeywords = F12_AutoPart.removedKeywords + removedAttrs = F12_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F12_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.cipher = kwargs.get("cipher", "") + + def __str__(self): + retval = F12_AutoPart.__str__(self) + if not self.autopart: + return retval + + if self.encrypted and self.cipher: + # remove any trailing newline + retval = retval.strip() + retval += " --cipher=\"%s\"" % self.cipher + retval += "\n" + + return retval + + def _getParser(self): + op = F12_AutoPart._getParser(self) + op.add_argument("--cipher", version=RHEL6, help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which encryption algorithm should be used to encrypt the + filesystem.""") + return op + + def parse(self, args): + # call the overriden command to do its job first + retval = F12_AutoPart.parse(self, args) + + # Using autopart together with other partitioning command such as + # part/partition, raid, logvol or volgroup can lead to hard to debug + # behavior that might among other result into an unbootable system. + # + # Therefore if any of those commands is detected in the same kickstart + # together with autopart, an error is raised and installation is + # aborted. + conflicting_command = "" + + # seen indicates that the corresponding + # command has been seen in kickstart + if self.handler.partition.seen: + conflicting_command = "part/partition" + elif self.handler.raid.seen: + conflicting_command = "raid" + elif self.handler.volgroup.seen: + conflicting_command = "volgroup" + elif self.handler.logvol.seen: + conflicting_command = "logvol" + + if conflicting_command: + # allow for translation of the error message + errorMsg = _("The %s and autopart commands can't be used at the same time") % conflicting_command + raise KickstartParseError(errorMsg, lineno=self.lineno) + return retval + + +class F16_AutoPart(F12_AutoPart): + removedKeywords = F12_AutoPart.removedKeywords + removedAttrs = F12_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F12_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.lvm = kwargs.get("lvm", True) + + def __str__(self): + retval = F12_AutoPart.__str__(self) + if not self.autopart: + return retval + + # If requested, disable LVM autopart + if not self.lvm: + # remove any trailing newline + retval = retval.strip() + retval += " --nolvm" + retval += "\n" + + return retval + + def _getParser(self): + op = F12_AutoPart._getParser(self) + op.add_argument("--nolvm", action="store_false", dest="lvm", + default=True, version=F16, + help="Don't use LVM when partitioning.") + return op + +class F17_AutoPart(F16_AutoPart): + def __init__(self, writePriority=100, *args, **kwargs): + self.typeMap = {"lvm": AUTOPART_TYPE_LVM, + "btrfs": AUTOPART_TYPE_BTRFS, + "plain": AUTOPART_TYPE_PLAIN, + "partition": AUTOPART_TYPE_PLAIN} + F16_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.type = kwargs.get("type", None) + + def _typeAsStr(self): + retval = None + + for (key, value) in list(self.typeMap.items()): + if value == self.type: + retval = key + break + + if retval == "partition": + retval = "plain" + + return retval + + def __str__(self): + retval = F16_AutoPart.__str__(self) + if not self.autopart: + return retval + + ty = self._typeAsStr() + if ty: + # remove any trailing newline + retval = retval.strip() + retval += " --type=%s\n" % ty + + return retval + + def _type_cb(self, value): + if value.lower() in self.typeMap: + return self.typeMap[value.lower()] + else: + raise KickstartParseError(_("Invalid autopart type: %s") % value, lineno=self.lineno) + + def _getParser(self): + op = F16_AutoPart._getParser(self) + op.add_argument("--nolvm", action="store_const", version=F17, + const=AUTOPART_TYPE_PLAIN, dest="type", + help="The same as ``--type=plain``") + op.add_argument("--type", type=self._type_cb, version=F17, help=""" + Select automatic partitioning scheme. Must be one of the + following: %s. Plain means regular + partitions with no btrfs or lvm.""" % list(self.typeMap.keys())) + return op + + def parse(self, args): + retval = F16_AutoPart.parse(self, args) + + # make this always True to avoid writing --nolvm + self.lvm = True + + return retval + +class F18_AutoPart(F17_AutoPart): + removedKeywords = F17_AutoPart.removedKeywords + removedAttrs = F17_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F17_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.cipher = kwargs.get("cipher", "") + + def __str__(self): + retval = F17_AutoPart.__str__(self) + if not self.autopart: + return retval + + if self.encrypted and self.cipher: + # remove any trailing newline + retval = retval.strip() + retval += " --cipher=\"%s\"" % self.cipher + retval += "\n" + + return retval + + def _getParser(self): + op = F17_AutoPart._getParser(self) + op.add_argument("--cipher", version=F18, help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which encryption algorithm should be used to encrypt the + filesystem.""") + return op + +class F20_AutoPart(F18_AutoPart): + def __init__(self, writePriority=100, *args, **kwargs): + F18_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.typeMap["thinp"] = AUTOPART_TYPE_LVM_THINP + + def parse(self, args): + # call the overriden command to do its job first + retval = F18_AutoPart.parse(self, args) + + # Using autopart together with other partitioning command such as + # part/partition, raid, logvol or volgroup can lead to hard to debug + # behavior that might among other result into an unbootable system. + # + # Therefore if any of those commands is detected in the same kickstart + # together with autopart, an error is raised and installation is + # aborted. + conflicting_command = "" + + # seen indicates that the corresponding + # command has been seen in kickstart + if self.handler.partition.seen: + conflicting_command = "part/partition" + elif self.handler.raid.seen: + conflicting_command = "raid" + elif self.handler.volgroup.seen: + conflicting_command = "volgroup" + elif self.handler.logvol.seen: + conflicting_command = "logvol" + elif hasattr(self.handler, "mount") and self.handler.mount.seen: + conflicting_command = "mount" + + if conflicting_command: + # allow for translation of the error message + errorMsg = _("The %s and autopart commands can't be used at the same time") % conflicting_command + raise KickstartParseError(errorMsg, lineno=self.lineno) + return retval + + def _getParser(self): + "Only necessary for the type change documentation" + op = F18_AutoPart._getParser(self) + for action in op._actions: + if "--type" in action.option_strings: + action.help += """ + + .. versionchanged:: %s + + Partitioning scheme 'thinp' was added.""" % versionToLongString(F20) + return op + +class F21_AutoPart(F20_AutoPart): + removedKeywords = F20_AutoPart.removedKeywords + removedAttrs = F20_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F20_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.fstype = kwargs.get("fstype", "") + + def __str__(self): + retval = F20_AutoPart.__str__(self) + if not self.autopart: + return retval + + if self.fstype: + # remove any trailing newline + retval = retval.strip() + retval += " --fstype=%s" % self.fstype + retval += "\n" + + return retval + + def _getParser(self): + op = F20_AutoPart._getParser(self) + op.add_argument("--fstype", version=F21, help=""" + Use the specified filesystem type on the partitions. + Note that it cannot be used with ``--type=btrfs`` since + btrfs is both a partition scheme and a filesystem. eg. + ``--fstype=ext4``.""") + return op + + def parse(self, args): + # call the overriden command to do its job first + retval = F20_AutoPart.parse(self, args) + + # btrfs is not a valid filesystem type + if self.fstype == "btrfs": + raise KickstartParseError(_("autopart --fstype=btrfs is not valid fstype, use --type=btrfs instead"), lineno=self.lineno) + + if self._typeAsStr() == "btrfs" and self.fstype: + raise KickstartParseError(_("autopart --fstype cannot be used with --type=btrfs"), lineno=self.lineno) + + return retval + +class F23_AutoPart(F21_AutoPart): + def parse(self, args): + # call the overriden command to do its job first + retval = F21_AutoPart.parse(self, args) + + conflicting_command = "" + if hasattr(self.handler, "reqpart") and self.handler.reqpart.seen: + conflicting_command = "reqpart" + + if conflicting_command: + # allow for translation of the error message + errorMsg = _("The %s and autopart commands can't be used at the same time") % conflicting_command + raise KickstartParseError(errorMsg, lineno=self.lineno) + + return retval + +class RHEL7_AutoPart(F21_AutoPart): + + def __init__(self, writePriority=100, *args, **kwargs): + F21_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.nohome = kwargs.get("nohome", False) + + def __str__(self): + retval = F21_AutoPart.__str__(self) + if not self.autopart: + return retval + + if self.nohome: + # remove any trailing newline + retval = retval.strip() + retval += " --nohome" + retval += "\n" + + return retval + + def _getParser(self): + op = F21_AutoPart._getParser(self) + op.add_argument("--nohome", action="store_true", default=False, + version=RHEL7, help=""" + Do not create a /home partition.""") + return op + + def parse(self, args): + # call the overriden command to do its job first + retval = F21_AutoPart.parse(self, args) + + conflicting_command = "" + if hasattr(self.handler, "reqpart") and self.handler.reqpart.seen: + conflicting_command = "reqpart" + + if conflicting_command: + # allow for translation of the error message + errorMsg = _("The %s and autopart commands can't be used at the same time") % conflicting_command + raise KickstartParseError(errorMsg, lineno=self.lineno) + + return retval + +class F26_AutoPart(F23_AutoPart): + removedKeywords = F23_AutoPart.removedKeywords + removedAttrs = F23_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F23_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.nohome = kwargs.get("nohome", False) + self.noboot = kwargs.get("noboot", False) + self.noswap = kwargs.get("noswap", False) + + def __str__(self): + retval = F23_AutoPart.__str__(self) + if not self.autopart: + return retval + + if self.nohome: + # remove any trailing newline + retval = retval.strip() + retval += " --nohome" + retval += "\n" + + if self.noboot: + # remove any trailing newline + retval = retval.strip() + retval += " --noboot" + retval += "\n" + + if self.noswap: + # remove any trailing newline + retval = retval.strip() + retval += " --noswap" + retval += "\n" + + return retval + + def _getParser(self): + op = F23_AutoPart._getParser(self) + op.add_argument("--nohome", action="store_true", default=False, + version=F26, help=""" + Do not create a /home partition.""") + op.add_argument("--noboot", action="store_true", default=False, + version=F26, help=""" + Do not create a /boot partition.""") + op.add_argument("--noswap", action="store_true", default=False, + version=F26, help=""" + Do not create a swap partition.""") + return op + +class F29_AutoPart(F26_AutoPart): + removedKeywords = F26_AutoPart.removedKeywords + removedAttrs = F26_AutoPart.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + F26_AutoPart.__init__(self, writePriority=writePriority, *args, **kwargs) + self.luks_version = kwargs.get("luks_version", "") + self.pbkdf = kwargs.get("pbkdf", "") + self.pbkdf_memory = kwargs.get("pbkdf_memory", 0) + self.pbkdf_time = kwargs.get("pbkdf_time", 0) + self.pbkdf_iterations = kwargs.get("pbkdf_iterations", 0) + + def __str__(self): + retval = F26_AutoPart.__str__(self) + if not self.autopart: + return retval + + if self.encrypted and self.luks_version: + retval = retval.strip() + retval += " --luks-version=%s" % self.luks_version + retval += "\n" + + if self.encrypted and self.pbkdf: + retval = retval.strip() + retval += " --pbkdf=%s" % self.pbkdf + retval += "\n" + + if self.encrypted and self.pbkdf_memory: + retval = retval.strip() + retval += " --pbkdf-memory=%s" % self.pbkdf_memory + retval += "\n" + + if self.encrypted and self.pbkdf_time: + retval = retval.strip() + retval += " --pbkdf-time=%s" % self.pbkdf_time + retval += "\n" + + if self.encrypted and self.pbkdf_iterations: + retval = retval.strip() + retval += " --pbkdf-iterations=%s" % self.pbkdf_iterations + retval += "\n" + + return retval + + def _getParser(self): + op = F26_AutoPart._getParser(self) + op.add_argument("--luks-version", dest="luks_version", version=F29, default="", + help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which version of LUKS format should be used to encrypt + the filesystem.""") + op.add_argument("--pbkdf", version=F29, default="", help=""" + Only relevant if ``--encrypted`` is specified. Sets + Password-Based Key Derivation Function (PBKDF) algorithm + for LUKS keyslot. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-memory", dest="pbkdf_memory", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the memory cost for PBKDF. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-time", dest="pbkdf_time", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of milliseconds to spend with PBKDF passphrase + processing. See ``--iter-time`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) + op.add_argument("--pbkdf-iterations", dest="pbkdf_iterations", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of iterations directly and avoids PBKDF benchmark. + See ``--pbkdf-force-iterations`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) return op + + def parse(self, args): + retval = F26_AutoPart.parse(self, args) + + if self.pbkdf_time and self.pbkdf_iterations: + msg = _("Only one of --pbkdf-time and --pbkdf-iterations can be specified.") + raise KickstartParseError(msg, lineno=self.lineno) + + return retval + +class RHEL8_AutoPart(F29_AutoPart): + removedKeywords = F29_AutoPart.removedKeywords + removedAttrs = F29_AutoPart.removedAttrs + + def parse(self, args): + # call the overriden command to do it's job first + retval = F29_AutoPart.parse(self, args) + + # btrfs is no more supported + if self._typeAsStr() == "btrfs": + raise KickstartParseError(_("autopart --type=btrfs is not supported"), + lineno=self.lineno) + + return retval + + def _getParser(self): + "Only necessary for the type change documentation" + op = F29_AutoPart._getParser(self) + for action in op._actions: + if "--type" in action.option_strings: + action.help += """ + + .. versionchanged:: %s + + Partitioning scheme 'btrfs' was removed.""" % versionToLongString(RHEL8) + if "--fstype" in action.option_strings: + action.help += """ + + .. versionchanged:: %s + + Partitioning scheme 'btrfs' was removed.""" % versionToLongString(RHEL8) + return op + + +class RHEL9_AutoPart(RHEL8_AutoPart): + pass + diff --git a/mic/3rdparty/pykickstart/commands/autostep.py b/mic/3rdparty/pykickstart/commands/autostep.py index e6ae71c..84a9fcd 100644 --- a/mic/3rdparty/pykickstart/commands/autostep.py +++ b/mic/3rdparty/pykickstart/commands/autostep.py @@ -15,10 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.version import FC3, F34, versionToLongString +from pykickstart.base import KickstartCommand, DeprecatedCommand +from pykickstart.options import KSOptionParser class FC3_AutoStep(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -43,13 +44,32 @@ class FC3_AutoStep(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--autoscreenshot", dest="autoscreenshot", - action="store_true", default=False) + op = KSOptionParser(prog="autostep", description=""" + Kickstart installs normally skip unnecessary screens. + This makes the installer step through every screen, + displaying each briefly. + + This is mostly used for debugging.""", + version=FC3) + op.add_argument("--autoscreenshot", action="store_true", default=False, + version=FC3, help=""" + Take a screenshot at every step during installation and + copy the images over to ``/root/anaconda-screenshots`` after + installation is complete. This is most useful for + documentation.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) self.autostep = True return self + +class F34_AutoStep(DeprecatedCommand, FC3_AutoStep): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = FC3_AutoStep._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/bootloader.py b/mic/3rdparty/pykickstart/commands/bootloader.py index b227fac..66055e8 100644 --- a/mic/3rdparty/pykickstart/commands/bootloader.py +++ b/mic/3rdparty/pykickstart/commands/bootloader.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2007 Red Hat, Inc. +# Copyright 2007-2014 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,10 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.version import RHEL5, RHEL6, versionToLongString +from pykickstart.version import FC3, FC4, F8, F12, F14, F15, F17, F18, F19, F21, F29, F34 +from pykickstart.base import KickstartCommand, RemovedCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser, commaSplit + +from pykickstart.i18n import _ class FC3_Bootloader(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -32,7 +37,7 @@ class FC3_Bootloader(KickstartCommand): self.appendLine = kwargs.get("appendLine", "") self.forceLBA = kwargs.get("forceLBA", False) self.linear = kwargs.get("linear", True) - self.location = kwargs.get("location", "") + self.location = kwargs.get("location", "none") self.md5pass = kwargs.get("md5pass", "") self.password = kwargs.get("password", "") self.upgrade = kwargs.get("upgrade", False) @@ -43,7 +48,7 @@ class FC3_Bootloader(KickstartCommand): def _getArgsAsStr(self): retval = "" - if self.appendLine != "": + if self.appendLine: retval += " --append=\"%s\"" % self.appendLine if self.linear: retval += " --linear" @@ -51,9 +56,9 @@ class FC3_Bootloader(KickstartCommand): retval += " --location=%s" % self.location if hasattr(self, "forceLBA") and self.forceLBA: retval += " --lba32" - if self.password != "": + if self.password: retval += " --password=\"%s\"" % self.password - if self.md5pass != "": + if self.md5pass: retval += " --md5pass=\"%s\"" % self.md5pass if self.upgrade: retval += " --upgrade" @@ -67,46 +72,103 @@ class FC3_Bootloader(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.location != "": + if self.location: retval += "# System bootloader configuration\nbootloader" retval += self._getArgsAsStr() + "\n" return retval def _getParser(self): - def driveorder_cb (option, opt_str, value, parser): - for d in value.split(','): - parser.values.ensure_value(option.dest, []).append(d) - - op = KSOptionParser() - op.add_option("--append", dest="appendLine") - op.add_option("--linear", dest="linear", action="store_true", - default=True) - op.add_option("--nolinear", dest="linear", action="store_false") - op.add_option("--location", dest="location", type="choice", - default="mbr", - choices=["mbr", "partition", "none", "boot"]) - op.add_option("--lba32", dest="forceLBA", action="store_true", - default=False) - op.add_option("--password", dest="password", default="") - op.add_option("--md5pass", dest="md5pass", default="") - op.add_option("--upgrade", dest="upgrade", action="store_true", - default=False) - op.add_option("--useLilo", dest="useLilo", action="store_true", - default=False) - op.add_option("--driveorder", dest="driveorder", action="callback", - callback=driveorder_cb, nargs=1, type="string") + op = KSOptionParser(prog="bootloader", description=""" + This required command specifies how the boot loader + should be installed. + + There must be a biosboot partition for the bootloader + to be installed successfully onto a disk that contains + a GPT/GUID partition table, which includes disks + initialized by anaconda. This partition may be created + with the kickstart command + ``part biosboot --fstype=biosboot --size=1``. However, + in the case that a disk has an existing biosboot + partition, adding a ``part biosboot`` option is + unnecessary.""", version=FC3) + op.add_argument("--append", dest="appendLine", version=FC3, help=""" + Specifies additional kernel parameters. For example: + + ``bootloader --location=mbr --append="hdd=ide-scsi ide=nodma"`` + + **Note** The installer will add the bootloader arguments ``rhgb + quiet`` if plymouth is installed on the target system. You can + disable these options with ``-plymouth`` in the ``%%packages`` + section. + """) + op.add_argument("--linear", action="store_true", default=True, + version=FC3, help="use linear mode to access hard disks (for LILO only)") + op.add_argument("--nolinear", dest="linear", action="store_false", + version=FC3, help="do not use linear mode to access hard disks (for LILO only)") + op.add_argument("--location", default="mbr", version=FC3, + choices=["mbr", "partition", "none", "boot"], + help=""" + Specifies where the boot record is written. Valid values + are the following: mbr (the default), partition + (installs the boot loader on the first sector of the + partition containing the kernel), or none + (do not install the boot loader). + + **Note** `bootloader --location=none` is different from + `bootloader --location=none --disabled`. + `--location=none` prevents extra installation steps + that makes the target machine bootable, e.g. write to + MBR on x86 BIOS systems. However, the corresponding RPM + packages are still installed, and `--disabled` can be + appended to prevent it. `bootloader --disabled` only + does not prevent the installation of the bootloader and + Anaconda will complain if no other options are + provided. + """) + op.add_argument("--lba32", dest="forceLBA", action="store_true", + default=False, version=FC3, help="force the use of LBA32 mode for hard disk access (LILO only)") + op.add_argument("--password", default="", version=FC3, help=""" + If using GRUB, sets the GRUB boot loader password. This + should be used to restrict access to the GRUB shell, + where arbitrary kernel options can be passed.""") + op.add_argument("--md5pass", default="", version=FC3, help=""" + If using GRUB, similar to ``--password=`` except the + password should already be encrypted.""") + op.add_argument("--upgrade", action="store_true", default=False, + version=FC3, help="upgrade the boot loader installed on disk") + op.add_argument("--useLilo", action="store_true", default=False, + version=FC3, help="force the use of LILO") + op.add_argument("--driveorder", type=commaSplit, version=FC3, help="define the explicit hard disk order the boot loader should use") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) if self.currentCmd == "lilo": self.useLilo = True return self + +class FC3_Lilo(FC3_Bootloader): + """ + This is for backwards compatibility and docs generation. + Used only in FC3, RHEL3 and RHEL4. + """ + def _getParser(self): + op = super(FC3_Lilo, self)._getParser() + op.prog = "lilo" + return op + +class FC4_Lilo(RemovedCommand, FC3_Lilo): + def _getParser(self): + op = FC3_Lilo._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(FC4) + return op + + class FC4_Bootloader(FC3_Bootloader): removedKeywords = FC3_Bootloader.removedKeywords + ["linear", "useLilo"] removedAttrs = FC3_Bootloader.removedAttrs + ["linear", "useLilo"] @@ -116,15 +178,15 @@ class FC4_Bootloader(FC3_Bootloader): def _getArgsAsStr(self): retval = "" - if self.appendLine != "": + if self.appendLine: retval += " --append=\"%s\"" % self.appendLine if self.location: retval += " --location=%s" % self.location if hasattr(self, "forceLBA") and self.forceLBA: retval += " --lba32" - if self.password != "": + if self.password: retval += " --password=\"%s\"" % self.password - if self.md5pass != "": + if self.md5pass: retval += " --md5pass=\"%s\"" % self.md5pass if self.upgrade: retval += " --upgrade" @@ -134,14 +196,14 @@ class FC4_Bootloader(FC3_Bootloader): def _getParser(self): op = FC3_Bootloader._getParser(self) - op.remove_option("--linear") - op.remove_option("--nolinear") - op.remove_option("--useLilo") + op.remove_argument("--linear", version=FC4) + op.remove_argument("--nolinear", version=FC4) + op.remove_argument("--useLilo", version=FC4) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self class F8_Bootloader(FC4_Bootloader): @@ -158,16 +220,20 @@ class F8_Bootloader(FC4_Bootloader): ret = FC4_Bootloader._getArgsAsStr(self) if self.timeout is not None: - ret += " --timeout=%d" %(self.timeout,) + ret += " --timeout=%d" % (self.timeout,) if self.default: - ret += " --default=%s" %(self.default,) + ret += " --default=%s" % (self.default,) return ret def _getParser(self): op = FC4_Bootloader._getParser(self) - op.add_option("--timeout", dest="timeout", type="int") - op.add_option("--default", dest="default") + op.add_argument("--timeout", type=int, version=F8, help=""" + Specify the number of seconds before the bootloader + times out and boots the default option.""") + op.add_argument("--default", version=F8, help=""" + Sets the default boot image in the bootloader + configuration.""") return op class F12_Bootloader(F8_Bootloader): @@ -176,7 +242,9 @@ class F12_Bootloader(F8_Bootloader): def _getParser(self): op = F8_Bootloader._getParser(self) - op.add_option("--lba32", dest="forceLBA", deprecated=1, action="store_true") + op.add_argument("--lba32", dest="forceLBA", action="store_true", + help="force the use of LBA32 mode for hard disk access (LILO only)", + deprecated=F12) return op class F14_Bootloader(F12_Bootloader): @@ -185,7 +253,7 @@ class F14_Bootloader(F12_Bootloader): def _getParser(self): op = F12_Bootloader._getParser(self) - op.remove_option("--lba32") + op.remove_argument("--lba32", version=F14) return op class F15_Bootloader(F14_Bootloader): @@ -206,13 +274,86 @@ class F15_Bootloader(F14_Bootloader): return ret def _getParser(self): - def password_cb(option, opt_str, value, parser): - parser.values.isCrypted = True - parser.values.password = value - op = F14_Bootloader._getParser(self) - op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False) - op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string") + op.add_argument("--iscrypted", dest="isCrypted", action="store_true", + default=False, version=F15, help=""" + If given, the password specified by ``--password=`` is + already encrypted and should be passed to the bootloader + configuration without additional modification.""") + op.add_argument("--md5pass", dest="_md5pass", metavar="MD5PASS", version=F15, + help="Alias for ``--password=MD5PASS --iscrypted``.") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + + # argparse doesn't give us a way to set two things at once, so we need to check if + # _md5pass was given and if so, set everything now. + if getattr(ns, "_md5pass", None): + ns.password = ns._md5pass + ns.isCrypted = True + del ns._md5pass + + self.set_to_self(ns) + return self + +class F17_Bootloader(F15_Bootloader): + removedKeywords = F15_Bootloader.removedKeywords + removedAttrs = F15_Bootloader.removedAttrs + + def __init__(self, writePriority=10, *args, **kwargs): + F15_Bootloader.__init__(self, writePriority, *args, **kwargs) + + self.bootDrive = kwargs.get("bootDrive", "") + + def _getArgsAsStr(self): + ret = F15_Bootloader._getArgsAsStr(self) + + if self.bootDrive: + ret += " --boot-drive=%s" % self.bootDrive + + return ret + + def _getParser(self): + op = F15_Bootloader._getParser(self) + op.add_argument("--boot-drive", dest="bootDrive", default="", + version=F17, help=""" + Specifies which drive the bootloader should be written + to and thus, which drive the computer will boot from.""") + return op + + def parse(self, args): + retval = F15_Bootloader.parse(self, args) + + if "," in retval.bootDrive: # pylint: disable=no-member + raise KickstartParseError(_("--boot-drive accepts only one argument"), lineno=self.lineno) + + return retval + +class F18_Bootloader(F17_Bootloader): + removedKeywords = F17_Bootloader.removedKeywords + removedAttrs = F17_Bootloader.removedAttrs + + def __init__(self, writePriority=10, *args, **kwargs): + F17_Bootloader.__init__(self, writePriority, *args, **kwargs) + + self.leavebootorder = kwargs.get("leavebootorder", False) + + def _getArgsAsStr(self): + ret = F17_Bootloader._getArgsAsStr(self) + + if self.leavebootorder: + ret += " --leavebootorder" + + return ret + + def _getParser(self): + op = F17_Bootloader._getParser(self) + op.add_argument("--leavebootorder", action="store_true", default=False, + version=F18, help=""" + On EFI or ISeries/PSeries machines, this option prevents + the installer from making changes to the existing list + of bootable images.""") return op class RHEL5_Bootloader(FC4_Bootloader): @@ -228,13 +369,16 @@ class RHEL5_Bootloader(FC4_Bootloader): ret = FC4_Bootloader._getArgsAsStr(self) if self.hvArgs: - ret += " --hvargs=\"%s\"" %(self.hvArgs,) + ret += " --hvargs=\"%s\"" % (self.hvArgs,) return ret def _getParser(self): op = FC4_Bootloader._getParser(self) - op.add_option("--hvargs", dest="hvArgs", type="string") + # todo: this is only in RHEL5 and nowhere else + # possibly shadowed by the way we implement commands + # inheritance + op.add_argument("--hvargs", dest="hvArgs", version=RHEL5, help="specify Xen hypervisor kernel arguments") return op class RHEL6_Bootloader(F12_Bootloader): @@ -255,11 +399,118 @@ class RHEL6_Bootloader(F12_Bootloader): return ret def _getParser(self): - def password_cb(option, opt_str, value, parser): - parser.values.isCrypted = True - parser.values.password = value - op = F12_Bootloader._getParser(self) - op.add_option("--iscrypted", dest="isCrypted", action="store_true", default=False) - op.add_option("--md5pass", action="callback", callback=password_cb, nargs=1, type="string") + op.add_argument("--iscrypted", dest="isCrypted", action="store_true", + default=False, version=RHEL6, help=""" + If given, the password specified by ``--password=`` is + already encrypted and should be passed to the bootloader + configuration without additional modification.""") + op.add_argument("--md5pass", dest="_md5pass", metavar="MD5PASS", version=RHEL6, + help="Alias for ``--password=MD5PASS --iscrypted``.") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + + # argparse doesn't give us a way to set two things at once, so we need to check if + # _md5pass was given and if so, set everything now. + if getattr(ns, "_md5pass", None): + ns.password = ns._md5pass + ns.isCrypted = True + del ns._md5pass + + self.set_to_self(ns) + return self + +class F19_Bootloader(F18_Bootloader): + removedKeywords = F18_Bootloader.removedKeywords + removedAttrs = F18_Bootloader.removedAttrs + + def __init__(self, writePriority=10, *args, **kwargs): + F18_Bootloader.__init__(self, writePriority, *args, **kwargs) + + self.extlinux = kwargs.get("extlinux", False) + + def _getArgsAsStr(self): + ret = F18_Bootloader._getArgsAsStr(self) + + if self.extlinux: + ret += " --extlinux" + + return ret + + def _getParser(self): + op = F18_Bootloader._getParser(self) + op.add_argument("--extlinux", action="store_true", default=False, + version=F19, help=""" + Use the extlinux bootloader instead of GRUB. This option + only works on machines that are supported by extlinux.""") + return op + +class F21_Bootloader(F19_Bootloader): + removedKeywords = F19_Bootloader.removedKeywords + removedAttrs = F19_Bootloader.removedAttrs + + def __init__(self, writePriority=10, *args, **kwargs): + F19_Bootloader.__init__(self, writePriority, *args, **kwargs) + + self.disabled = kwargs.get("disabled", False) + self.nombr = kwargs.get("nombr", False) + + def _getArgsAsStr(self): + if self.disabled: + return " --disabled" + + ret = F19_Bootloader._getArgsAsStr(self) + if self.nombr: + ret += " --nombr" + return ret + + def _getParser(self): + op = F19_Bootloader._getParser(self) + op.add_argument("--disabled", action="store_true", default=False, + version=F21, help=""" + Do not install the boot loader. + + **Note** `bootloader --location=none` is different from + `bootloader --location=none --disabled`. + `--location=none` prevents extra installation steps + that makes the target machine bootable, e.g. write to + MBR on x86 BIOS systems. However, the corresponding RPM + packages are still installed, and `--disabled` can be + appended to prevent it. `bootloader --disabled` only + does not prevent the installation of the bootloader and + Anaconda will complain if no other options are + provided. + """) + op.add_argument("--nombr", action="store_true", default=False, + version=F21, help="do not install the boot loader to the MBR") return op + +class RHEL7_Bootloader(F21_Bootloader): + pass + +class F29_Bootloader(F21_Bootloader): + removedKeywords = F21_Bootloader.removedKeywords + removedAttrs = F21_Bootloader.removedAttrs + + def _getParser(self): + op = F21_Bootloader._getParser(self) + op.add_argument("--upgrade", action="store_true", default=False, + deprecated=F29, help="upgrade the boot loader installed on disk") + return op + +class RHEL8_Bootloader(F29_Bootloader): + pass + +class F34_Bootloader(F29_Bootloader): + removedKeywords = F29_Bootloader.removedKeywords + removedAttrs = F29_Bootloader.removedAttrs + + def _getParser(self): + op = F29_Bootloader._getParser(self) + op.remove_argument("--upgrade", version=F34) + return op + +class RHEL9_Bootloader(F34_Bootloader): + pass diff --git a/mic/3rdparty/pykickstart/commands/btrfs.py b/mic/3rdparty/pykickstart/commands/btrfs.py new file mode 100644 index 0000000..ddfce52 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/btrfs.py @@ -0,0 +1,281 @@ +# +# Chris Lumens <clumens@redhat.com> +# David Lehman <dlehman@redhat.com> +# +# Copyright 2005, 2006, 2007, 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import F17, F23, RHEL8, versionToLongString +from pykickstart.base import BaseData, KickstartCommand, DeprecatedCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser, mountpoint + +import warnings +from pykickstart.i18n import _ + +class F17_BTRFSData(BaseData): + removedKeywords = BaseData.removedKeywords + removedAttrs = BaseData.removedAttrs + + def __init__(self, *args, **kwargs): + BaseData.__init__(self, *args, **kwargs) + self.format = kwargs.get("format", True) + self.preexist = kwargs.get("preexist", False) + self.label = kwargs.get("label", "") + self.mountpoint = kwargs.get("mountpoint", "") + self.devices = kwargs.get("devices", []) + self.dataLevel = kwargs.get("data", None) or kwargs.get("dataLevel", None) + self.metaDataLevel = kwargs.get("metadata", None) or kwargs.get("metaDataLevel", None) + + # subvolume-specific + self.subvol = kwargs.get("subvol", False) + self.parent = kwargs.get("parent", "") + self.name = kwargs.get("name", None) # required + + def __eq__(self, y): + if not y: + return False + + return self.mountpoint == y.mountpoint + + def __ne__(self, y): + return not self == y + + def _getArgsAsStr(self): + retval = "" + if not self.format: + retval += " --noformat" + if self.preexist: + retval += " --useexisting" + if self.label: + retval += " --label=%s" % self.label + if self.dataLevel: + retval += " --data=%s" % self.dataLevel.lower() + if self.metaDataLevel: + retval += " --metadata=%s" % self.metaDataLevel.lower() + if self.subvol: + retval += " --subvol --name=%s" % self.name + + return retval + + def __str__(self): + retval = BaseData.__str__(self) + retval += "btrfs %s" % self.mountpoint + retval += self._getArgsAsStr() + return retval + " " + " ".join(self.devices) + "\n" + +class F23_BTRFSData(F17_BTRFSData): + removedKeywords = F17_BTRFSData.removedKeywords + removedAttrs = F17_BTRFSData.removedAttrs + + def __init__(self, *args, **kwargs): + F17_BTRFSData.__init__(self, *args, **kwargs) + self.mkfsopts = kwargs.get("mkfsoptions", "") or kwargs.get("mkfsopts", "") + + def _getArgsAsStr(self): + retval = F17_BTRFSData._getArgsAsStr(self) + + if self.mkfsopts: + retval += " --mkfsoptions=\"%s\"" % self.mkfsopts + + return retval + +class RHEL7_BTRFSData(F23_BTRFSData): + pass + +class F17_BTRFS(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=132, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + # A dict of all the RAID levels we support. This means that if we + # support more levels in the future, subclasses don't have to + # duplicate too much. + self.levelMap = {"raid0": "raid0", "0": "raid0", + "raid1": "raid1", "1": "raid1", + "raid10": "raid10", "10": "raid10", + "single": "single"} + + self.btrfsList = kwargs.get("btrfsList", []) + + def __str__(self): + retval = "" + for btr in self.btrfsList: + retval += btr.__str__() + + return retval + + def _getParser(self): + def level_cb(value): + if value.lower() in self.levelMap: + return self.levelMap[value.lower()] + else: + raise KickstartParseError(_("Invalid btrfs level: %s") % value, lineno=self.lineno) + + op = KSOptionParser(prog="btrfs", description=""" + Defines a BTRFS volume or subvolume. This command + is of the form: + + ``btrfs <mntpoint> --data=<level> --metadata=<level> --label=<label> <partitions*>`` + + for volumes and of the form: + + ``btrfs <mntpoint> --subvol --name=<path> <parent>`` + + for subvolumes. + + The ``<partitions*>`` (which denotes that multiple + partitions can be listed) lists the BTRFS identifiers + to add to the BTRFS volume. For subvolumes, should be + the identifier of the subvolume's parent volume. + + ``<mntpoint>`` + + Location where the file system is mounted.""", + epilog=""" + The following example shows how to create a BTRFS + volume from member partitions on three disks with + subvolumes for root and home. The main volume is not + mounted or used directly in this example -- only + the root and home subvolumes:: + + part btrfs.01 --size=6000 --ondisk=sda + part btrfs.02 --size=6000 --ondisk=sdb + part btrfs.03 --size=6000 --ondisk=sdc + + btrfs none --data=0 --metadata=1 --label=f17 btrfs.01 btrfs.02 btrfs.03 + btrfs / --subvol --name=root LABEL=f17 + btrfs /home --subvol --name=home f17""", + version=F17) + op.add_argument("--noformat", dest="format", action="store_false", + default=True, version=F17, help=""" + Use an existing BTRFS volume (or subvolume) and do not + reformat the filesystem.""") + op.add_argument("--useexisting", dest="preexist", action="store_true", + default=False, help="Same as ``--noformat``.", + version=F17) + + # label, data, metadata + op.add_argument("--label", default="", version=F17, help=""" + Specify the label to give to the filesystem to be made. + If the given label is already in use by another + filesystem, a new label will be created. This option + has no meaning for subvolumes.""") + op.add_argument("--data", dest="dataLevel", type=level_cb, help=""" + RAID level to use (0, 1, 10) for filesystem data. Optional. + This option has no meaning for subvolumes.""", + version=F17) + op.add_argument("--metadata", dest="metaDataLevel", type=level_cb, + version=F17, help=""" + RAID level to use (0, 1, 10) for filesystem/volume + metadata. Optional. This option has no meaning for + subvolumes.""") + + # + # subvolumes + # + op.add_argument("--subvol", action="store_true", default=False, + version=F17, help="Create BTRFS subvolume.") + + # parent must be a device spec (LABEL, UUID, &c) + op.add_argument("--parent", default="", version=F17, help="BTRFS parent device") + op.add_argument("--name", default="", version=F17, help=""" + Subvolume name.""") + return op + + def parse(self, args): + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + data = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, data) + data.lineno = self.lineno + + if not data.format: + data.preexist = True + elif data.preexist: + data.format = False + + if not extra: + raise KickstartParseError(_("btrfs must be given a mountpoint"), lineno=self.lineno) + elif any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "btrfs", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + data.mountpoint = mountpoint(extra[0]) + data.devices = extra[1:] + + if not any([data.devices, data.subvol]): + raise KickstartParseError(_("btrfs must be given a list of partitions"), lineno=self.lineno) + elif not data.devices: + raise KickstartParseError(_("btrfs subvol requires specification of parent volume"), lineno=self.lineno) + + if data.subvol and not data.name: + raise KickstartParseError(_("btrfs subvolume requires a name"), lineno=self.lineno) + + # Check for duplicates in the data list. + if data in self.dataList(): + warnings.warn(_("A btrfs volume with the mountpoint %s has already been defined.") % data.mountpoint, KickstartParseWarning) + + return data + + def dataList(self): + return self.btrfsList + + @property + def dataClass(self): + return self.handler.BTRFSData + +class F23_BTRFS(F17_BTRFS): + removedKeywords = F17_BTRFS.removedKeywords + removedAttrs = F17_BTRFS.removedAttrs + + def _getParser(self): + op = F17_BTRFS._getParser(self) + op.add_argument("--mkfsoptions", dest="mkfsopts", version=F23, help=""" + Specifies additional parameters to be passed to the + program that makes a filesystem on this partition. No + processing is done on the list of arguments, so they + must be supplied in a format that can be passed directly + to the mkfs program. This means multiple options should + be comma-separated or surrounded by double quotes, + depending on the filesystem.""") + return op + + def parse(self, args): + data = F17_BTRFS.parse(self, args) + + if (data.preexist or not data.format) and data.mkfsopts: + raise KickstartParseError(_("--mkfsoptions with --noformat or --useexisting has no effect."), lineno=self.lineno) + + return data + +class RHEL7_BTRFS(F23_BTRFS): + pass + +class RHEL8_BTRFS(DeprecatedCommand, F23_BTRFS): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = F23_BTRFS._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(RHEL8) + return op + +class RHEL9_BTRFS(RHEL8_BTRFS): + pass diff --git a/mic/3rdparty/pykickstart/commands/cdrom.py b/mic/3rdparty/pykickstart/commands/cdrom.py new file mode 100644 index 0000000..cea186e --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/cdrom.py @@ -0,0 +1,48 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2007, 2009, 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import FC3 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ + +class FC3_Cdrom(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use CDROM installation media\ncdrom\n" + return retval + + def parse(self, args): + if args: + raise KickstartParseError(_("Kickstart command %s does not take any arguments") % self.currentCmd, lineno=self.lineno) + + return self + + def _getParser(self): + return KSOptionParser(prog="cdrom", description=""" + Install from the first CD-ROM/DVD drive on the + system.""", version=FC3) diff --git a/mic/3rdparty/pykickstart/commands/clearpart.py b/mic/3rdparty/pykickstart/commands/clearpart.py index a8089fc..0e459c4 100644 --- a/mic/3rdparty/pykickstart/commands/clearpart.py +++ b/mic/3rdparty/pykickstart/commands/clearpart.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005, 2006, 2007 Red Hat, Inc. +# Copyright 2005, 2006, 2007, 2012 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,12 +15,12 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC3, F17, F21, F25, F28 +from pykickstart.base import KickstartCommand +from pykickstart.constants import CLEARPART_TYPE_ALL, CLEARPART_TYPE_LINUX, CLEARPART_TYPE_LIST, CLEARPART_TYPE_NONE +from pykickstart.options import KSOptionParser, commaSplit class FC3_ClearPart(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -41,46 +41,170 @@ class FC3_ClearPart(KickstartCommand): return retval if self.type == CLEARPART_TYPE_NONE: - clearstr = "--none" + clearstr = " --none" elif self.type == CLEARPART_TYPE_LINUX: - clearstr = "--linux" + clearstr = " --linux" elif self.type == CLEARPART_TYPE_ALL: - clearstr = "--all" + clearstr = " --all" else: clearstr = "" if self.initAll: - initstr = "--initlabel" + initstr = " --initlabel" else: initstr = "" - if len(self.drives) > 0: - drivestr = "--drives=" + ",".join(self.drives) + if self.drives: + drivestr = " --drives=" + ",".join(self.drives) else: drivestr = "" - retval += "# Partition clearing information\nclearpart %s %s %s\n" % (clearstr, initstr, drivestr) + retval += "# Partition clearing information\nclearpart%s%s%s\n" % (clearstr, initstr, drivestr) return retval def _getParser(self): - def drive_cb (option, opt_str, value, parser): - for d in value.split(','): - parser.values.ensure_value(option.dest, []).append(d) - - op = KSOptionParser() - op.add_option("--all", dest="type", action="store_const", - const=CLEARPART_TYPE_ALL) - op.add_option("--drives", dest="drives", action="callback", - callback=drive_cb, nargs=1, type="string") - op.add_option("--initlabel", dest="initAll", action="store_true", - default=False) - op.add_option("--linux", dest="type", action="store_const", - const=CLEARPART_TYPE_LINUX) - op.add_option("--none", dest="type", action="store_const", - const=CLEARPART_TYPE_NONE) + op = KSOptionParser(prog="clearpart", description=""" + Removes partitions from the system, prior to creation + of new partitions. By default, no partitions are + removed. + + If the clearpart command is used, then the ``--onpart`` + command cannot be used on a logical partition.""", + version=FC3) + op.add_argument("--all", dest="type", action="store_const", + const=CLEARPART_TYPE_ALL, version=FC3, + help="Erases all partitions from the system.") + op.add_argument("--drives", type=commaSplit, help=""" + Specifies which drives to clear partitions from. For + example, the following clears the partitions on the + first two drives on the primary IDE controller:: + + ``clearpart --all --drives=sda,sdb``""", + version=FC3) + op.add_argument("--initlabel", dest="initAll", action="store_true", + default=False, version=FC3, help=""" + Initializes the disk label to the default for your + architecture (for example msdos for x86 and gpt for + Itanium). This is only meaningful in combination with + the '--all' option.""") + op.add_argument("--linux", dest="type", action="store_const", + const=CLEARPART_TYPE_LINUX, version=FC3, + help="Erases all Linux partitions.") + op.add_argument("--none", dest="type", action="store_const", + const=CLEARPART_TYPE_NONE, version=FC3, help=""" + Do not remove any partitions. This is the default""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self + +class F17_ClearPart(FC3_ClearPart): + def __init__(self, *args, **kwargs): + super(F17_ClearPart, self).__init__(*args, **kwargs) + self.devices = kwargs.get("devices", []) + + def __str__(self): + s = super(F17_ClearPart, self).__str__() + if s and self.devices: + s = s.rstrip() + s += " --list=" + ",".join(self.devices) + s += "\n" + return s + + def _getParser(self): + op = FC3_ClearPart._getParser(self) + op.add_argument("--list", dest="devices", type=commaSplit, + version=F17, help=""" + Specifies which partitions to clear. If given, this + supersedes any of the ``--all`` and ``--linux`` + options. This can be across different drives:: + + ``clearpart --list=sda2,sda3,sdb1``""") + return op + + def parse(self, args): + obj = FC3_ClearPart.parse(self, args) + if getattr(obj, "devices", []): + obj.type = CLEARPART_TYPE_LIST + + return obj + +class F21_ClearPart(F17_ClearPart): + def __init__(self, *args, **kwargs): + super(F21_ClearPart, self).__init__(*args, **kwargs) + self.disklabel = kwargs.get("disklabel", "") + + def __str__(self): + s = super(F21_ClearPart, self).__str__() + if s and self.disklabel: + s = s.rstrip() + s += " --disklabel=%s\n" % self.disklabel + return s + + def _getParser(self): + op = F17_ClearPart._getParser(self) + op.add_argument("--disklabel", default="", version=F21, help=""" + Set the default disklabel to use. Only disklabels + supported for the platform will be accepted. eg. msdos + and gpt for x86_64 but not dasd.""") + return op + +class F25_ClearPart(F21_ClearPart): + def _getParser(self): + op = super(F25_ClearPart, self)._getParser() + op.add_argument("--drives", type=commaSplit, version=F25, help=""" + The following clears the partitions on the first + two drives on the system: + + ``clearpart --drives=sda,sdb`` + + or clear as many drives as it could and skip the missing + (at least one must be matched): + + ``clearpart --drives=sda|sdb1`` + + or clear all virtio drives and only first scsi device if + exists + + ``clearpart --drives=sda|vd*``""") + op.add_argument("--list", dest="devices", type=commaSplit, + version=F25, help=""" + The following clears the partitions on the first + two drives on the system: + + ``clearpart --list=sda,sdb`` + + or clear as many drives as it could and skip the missing + (at least one must be matched): + + ``clearpart --list=sda|sdb1`` + + or clear all virtio drives and only first scsi device if + exists + + ``clearpart --list=sda|vd*``""") + return op + +class F28_ClearPart(F25_ClearPart): + def __init__(self, *args, **kwargs): + super(F28_ClearPart, self).__init__(*args, **kwargs) + self.cdl = kwargs.get("cdl", False) + + def __str__(self): + s = super(F28_ClearPart, self).__str__() + if s and self.cdl: + s = s.rstrip() + s += " --cdl\n" + return s + + def _getParser(self): + op = super(F28_ClearPart, self)._getParser() + op.add_argument("--cdl", dest="cdl", default=False, version=F28, + action="store_true", help=""" + Reformat any LDL DASDs to CDL format.""") + return op + +class RHEL7_ClearPart(F28_ClearPart): + pass diff --git a/mic/3rdparty/pykickstart/commands/device.py b/mic/3rdparty/pykickstart/commands/device.py index afed26c..99d80c7 100644 --- a/mic/3rdparty/pykickstart/commands/device.py +++ b/mic/3rdparty/pykickstart/commands/device.py @@ -15,14 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.version import versionToLongString, FC3, F24, F34 +from pykickstart.base import BaseData, DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class F8_DeviceData(BaseData): removedKeywords = BaseData.removedKeywords @@ -34,15 +35,21 @@ class F8_DeviceData(BaseData): self.moduleOpts = kwargs.get("moduleOpts", "") def __eq__(self, y): + if not y: + return False + return self.moduleName == y.moduleName + def __ne__(self, y): + return not self == y + def __str__(self): retval = BaseData.__str__(self) - if self.moduleName != "": + if self.moduleName: retval += "device %s" % self.moduleName - if self.moduleOpts != "": + if self.moduleOpts: retval += " --opts=\"%s\"" % self.moduleOpts return retval + "\n" @@ -60,31 +67,57 @@ class FC3_Device(KickstartCommand): self.moduleOpts = kwargs.get("moduleOpts", "") def __eq__(self, y): + if not y: + return False + return self.moduleName == y.moduleName + def __ne__(self, y): + return not self == y + def __str__(self): retval = KickstartCommand.__str__(self) - if self.moduleName != "": + if self.moduleName: retval += "device %s %s" % (self.type, self.moduleName) - if self.moduleOpts != "": + if self.moduleOpts: retval += " --opts=\"%s\"" % self.moduleOpts return retval + "\n" def _getParser(self): - op = KSOptionParser() - op.add_option("--opts", dest="moduleOpts", default="") + op = KSOptionParser(prog="device", description=""" + On most PCI systems, the installation program will autoprobe for + Ethernet and SCSI cards properly. On older systems and some PCI + systems, however, kickstart needs a hint to find the proper + devices. The device command, which tells the installation program + to install extra modules, is in this format: + + ``device <moduleName> --opts=<options>`` + + ``<moduleName>`` + + Replace with the name of the kernel module which should be + installed.""", version=FC3) + op.add_argument("--opts", dest="moduleOpts", default="", version=FC3, + help=""" + Options to pass to the kernel module. For example: + + ``--opts="aic152x=0x340 io=11"`` + """) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) if len(extra) != 2: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name"))) + raise KickstartParseError(_("device command requires two arguments: module type and name"), lineno=self.lineno) + elif any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "device", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - self.moduleOpts = opts.moduleOpts + self.moduleOpts = ns.moduleOpts self.type = extra[0] self.moduleName = extra[1] return self @@ -105,21 +138,43 @@ class F8_Device(FC3_Device): return retval def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) if len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name"))) + raise KickstartParseError(_("%(command)s command requires a single argument: %(argument)s") % {"command": "device", "argument": "module name"}, lineno=self.lineno) + elif any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "device", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - dd = F8_DeviceData() - self._setToObj(self.op, opts, dd) + dd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, dd) dd.lineno = self.lineno dd.moduleName = extra[0] # Check for duplicates in the data list. if dd in self.dataList(): - warnings.warn(_("A module with the name %s has already been defined.") % dd.moduleName) + warnings.warn(_("A module with the name %s has already been defined.") % dd.moduleName, KickstartParseWarning) return dd def dataList(self): return self.deviceList + + @property + def dataClass(self): + return self.handler.DeviceData + +class F24_Device(DeprecatedCommand, F8_Device): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = F8_Device._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F24) + return op + +class F34_Device(RemovedCommand, F24_Device): + def _getParser(self): + op = F24_Device._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/deviceprobe.py b/mic/3rdparty/pykickstart/commands/deviceprobe.py index 9f462fd..bc6dbf9 100644 --- a/mic/3rdparty/pykickstart/commands/deviceprobe.py +++ b/mic/3rdparty/pykickstart/commands/deviceprobe.py @@ -15,9 +15,12 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * +from pykickstart.version import FC3, F29, F34, versionToLongString +from pykickstart.base import KickstartCommand, DeprecatedCommand, RemovedCommand +from pykickstart.options import KSOptionParser + class FC3_DeviceProbe(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -30,7 +33,7 @@ class FC3_DeviceProbe(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.deviceprobe != "": + if self.deviceprobe: retval += "deviceprobe %s\n" % self.deviceprobe return retval @@ -38,3 +41,23 @@ class FC3_DeviceProbe(KickstartCommand): def parse(self, args): self.deviceprobe = " ".join(args) return self + + def _getParser(self): + return KSOptionParser(prog="deviceprobe", version=FC3, description="probe for devices") + + +class F29_DeviceProbe(DeprecatedCommand, FC3_DeviceProbe): + + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = FC3_DeviceProbe._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F29) + return op + +class F34_DeviceProbe(RemovedCommand, F29_DeviceProbe): + def _getParser(self): + op = F29_DeviceProbe._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/displaymode.py b/mic/3rdparty/pykickstart/commands/displaymode.py index afd58ea..d02aaca 100644 --- a/mic/3rdparty/pykickstart/commands/displaymode.py +++ b/mic/3rdparty/pykickstart/commands/displaymode.py @@ -15,14 +15,16 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.options import * +from pykickstart.version import FC3, F26 +from pykickstart.base import KickstartCommand +from pykickstart.constants import DISPLAY_MODE_CMDLINE, DISPLAY_MODE_GRAPHICAL, \ + DISPLAY_MODE_TEXT +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_DisplayMode(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -30,8 +32,8 @@ class FC3_DisplayMode(KickstartCommand): def __init__(self, writePriority=0, *args, **kwargs): KickstartCommand.__init__(self, writePriority, *args, **kwargs) - self.op = self._getParser() self.displayMode = kwargs.get("displayMode", None) + self.op = self._getParser() def __str__(self): retval = KickstartCommand.__str__(self) @@ -48,15 +50,9 @@ class FC3_DisplayMode(KickstartCommand): return retval - def _getParser(self): - op = KSOptionParser() - return op - def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if len(extra) > 0: - raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % self.currentCmd)) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) if self.currentCmd == "cmdline": self.displayMode = DISPLAY_MODE_CMDLINE @@ -64,5 +60,52 @@ class FC3_DisplayMode(KickstartCommand): self.displayMode = DISPLAY_MODE_GRAPHICAL elif self.currentCmd == "text": self.displayMode = DISPLAY_MODE_TEXT + else: + raise KickstartParseError(_("Unknown command %s") % self.currentCmd, lineno=self.lineno) + + return self + + def _getParser(self): + op = KSOptionParser(prog="graphical|text|cmdline", version=FC3, + description=""" + Controls which display mode will be used during + installation. If ``cmdline`` is chosen all required + installation options must be configured via kickstart + otherwise the installation will fail.""") + return op + +class F26_DisplayMode(FC3_DisplayMode): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + FC3_DisplayMode.__init__(self, writePriority, args, kwargs) + self.nonInteractive = kwargs.get("nonInteractive", False) + + def __str__(self): + retval = super(F26_DisplayMode, self).__str__() + + if self.nonInteractive: + retval = retval.rstrip() + retval += " --non-interactive\n" + + return retval + + def _getParser(self): + op = FC3_DisplayMode._getParser(self) + op.add_argument("--non-interactive", action="store_true", default=False, + dest="nonInteractive", version=F26, help=""" + Perform the installation in a completely non-interactive mode. + This mode will kill the installation when user interaction will be + required. Can't be used with ``cmdline`` mode. This option is + especially useful for automated testing purpose.""") + return op + + def parse(self, args): + FC3_DisplayMode.parse(self, args) + + if self.currentCmd == "cmdline" and self.nonInteractive: + msg = _("Kickstart command cmdline does not support --non-interactive parameter") + raise KickstartParseError(msg, lineno=self.lineno) return self diff --git a/mic/3rdparty/pykickstart/commands/dmraid.py b/mic/3rdparty/pykickstart/commands/dmraid.py index 993575a..b818e03 100644 --- a/mic/3rdparty/pykickstart/commands/dmraid.py +++ b/mic/3rdparty/pykickstart/commands/dmraid.py @@ -16,15 +16,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.errors import KickstartParseWarning +from pykickstart.version import versionToLongString, FC6, F24, F34 +from pykickstart.base import BaseData, DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.options import KSOptionParser -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC6_DmRaidData(BaseData): removedKeywords = BaseData.removedKeywords @@ -38,8 +38,14 @@ class FC6_DmRaidData(BaseData): self.dmset = kwargs.get("dmset", None) def __eq__(self, y): + if not y: + return False + return self.name == y.name and self.devices == y.devices + def __ne__(self, y): + return not self == y + def __str__(self): retval = BaseData.__str__(self) retval += "dmraid --name=%s" % self.name @@ -67,25 +73,43 @@ class FC6_DmRaid(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--name", dest="name", action="store", type="string", - required=1) - op.add_option("--dev", dest="devices", action="append", type="string", - required=1) + op = KSOptionParser(prog="dmraid", description="define a software RAID device", version=FC6) + op.add_argument("--name", required=True, version=FC6, help="Name of dmraid") + op.add_argument("--dev", dest="devices", action="append", + required=True, version=FC6, help="device to add to the dmraid") return op def parse(self, args): - dm = FC6_DmRaidData() - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + dm = self.dataClass() # pylint: disable=not-callable + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_obj(ns, dm) dm.name = dm.name.split('/')[-1] - self._setToObj(self.op, opts, dm) dm.lineno = self.lineno # Check for duplicates in the data list. if dm in self.dataList(): - warnings.warn(_("A DM RAID device with the name %s and devices %s has already been defined.") % (dm.name, dm.devices)) + warnings.warn(_("A DM RAID device with the name %(name)s and devices %(devices)s has already been defined.") % {"name": dm.name, "devices": dm.devices}, KickstartParseWarning) return dm def dataList(self): return self.dmraids + + @property + def dataClass(self): + return self.handler.DmRaidData + +class F24_DmRaid(DeprecatedCommand, FC6_DmRaid): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = FC6_DmRaid._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F24) + return op + +class F34_DmRaid(RemovedCommand, F24_DmRaid): + def _getParser(self): + op = F24_DmRaid._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/driverdisk.py b/mic/3rdparty/pykickstart/commands/driverdisk.py index 43d6259..3d16958 100644 --- a/mic/3rdparty/pykickstart/commands/driverdisk.py +++ b/mic/3rdparty/pykickstart/commands/driverdisk.py @@ -15,19 +15,20 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.version import FC3, FC4, F12, F14 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_DriverDiskData(BaseData): removedKeywords = BaseData.removedKeywords removedAttrs = BaseData.removedAttrs - def __init__(self, writePriority=0, *args, **kwargs): + def __init__(self, *args, **kwargs): BaseData.__init__(self, *args, **kwargs) self.partition = kwargs.get("partition", "") @@ -55,7 +56,7 @@ class FC4_DriverDiskData(FC3_DriverDiskData): removedKeywords = FC3_DriverDiskData.removedKeywords removedAttrs = FC3_DriverDiskData.removedAttrs - def __init__(self, writePriority=0, *args, **kwargs): + def __init__(self, *args, **kwargs): FC3_DriverDiskData.__init__(self, *args, **kwargs) self.deleteRemovedAttrs() @@ -84,7 +85,8 @@ class F12_DriverDiskData(FC4_DriverDiskData): FC4_DriverDiskData.__init__(self, *args, **kwargs) self.deleteRemovedAttrs() -F14_DriverDiskData = F12_DriverDiskData +class F14_DriverDiskData(F12_DriverDiskData): + pass class FC3_DriverDisk(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -104,64 +106,90 @@ class FC3_DriverDisk(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--source") - op.add_option("--type") + op = KSOptionParser(prog="driverdisk", description=""" + Driver diskettes can be used during kickstart + installations. You need to copy the driver disk's + contents to the root directory of a partition on + the system's hard drive. Then you need to use the + driverdisk command to tell the installation program + where to look for the driver disk.""", + version=FC3) + op.add_argument("partition", nargs="*", version=FC3, + help=""" + Partition containing the driver disk. + This can be specified by device name, UUID=, or LABEL= + just like the harddrive command may be.""") + op.add_argument("--source", version=FC3, help=""" + Specify a URL for the driver disk. NFS locations can be + given with ``nfs:host:/path/to/img``.""") + op.add_argument("--type", version=FC3, help="REMOVED") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) - if len(extra) > 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))) + if len(ns.partition) > 1: + raise KickstartParseError(_("Only one partition may be specified for driverdisk command."), lineno=self.lineno) + elif extra: + mapping = {"command": "driverdisk", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - if len(extra) == 1 and opts.source: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))) + if ns.partition and ns.source: + raise KickstartParseError(_("Only one of --source and partition may be specified for driverdisk command."), lineno=self.lineno) - if not extra and not opts.source: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command."))) + if not ns.partition and not ns.source: + raise KickstartParseError(_("One of --source or partition must be specified for driverdisk command."), lineno=self.lineno) - ddd = self.handler.DriverDiskData() - self._setToObj(self.op, opts, ddd) + ddd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, ddd) ddd.lineno = self.lineno - if len(extra) == 1: - ddd.partition = extra[0] + if ns.partition: + ddd.partition = ns.partition[0] return ddd def dataList(self): return self.driverdiskList + @property + def dataClass(self): + return self.handler.DriverDiskData + class FC4_DriverDisk(FC3_DriverDisk): removedKeywords = FC3_DriverDisk.removedKeywords removedAttrs = FC3_DriverDisk.removedKeywords def _getParser(self): op = FC3_DriverDisk._getParser(self) - op.add_option("--biospart") + op.add_argument("--biospart", version=FC4, help=""" + BIOS partition containing the driver disk (such as 82p2). + """) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if len(extra) > 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command."))) - - if len(extra) == 1 and opts.source: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command."))) - elif len(extra) == 1 and opts.biospart: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command."))) - elif opts.source and opts.biospart: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command."))) - - if not extra and not opts.source and not opts.biospart: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command."))) - - ddd = self.handler.DriverDiskData() - self._setToObj(self.op, opts, ddd) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if len(ns.partition) > 1: + raise KickstartParseError(_("Only one partition may be specified for driverdisk command."), lineno=self.lineno) + elif extra: + mapping = {"command": "driverdisk", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + if ns.partition and ns.source: + raise KickstartParseError(_("Only one of --source and partition may be specified for driverdisk command."), lineno=self.lineno) + elif ns.partition and ns.biospart: + raise KickstartParseError(_("Only one of --biospart and partition may be specified for driverdisk command."), lineno=self.lineno) + elif ns.source and ns.biospart: + raise KickstartParseError(_("Only one of --biospart and --source may be specified for driverdisk command."), lineno=self.lineno) + + if not ns.partition and not ns.source and not ns.biospart: + raise KickstartParseError(_("One of --source, --biospart, or partition must be specified for driverdisk command."), lineno=self.lineno) + + ddd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, ddd) ddd.lineno = self.lineno - if len(extra) == 1: - ddd.partition = extra[0] + if ns.partition: + ddd.partition = ns.partition[0] return ddd @@ -171,7 +199,7 @@ class F12_DriverDisk(FC4_DriverDisk): def _getParser(self): op = FC4_DriverDisk._getParser(self) - op.add_option("--type", deprecated=1) + op.add_argument("--type", deprecated=F12) return op class F14_DriverDisk(F12_DriverDisk): @@ -180,5 +208,5 @@ class F14_DriverDisk(F12_DriverDisk): def _getParser(self): op = F12_DriverDisk._getParser(self) - op.remove_option("--type") + op.remove_argument("--type", version=F14) return op diff --git a/mic/3rdparty/pykickstart/commands/eula.py b/mic/3rdparty/pykickstart/commands/eula.py new file mode 100644 index 0000000..421da64 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/eula.py @@ -0,0 +1,70 @@ +# +# Copyright (C) 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Vratislav Podzimek <vpodzime@redhat.com> +# +from pykickstart.version import F20 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ + +class F20_Eula(KickstartCommand): + """The 'eula' kickstart command""" + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + self.agreed = kwargs.get("agreed", False) + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.agreed: + retval += "# License agreement\n" + retval += "eula %s\n" % self._getArgsAsStr() + + return retval + + def _getArgsAsStr(self): + if self.agreed: + return "--agreed" + else: + return "" + + def _getParser(self): + op = KSOptionParser(prog="eula", version=F20, description=""" + Automatically accept Red Hat's EULA""") + # people would struggle remembering the exact word + op.add_argument("--agreed", "--agree", "--accepted", "--accept", + dest="agreed", action="store_true", default=False, + version=F20, help="Accept the EULA. This is mandatory option!") + return op + + def parse(self, args): + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + self.set_to_self(ns) + + if extra: + raise KickstartParseError(_("Kickstart command %s does not take any arguments") % "eula", lineno=self.lineno) + + if not self.agreed: + raise KickstartParseError(_("Kickstart command eula expects the --agreed option"), lineno=self.lineno) + + return self diff --git a/mic/3rdparty/pykickstart/commands/fcoe.py b/mic/3rdparty/pykickstart/commands/fcoe.py index 2f4b492..e4e1fb6 100644 --- a/mic/3rdparty/pykickstart/commands/fcoe.py +++ b/mic/3rdparty/pykickstart/commands/fcoe.py @@ -15,14 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.version import F12, F13, F28, RHEL7 +from pykickstart.errors import KickstartParseWarning +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.options import KSOptionParser -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class F12_FcoeData(BaseData): removedKeywords = BaseData.removedKeywords @@ -33,8 +34,14 @@ class F12_FcoeData(BaseData): self.nic = kwargs.get("nic", None) def __eq__(self, y): + if not y: + return False + return self.nic == y.nic + def __ne__(self, y): + return not self == y + def _getArgsAsStr(self): retval = "" @@ -64,6 +71,44 @@ class F13_FcoeData(F12_FcoeData): return retval +class RHEL7_FcoeData(F13_FcoeData): + removedKeywords = F13_FcoeData.removedKeywords + removedAttrs = F13_FcoeData.removedAttrs + + def __init__(self, *args, **kwargs): + F13_FcoeData.__init__(self, *args, **kwargs) + self.autovlan = kwargs.get("autovlan", False) + + def _getArgsAsStr(self): + retval = F13_FcoeData._getArgsAsStr(self) + + if self.autovlan: + retval += " --autovlan" + + return retval + +class F28_FcoeData(F13_FcoeData): + removedKeywords = F13_FcoeData.removedKeywords + removedAttrs = F13_FcoeData.removedAttrs + + def __init__(self, *args, **kwargs): + F13_FcoeData.__init__(self, *args, **kwargs) + self.autovlan = kwargs.get("autovlan", False) + + def _getArgsAsStr(self): + retval = F13_FcoeData._getArgsAsStr(self) + + if self.autovlan: + retval += " --autovlan" + + return retval + +class RHEL8_FcoeData(F28_FcoeData): + pass + +class RHEL9_FcoeData(F28_FcoeData): + pass + class F12_Fcoe(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -81,34 +126,75 @@ class F12_Fcoe(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--nic", dest="nic", required=1) + op = KSOptionParser(prog="fcoe", description=""" + Discover and attach FCoE storage devices accessible via + specified network interface + """, version=F12) + op.add_argument("--nic", required=True, version=F12, help=""" + Name of the network device connected to the FCoE switch""") return op def parse(self, args): - zd = self.handler.FcoeData() - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) > 0: - mapping = {"command": "fcoe", "options": extra} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) + zd = self.dataClass() # pylint: disable=not-callable + ns = self.op.parse_args(args=args, lineno=self.lineno) - self._setToObj(self.op, opts, zd) + self.set_to_obj(ns, zd) zd.lineno = self.lineno # Check for duplicates in the data list. if zd in self.dataList(): - warnings.warn(_("A FCOE device with the name %s has already been defined.") % zd.nic) + warnings.warn(_("A FCOE device with the name %s has already been defined.") % zd.nic, KickstartParseWarning) return zd def dataList(self): return self.fcoe + @property + def dataClass(self): + return self.handler.FcoeData + class F13_Fcoe(F12_Fcoe): removedKeywords = F12_Fcoe.removedKeywords removedAttrs = F12_Fcoe.removedAttrs def _getParser(self): op = F12_Fcoe._getParser(self) - op.add_option("--dcb", dest="dcb", action="store_true", default=False) + op.add_argument("--dcb", action="store_true", default=False, version=F13, help=""" + Enable Data Center Bridging awareness in installer. This option + should only be enabled for network interfaces that + require a host-based DCBX client. Configurations on + interfaces that implement a hardware DCBX client should + not use it. + """) return op + +class RHEL7_Fcoe(F13_Fcoe): + removedKeywords = F13_Fcoe.removedKeywords + removedAttrs = F13_Fcoe.removedAttrs + + def _getParser(self): + op = F13_Fcoe._getParser(self) + op.add_argument("--autovlan", action="store_true", default=False, version=RHEL7, help=""" + Perform automatic VLAN discovery and setup. This option is enabled + by default. + """) + return op + +class F28_Fcoe(F13_Fcoe): + removedKeywords = F13_Fcoe.removedKeywords + removedAttrs = F13_Fcoe.removedAttrs + + def _getParser(self): + op = F13_Fcoe._getParser(self) + op.add_argument("--autovlan", action="store_true", default=False, version=F28, help=""" + Perform automatic VLAN discovery and setup. This option is enabled + by default. + """) + return op + +class RHEL8_Fcoe(F28_Fcoe): + pass + +class RHEL9_Fcoe(F28_Fcoe): + pass diff --git a/mic/3rdparty/pykickstart/commands/firewall.py b/mic/3rdparty/pykickstart/commands/firewall.py index 1d21759..727ad21 100644 --- a/mic/3rdparty/pykickstart/commands/firewall.py +++ b/mic/3rdparty/pykickstart/commands/firewall.py @@ -15,14 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC3, F9, F10, F14, F20, F28 +from pykickstart.base import KickstartCommand +from pykickstart.options import ExtendAction, ExtendConstAction, KSOptionParser, commaSplit class FC3_Firewall(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -50,30 +47,28 @@ class FC3_Firewall(KickstartCommand): # port:proto (s-c-kickstart may do this). So, filter those # out into their own list leaving what we expect. for port in self.ports: - if port == "ssh": + if port == "ssh:tcp": extra.append(" --ssh") - elif port == "telnet": + elif port == "telnet:tcp": extra.append(" --telnet") - elif port == "smtp": + elif port == "smtp:tcp": extra.append(" --smtp") - elif port == "http": + elif port == "http:tcp": extra.append(" --http") - elif port == "ftp": + elif port == "ftp:tcp": extra.append(" --ftp") else: filteredPorts.append(port) # All the port:proto strings go into a comma-separated list. portstr = ",".join(filteredPorts) - if len(portstr) > 0: + if portstr: portstr = " --port=" + portstr - else: - portstr = "" extrastr = "".join(extra) truststr = ",".join(self.trusts) - if len(truststr) > 0: + if truststr: truststr = " --trust=" + truststr # The output port list consists only of port:proto for @@ -86,38 +81,68 @@ class FC3_Firewall(KickstartCommand): return retval def _getParser(self): - def firewall_port_cb (option, opt_str, value, parser): + def firewall_port_cb(value): + retval = [] for p in value.split(","): p = p.strip() if p.find(":") == -1: p = "%s:tcp" % p - parser.values.ensure_value(option.dest, []).append(p) - - op = KSOptionParser(mapping={"ssh":["22:tcp"], "telnet":["23:tcp"], - "smtp":["25:tcp"], "http":["80:tcp", "443:tcp"], - "ftp":["21:tcp"]}) - - op.add_option("--disable", "--disabled", dest="enabled", - action="store_false") - op.add_option("--enable", "--enabled", dest="enabled", - action="store_true", default=True) - op.add_option("--ftp", "--http", "--smtp", "--ssh", "--telnet", - dest="ports", action="map_extend") - op.add_option("--high", deprecated=1) - op.add_option("--medium", deprecated=1) - op.add_option("--port", dest="ports", action="callback", - callback=firewall_port_cb, nargs=1, type="string") - op.add_option("--trust", dest="trusts", action="append") - return op - def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + retval.append(p) - if len(extra) != 0: - mapping = {"command": "firewall", "options": extra} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) + return retval - self._setToSelf(self.op, opts) + op = KSOptionParser(prog="firewall", description=""" + This option corresponds to the Firewall Configuration + screen in the installation program""", + version=FC3) + op.add_argument("--disable", "--disabled", dest="enabled", + action="store_false", version=FC3, + help="Do not configure any iptables rules.") + op.add_argument("--enable", "--enabled", dest="enabled", + action="store_true", default=True, help=""" + Reject incoming connections that are not in response + to outbound requests, such as DNS replies or DHCP + requests. If access to services running on this machine + is needed, you can choose to allow specific services + through the firewall.""", version=FC3) + op.add_argument("--ftp", dest="ports", action="append_const", + const="21:tcp", version=FC3, + help="Open port 21:tcp") + op.add_argument("--http", dest="ports", action=ExtendConstAction, + const=["80:tcp", "443:tcp"], nargs=0, version=FC3, + help="Open ports 80:tcp and 443:tcp") + op.add_argument("--smtp", dest="ports", action="append_const", + const="25:tcp", version=FC3, + help="Open port 25:tcp") + op.add_argument("--ssh", dest="ports", action="append_const", + const="22:tcp", version=FC3, + help="Open port 22:tcp") + op.add_argument("--telnet", dest="ports", action="append_const", + const="23:tcp", version=FC3, + help="Open port 23:tcp") + op.add_argument("--high", deprecated=FC3, help="") + op.add_argument("--medium", deprecated=FC3, help="") + op.add_argument("--port", dest="ports", action=ExtendAction, + type=firewall_port_cb, help=""" + You can specify that ports be allowed through the firewall + using the port:protocol format. You can also specify ports + numerically. Multiple ports can be combined into one option + as long as they are separated by commas. For example:: + + ``firewall --port=imap:tcp,1234:ucp,47``""", + version=FC3) + op.add_argument("--trust", dest="trusts", action="append", help=""" + Listing a device here, such as eth0, allows all traffic + coming from that device to go through the firewall. To + list more than one device, use --trust eth0 --trust eth1. + Do NOT use a comma-separated format such as + --trust eth0, eth1.""", version=FC3) + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self class F9_Firewall(FC3_Firewall): @@ -126,8 +151,8 @@ class F9_Firewall(FC3_Firewall): def _getParser(self): op = FC3_Firewall._getParser(self) - op.remove_option("--high") - op.remove_option("--medium") + op.remove_argument("--high", version=F9) + op.remove_argument("--medium", version=F9) return op class F10_Firewall(F9_Firewall): @@ -147,40 +172,41 @@ class F10_Firewall(F9_Firewall): retval = retval.strip() svcstr = ",".join(self.services) - if len(svcstr) > 0: + if svcstr: svcstr = " --service=" + svcstr - else: - svcstr = "" return retval + "%s\n" % svcstr else: return retval def _getParser(self): - def service_cb (option, opt_str, value, parser): - # python2.4 does not support action="append_const" that we were - # using for these options. Instead, we have to fake it by - # appending whatever the option string is to the service list. - if not value: - parser.values.ensure_value(option.dest, []).append(opt_str[2:]) - return - - for p in value.split(","): - p = p.strip() - parser.values.ensure_value(option.dest, []).append(p) - op = F9_Firewall._getParser(self) - op.add_option("--service", dest="services", action="callback", - callback=service_cb, nargs=1, type="string") - op.add_option("--ftp", dest="services", action="callback", - callback=service_cb) - op.add_option("--http", dest="services", action="callback", - callback=service_cb) - op.add_option("--smtp", dest="services", action="callback", - callback=service_cb) - op.add_option("--ssh", dest="services", action="callback", - callback=service_cb) - op.add_option("--telnet", deprecated=1) + op.add_argument("--service", dest="services", action=ExtendAction, + type=commaSplit, help=""" + This option provides a higher-level way to allow services + through the firewall. Some services (like cups, avahi, etc.) + require multiple ports to be open or other special + configuration in order for the service to work. You could + specify each individual service with the ``--port`` option, + or specify ``--service=`` and open them all at once. + + Valid options are anything recognized by the + firewall-cmd program in the firewalld package. + If firewalld is running:: + + ``firewall-cmd --get-services`` + + will provide a list of known service names.""", + version=F10) + op.add_argument("--ftp", dest="services", action="append_const", + const="ftp", version=F10, help="Open the ftp service port") + op.add_argument("--http", dest="services", action="append_const", + const="http", version=F10, help="Open the http service port") + op.add_argument("--smtp", dest="services", action="append_const", + const="smtp", version=F10, help="Open the smtp service port") + op.add_argument("--ssh", dest="services", action="append_const", + const="ssh", version=F10, help="Open the ssh service port") + op.add_argument("--telnet", deprecated=F10) return op class F14_Firewall(F10_Firewall): @@ -189,5 +215,55 @@ class F14_Firewall(F10_Firewall): def _getParser(self): op = F10_Firewall._getParser(self) - op.remove_option("--telnet") + op.remove_argument("--telnet", version=F14) + return op + +class F20_Firewall(F14_Firewall): + def __init__(self, writePriority=0, *args, **kwargs): + F14_Firewall.__init__(self, writePriority, *args, **kwargs) + self.remove_services = kwargs.get("remove_services", []) + + def _getParser(self): + op = F14_Firewall._getParser(self) + op.add_argument("--remove-service", dest="remove_services", + help="Close ports for the comma-separated list of services", + action=ExtendAction, type=commaSplit, version=F20) + return op + + def __str__(self): + if self.enabled is None: + return "" + + retval = F14_Firewall.__str__(self) + if self.enabled: + retval = retval.strip() + + svcstr = ",".join(self.remove_services) + if svcstr: + svcstr = " --remove-service=" + svcstr + + return retval + "%s\n" % svcstr + else: + return retval + +class F28_Firewall(F20_Firewall): + def __init__(self, writePriority=0, *args, **kwargs): + F20_Firewall.__init__(self, writePriority, *args, **kwargs) + self.use_system_defaults = kwargs.get("use_system_defaults", None) + + def _getParser(self): + op = F20_Firewall._getParser(self) + op.add_argument("--use-system-defaults", dest="use_system_defaults", + action="store_true", default=False, version=F28, help=""" + Don't configure the firewall at all. This instructs anaconda + to do nothing and allows the system to rely on the defaults + that were provided with the package or ostree. If this option + is used with other options then all other options will be + ignored.""") return op + + def __str__(self): + if self.use_system_defaults: + return "# Firewall configuration\nfirewall --use-system-defaults\n" + else: + return F20_Firewall.__str__(self) diff --git a/mic/3rdparty/pykickstart/commands/firstboot.py b/mic/3rdparty/pykickstart/commands/firstboot.py index 05c0ac1..e0f2b69 100644 --- a/mic/3rdparty/pykickstart/commands/firstboot.py +++ b/mic/3rdparty/pykickstart/commands/firstboot.py @@ -15,11 +15,12 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.options import * +from pykickstart.version import FC3 +from pykickstart.base import KickstartCommand +from pykickstart.constants import FIRSTBOOT_DEFAULT, FIRSTBOOT_SKIP, FIRSTBOOT_RECONFIG +from pykickstart.options import KSOptionParser class FC3_Firstboot(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -47,16 +48,32 @@ class FC3_Firstboot(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--disable", "--disabled", dest="firstboot", - action="store_const", const=FIRSTBOOT_SKIP) - op.add_option("--enable", "--enabled", dest="firstboot", - action="store_const", const=FIRSTBOOT_DEFAULT) - op.add_option("--reconfig", dest="firstboot", action="store_const", - const=FIRSTBOOT_RECONFIG) + op = KSOptionParser(prog="firstboot", description=""" + Determine whether the Setup Agent starts the first + time the system is booted. If enabled, the + ``initial-setup`` package must be installed. If not + specified, the setup agent (initial-setup) is disabled + by default.""", + version=FC3) + op.add_argument("--disable", "--disabled", dest="firstboot", + action="store_const", const=FIRSTBOOT_SKIP, version=FC3, + help="""The Setup Agent is not started the first time the + system boots.""") + op.add_argument("--enable", "--enabled", dest="firstboot", + action="store_const", const=FIRSTBOOT_DEFAULT, version=FC3, + help="""The Setup Agent is started the first time the + system boots.""") + op.add_argument("--reconfig", dest="firstboot", version=FC3, + action="store_const", const=FIRSTBOOT_RECONFIG, + help=""" + Enable the Setup Agent to start at boot time in + reconfiguration mode. This mode enables the language, + mouse, keyboard, root password, security level, + time zone, and networking configuration options in + addition to the default ones.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self.firstboot = opts.firstboot + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.firstboot = ns.firstboot return self diff --git a/mic/3rdparty/pykickstart/commands/group.py b/mic/3rdparty/pykickstart/commands/group.py index 80ba5bd..fab5e74 100644 --- a/mic/3rdparty/pykickstart/commands/group.py +++ b/mic/3rdparty/pykickstart/commands/group.py @@ -15,16 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.errors import KickstartParseWarning +from pykickstart.version import F12 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.options import KSOptionParser -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class F12_GroupData(BaseData): removedKeywords = BaseData.removedKeywords @@ -36,8 +35,14 @@ class F12_GroupData(BaseData): self.gid = kwargs.get("gid", None) def __eq__(self, y): + if not y: + return False + return self.name == y.name + def __ne__(self, y): + return not self == y + def __str__(self): retval = BaseData.__str__(self) retval += "group" @@ -67,22 +72,33 @@ class F12_Group(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--name", required=1) - op.add_option("--gid", type="int") + op = KSOptionParser(prog="group", description=""" + Creates a new user group on the system. If a group with the given + name or GID already exists, this command will fail. In addition, + the ``user`` command can be used to create a new group for the + newly created user.""", version=F12) + op.add_argument("--name", required=True, version=F12, + help="Provides the name of the new group.") + op.add_argument("--gid", type=int, version=F12, help=""" + The group's GID. If not provided, this defaults to the + next available non-system GID.""") return op def parse(self, args): - gd = self.handler.GroupData() - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToObj(self.op, opts, gd) + gd = self.dataClass() # pylint: disable=not-callable + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_obj(ns, gd) gd.lineno = self.lineno # Check for duplicates in the data list. if gd in self.dataList(): - warnings.warn(_("A group with the name %s has already been defined.") % gd.name) + warnings.warn(_("A group with the name %s has already been defined.") % gd.name, KickstartParseWarning) return gd def dataList(self): return self.groupList + + @property + def dataClass(self): + return self.handler.GroupData diff --git a/mic/3rdparty/pykickstart/commands/harddrive.py b/mic/3rdparty/pykickstart/commands/harddrive.py new file mode 100644 index 0000000..c667993 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/harddrive.py @@ -0,0 +1,129 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2007, 2009, 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import FC3, F33 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ + +class FC3_HardDrive(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.biospart = kwargs.get("biospart", None) + self.partition = kwargs.get("partition", None) + self.dir = kwargs.get("dir", None) + + self.op = self._getParser() + + self.deleteRemovedAttrs() + + def __eq__(self, other): + if not other: + return False + + return self.biospart == other.biospart and self.partition == other.partition and self.dir == other.dir + + def __ne__(self, other): + return not self == other + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use hard drive installation media\n" + + if self.biospart is not None: + retval += "harddrive --dir=%s --biospart=%s\n" % (self.dir, self.biospart) + else: + retval += "harddrive --dir=%s --partition=%s\n" % (self.dir, self.partition) + + return retval + + def _getParser(self): + op = KSOptionParser(prog="harddrive", description=""" + Install from a directory of ISO images on a local drive, which must + be either vfat or ext2. In addition to this directory, you must also + provide the install.img in some way. You can either do this by + booting off the boot.iso or by creating an images/ directory in the + same directory as the ISO images and placing install.img in there. + """, version=FC3) + op.add_argument("--biospart", version=FC3, + help="BIOS partition to install from (such as 82p2).") + op.add_argument("--partition", version=FC3, + help="Partition to install from (such as, sdb2).") + op.add_argument("--dir", required=True, version=FC3, help=""" + Directory containing both the ISO images and the + images/install.img. For example:: + + ``harddrive --partition=hdb2 --dir=/tmp/install-tree`` + """) + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + + if self.biospart is None and self.partition is None or \ + self.biospart is not None and self.partition is not None: + raise KickstartParseError(_("One of biospart or partition options must be specified."), lineno=self.lineno) + + return self + + +class F33_HardDrive(FC3_HardDrive): + removedKeywords = KickstartCommand.removedKeywords + ["biospart"] + removedAttrs = KickstartCommand.removedAttrs + ["biospart"] + + def __init__(self, writePriority=0, *args, **kwargs): + FC3_HardDrive.__init__(self, writePriority, *args, **kwargs) + + def __eq__(self, other): + if not other: + return False + + return self.partition == other.partition and self.dir == other.dir + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use hard drive installation media\n" + retval += "harddrive --dir=%s --partition=%s\n" % (self.dir, self.partition) + + return retval + + def _getParser(self): + op = FC3_HardDrive._getParser(self) + op.remove_argument("--biospart", version=F33) + op.add_argument("--partition", required=True, version=F33, + help="Partition to install from (such as, sdb2).") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + + return self diff --git a/mic/3rdparty/pykickstart/commands/hmc.py b/mic/3rdparty/pykickstart/commands/hmc.py new file mode 100644 index 0000000..92ad3d6 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/hmc.py @@ -0,0 +1,52 @@ +# +# Vendula Poncova <vponcova@redhat.com> +# +# Copyright 2017 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser +from pykickstart.version import RHEL7 +from pykickstart.i18n import _ + + +class RHEL7_Hmc(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use installation media via SE/HMC\nhmc\n" + return retval + + def _getParser(self): + return KSOptionParser(prog="hmc", description=""" + Install from an installation medium via SE/HMC on + z Systems.""", version=RHEL7) + + def parse(self, args): + if args: + msg = _("Kickstart command %s does not take any arguments") % self.currentCmd + raise KickstartParseError(msg, lineno=self.lineno) + + return self + +class F28_Hmc(RHEL7_Hmc): + pass diff --git a/mic/3rdparty/pykickstart/commands/ignoredisk.py b/mic/3rdparty/pykickstart/commands/ignoredisk.py index 48f281d..9545abc 100644 --- a/mic/3rdparty/pykickstart/commands/ignoredisk.py +++ b/mic/3rdparty/pykickstart/commands/ignoredisk.py @@ -15,13 +15,13 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC3, F8, RHEL6, F25, F29, F34 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.i18n import _ +from pykickstart.options import KSOptionParser, commaSplit class FC3_IgnoreDisk(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -36,24 +36,25 @@ class FC3_IgnoreDisk(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if len(self.ignoredisk) > 0: + if self.ignoredisk: retval += "ignoredisk --drives=%s\n" % ",".join(self.ignoredisk) return retval def _getParser(self): - def drive_cb (option, opt_str, value, parser): - for d in value.split(','): - parser.values.ensure_value(option.dest, []).append(d) - - op = KSOptionParser() - op.add_option("--drives", dest="ignoredisk", action="callback", - callback=drive_cb, nargs=1, type="string", required=1) + op = KSOptionParser(prog="ignoredisk", description=""" + Controls anaconda's access to disks attached to the system. By + default, all disks will be available for partitioning. Only one of + the following three options may be used.""", version=FC3) + op.add_argument("--drives", dest="ignoredisk", type=commaSplit, + required=True, version=FC3, help=""" + Specifies those disks that anaconda should not touch + when partitioning, formatting, and clearing.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self class F8_IgnoreDisk(FC3_IgnoreDisk): @@ -68,32 +69,36 @@ class F8_IgnoreDisk(FC3_IgnoreDisk): def __str__(self): retval = KickstartCommand.__str__(self) - if len(self.ignoredisk) > 0: + if self.ignoredisk: retval += "ignoredisk --drives=%s\n" % ",".join(self.ignoredisk) - elif len(self.onlyuse) > 0: + elif self.onlyuse: retval += "ignoredisk --only-use=%s\n" % ",".join(self.onlyuse) return retval - def parse(self, args, errorCheck=True): + def parse(self, args): retval = FC3_IgnoreDisk.parse(self, args) - if errorCheck: - if (len(self.ignoredisk) == 0 and len(self.onlyuse) == 0) or (len(self.ignoredisk) > 0 and (len(self.onlyuse) > 0)): - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --drives or --only-use must be specified for ignoredisk command."))) + howmany = 0 + if self.ignoredisk: + howmany += 1 + if self.onlyuse: + howmany += 1 + if howmany != 1: + raise KickstartParseError(_("One of --drives or --only-use must be specified " + "for ignoredisk command."), lineno=self.lineno) return retval def _getParser(self): - def drive_cb (option, opt_str, value, parser): - for d in value.split(','): - parser.values.ensure_value(option.dest, []).append(d) - op = FC3_IgnoreDisk._getParser(self) - op.add_option("--drives", dest="ignoredisk", action="callback", - callback=drive_cb, nargs=1, type="string") - op.add_option("--only-use", dest="onlyuse", action="callback", - callback=drive_cb, nargs=1, type="string") + op.add_argument("--drives", dest="ignoredisk", version=F8, + type=commaSplit, help=""" + This argument is no longer required!""") + op.add_argument("--only-use", dest="onlyuse", + type=commaSplit, version=F8, help=""" + Specifies the opposite - only disks listed here will be + used during installation.""") return op class RHEL6_IgnoreDisk(F8_IgnoreDisk): @@ -102,10 +107,7 @@ class RHEL6_IgnoreDisk(F8_IgnoreDisk): def __init__(self, writePriority=0, *args, **kwargs): F8_IgnoreDisk.__init__(self, writePriority, *args, **kwargs) - self.interactive = kwargs.get("interactive", False) - if self.interactive: - self.ignoredisk = [] def __str__(self): retval = F8_IgnoreDisk.__str__(self) @@ -116,24 +118,95 @@ class RHEL6_IgnoreDisk(F8_IgnoreDisk): return retval def parse(self, args): - retval = F8_IgnoreDisk.parse(self, args, errorCheck=False) + retval = FC3_IgnoreDisk.parse(self, args) howmany = 0 - if len(self.ignoredisk) > 0: + if self.ignoredisk: howmany += 1 - if len(self.onlyuse) > 0: + if self.onlyuse: howmany += 1 if self.interactive: howmany += 1 if howmany != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command."))) + raise KickstartParseError(_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command."), lineno=self.lineno) + + if self.interactive: + self.ignoredisk = [] return retval def _getParser(self): op = F8_IgnoreDisk._getParser(self) - op.add_option("--interactive", dest="interactive", action="store_true", - default=False) + op.add_argument("--interactive", action="store_true", + default=False, version=RHEL6, help=""" + Allow the user manually navigate the advanced storage + screen.""") + return op + +class F14_IgnoreDisk(RHEL6_IgnoreDisk): + pass + +class F25_IgnoreDisk(F14_IgnoreDisk): + removedKeywords = F14_IgnoreDisk.removedKeywords + removedAttrs = F14_IgnoreDisk.removedAttrs + + def _getParser(self): + op = F14_IgnoreDisk._getParser(self) + op.add_argument("--drives", dest="ignoredisk", version=F25, + type=commaSplit, help=""" + The following ignores the partitions on the first + two drives on the system: + + ``ignoredisk --drives=sda,sdb`` + + or ignores as many drives as it could and skip the missing + (at least one must be matched): + + ``ignoredisk --drives=sda|sdb1`` + + or ignores all virtio drives and only first scsi device if + exists + + ``ignoredisk --drives=sda|vd*``""") + op.add_argument("--only-use", dest="onlyuse", + type=commaSplit, version=F25, help=""" + The following ignores the partitions on the first + two drives on the system: + + ``ignoredisk --only-use=sda,sdb`` + + or ignores as many drives as it could and skip the missing + (at least one must be matched): + + ``ignoredisk --only-use=sda|sdb1`` + + or ignores all virtio drives and only first scsi device if + exists + + ``ignoredisk --only-use=sda|vd*``""") return op -F14_IgnoreDisk = RHEL6_IgnoreDisk + +class F29_IgnoreDisk(F25_IgnoreDisk): + removedKeywords = F25_IgnoreDisk.removedKeywords + removedAttrs = F25_IgnoreDisk.removedAttrs + + def parse(self, args): + return F8_IgnoreDisk.parse(self, args) + + def _getParser(self): + op = F25_IgnoreDisk._getParser(self) + op.add_argument("--interactive", action="store_true", + default=False, deprecated=F29, help=""" + Allow the user manually navigate the advanced storage + screen.""") + return op + +class F34_IgnoreDisk(F29_IgnoreDisk): + removedKeywords = F29_IgnoreDisk.removedKeywords + removedAttrs = F29_IgnoreDisk.removedAttrs + + def _getParser(self): + op = F29_IgnoreDisk._getParser(self) + op.remove_argument("--interactive", version=F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/install.py b/mic/3rdparty/pykickstart/commands/install.py new file mode 100644 index 0000000..96c34b9 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/install.py @@ -0,0 +1,73 @@ +# +# Alexander Todorov <atodorov@redhat.com> +# +# Copyright 2016 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.base import DeprecatedCommand, RemovedCommand +from pykickstart.version import F20, F29, F34, versionToLongString +from pykickstart.commands.upgrade import F11_Upgrade + + +class F20_Install(F11_Upgrade): + """ + The upgrade command has been deprecated in Fedora 20. This + class should be used for any further updates to the install + command. This separation is required because there's no + clean way of deprecating only half of the behavior of some + command class and still have the handlers map to the latest + possible version of this class! + """ + def _getParser(self): + op = super(F20_Install, self)._getParser() + op.prog = "install" + op.description = """ + Install a fresh system. You must specify the type of + installation from one of cdrom, harddrive, nfs, or url + (for ftp or http installations). + The install command and the installation method command + must be on separate lines. + + Important: before Fedora 20 this command was known as + install or upgrade but the upgrade part was deprecated! + """ + op.version = F20 + + return op + + def parse(self, args): + super(F20_Install, self).parse(args) + # since F20 we always return False for upgrades + self.upgrade = False + + return self + + +class F29_Install(DeprecatedCommand, F20_Install): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = F20_Install._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F29) + return op + + +class F34_Install(RemovedCommand, F29_Install): + def _getParser(self): + op = F29_Install._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/interactive.py b/mic/3rdparty/pykickstart/commands/interactive.py index b4e286b..fe98c4a 100644 --- a/mic/3rdparty/pykickstart/commands/interactive.py +++ b/mic/3rdparty/pykickstart/commands/interactive.py @@ -15,14 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import versionToLongString, FC3, F14, F15 +from pykickstart.base import DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.options import KSOptionParser class FC3_Interactive(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -42,17 +39,26 @@ class FC3_Interactive(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="interactive", description=""" + Use interactive kickstart installation method.""", version=FC3) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) > 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "interactive")) - + self.op.parse_args(args=args, lineno=self.lineno) self.interactive = True return self -class F14_Interactive(DeprecatedCommand): - def __init__(self): +class F14_Interactive(DeprecatedCommand, FC3_Interactive): + def __init__(self): # pylint: disable=super-init-not-called DeprecatedCommand.__init__(self) + + def _getParser(self): + op = FC3_Interactive._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F14) + return op + +class F15_Interactive(RemovedCommand, F14_Interactive): + def _getParser(self): + op = F14_Interactive._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F15) + return op diff --git a/mic/3rdparty/pykickstart/commands/iscsi.py b/mic/3rdparty/pykickstart/commands/iscsi.py index 9c25111..b71e4b8 100644 --- a/mic/3rdparty/pykickstart/commands/iscsi.py +++ b/mic/3rdparty/pykickstart/commands/iscsi.py @@ -18,12 +18,9 @@ # subject to the GNU General Public License and may only be used or replicated # with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC6, F10, RHEL6, F17, versionToLongString +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.options import KSOptionParser class FC6_IscsiData(BaseData): removedKeywords = BaseData.removedKeywords @@ -32,7 +29,7 @@ class FC6_IscsiData(BaseData): def __init__(self, *args, **kwargs): BaseData.__init__(self, *args, **kwargs) self.ipaddr = kwargs.get("ipaddr", "") - self.port = kwargs.get("port", "3260") + self.port = kwargs.get("port", 3260) self.target = kwargs.get("target", "") self.user = kwargs.get("user", None) self.password = kwargs.get("password", None) @@ -40,15 +37,15 @@ class FC6_IscsiData(BaseData): def _getArgsAsStr(self): retval = "" - if self.target != "": + if self.target: retval += " --target=%s" % self.target - if self.ipaddr != "": + if self.ipaddr: retval += " --ipaddr=%s" % self.ipaddr - if self.port != "3260": + if self.port != 3260: retval += " --port=%s" % self.port - if self.user is not None: + if self.user: retval += " --user=%s" % self.user - if self.password is not None: + if self.password: retval += " --password=%s" % self.password return retval @@ -70,13 +67,32 @@ class F10_IscsiData(FC6_IscsiData): def _getArgsAsStr(self): retval = FC6_IscsiData._getArgsAsStr(self) - if self.user_in is not None: + if self.user_in: retval += " --reverse-user=%s" % self.user_in - if self.password_in is not None: + if self.password_in: retval += " --reverse-password=%s" % self.password_in return retval +class RHEL6_IscsiData(F10_IscsiData): + removedKeywords = F10_IscsiData.removedKeywords + removedAttrs = F10_IscsiData.removedAttrs + + def __init__(self, *args, **kwargs): + F10_IscsiData.__init__(self, *args, **kwargs) + self.iface = kwargs.get("iface", None) + + def _getArgsAsStr(self): + retval = F10_IscsiData._getArgsAsStr(self) + + if self.iface: + retval += " --iface=%s" % self.iface + + return retval + +class F17_IscsiData(RHEL6_IscsiData): + pass + class FC6_Iscsi(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -95,39 +111,94 @@ class FC6_Iscsi(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--target", dest="target", action="store", type="string") - op.add_option("--ipaddr", dest="ipaddr", action="store", type="string", - required=1) - op.add_option("--port", dest="port", action="store", type="string") - op.add_option("--user", dest="user", action="store", type="string") - op.add_option("--password", dest="password", action="store", - type="string") + op = KSOptionParser(prog="iscsi", description=""" + Specifies additional iSCSI storage to be attached + during installation. If you use the iscsi parameter, + you must also assign a name to the iSCSI node, using + the iscsiname parameter. The iscsiname parameter + must appear before the iscsi parameter in the + kickstart file. + + We recommend that wherever possible you configure + iSCSI storage in the system BIOS or firmware (iBFT + for Intel systems) rather than use the iscsi + parameter. Anaconda automatically detects and uses + disks configured in BIOS or firmware and no special + configuration is necessary in the kickstart file. + + If you must use the iscsi parameter, ensure that + networking is activated at the beginning of the + installation, and that the iscsi parameter appears + in the kickstart file before you refer to iSCSI + disks with parameters such as clearpart or + ignoredisk.""", + version=FC6) + op.add_argument("--target", help="The target iqn.", version=FC6) + op.add_argument("--ipaddr", required=True, version=FC6, help=""" + The IP address of the target to connect to.""") + op.add_argument("--port", version=FC6, type=int, help=""" + The port number to connect to (default, --port=3260). + """) + op.add_argument("--user", version=FC6, help=""" + The username required to authenticate with the target. + """) + op.add_argument("--password", version=FC6, help=""" + The password that corresponds with the username specified + for the target.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if len(extra) != 0: - mapping = {"command": "iscsi", "options": extra} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) - - dd = self.handler.IscsiData() - self._setToObj(self.op, opts, dd) + ns = self.op.parse_args(args=args, lineno=self.lineno) + dd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, dd) dd.lineno = self.lineno return dd def dataList(self): return self.iscsi + @property + def dataClass(self): + return self.handler.IscsiData + class F10_Iscsi(FC6_Iscsi): removedKeywords = FC6_Iscsi.removedKeywords removedAttrs = FC6_Iscsi.removedAttrs def _getParser(self): op = FC6_Iscsi._getParser(self) - op.add_option("--reverse-user", dest="user_in", action="store", - type="string") - op.add_option("--reverse-password", dest="password_in", action="store", - type="string") + op.add_argument("--reverse-user", dest="user_in", version=F10, help=""" + The username required to authenticate with the initiator + from a target that uses reverse CHAP authentication.""") + op.add_argument("--reverse-password", dest="password_in", + version=F10, help=""" + The password that corresponds with the username + specified for the initiator.""") + return op + +class RHEL6_Iscsi(F10_Iscsi): + removedKeywords = F10_Iscsi.removedKeywords + removedAttrs = F10_Iscsi.removedAttrs + + def _getParser(self): + op = F10_Iscsi._getParser(self) + op.add_argument("--iface", version=RHEL6, help=""" + Bind connection to specific network interface instead + of using the default one determined by network layer. + Once used, it must be specified for all iscsi commands. + """) + return op + +class F17_Iscsi(RHEL6_Iscsi): + def _getParser(self): + op = super(F17_Iscsi, self)._getParser() + for action in op._actions: + # mark the fact that --iface is available since F17 + # while RHEL6 is based on F12 + if '--iface' in action.option_strings: + action.help = action.help.replace( + versionToLongString(RHEL6), + versionToLongString(F17) + ) + return op diff --git a/mic/3rdparty/pykickstart/commands/iscsiname.py b/mic/3rdparty/pykickstart/commands/iscsiname.py index ccfbe5f..1e393ae 100644 --- a/mic/3rdparty/pykickstart/commands/iscsiname.py +++ b/mic/3rdparty/pykickstart/commands/iscsiname.py @@ -16,14 +16,14 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC6 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC6_IscsiName(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -37,18 +37,28 @@ class FC6_IscsiName(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.iscsiname != "": + if self.iscsiname: retval += "iscsiname %s\n" % self.iscsiname return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="iscsiname", description=""" + Assigns an initiator name to the computer. If you use the iscsi + parameter in your kickstart file, this parameter is mandatory, and + you must specify iscsiname in the kickstart file before you specify + iscsi.""", version=FC6) + op.add_argument("iqn", metavar="<iqn>", nargs=1, version=FC6, help=""" + IQN name""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "iscsiname")) - self.iscsiname = extra[0] + (_ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + assert len(_ns.iqn) == 1 + + if extra: + mapping = {"command": "iscsiname", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + self.iscsiname = _ns.iqn[0] return self diff --git a/mic/3rdparty/pykickstart/commands/key.py b/mic/3rdparty/pykickstart/commands/key.py index cfeb62e..e14b577 100644 --- a/mic/3rdparty/pykickstart/commands/key.py +++ b/mic/3rdparty/pykickstart/commands/key.py @@ -15,15 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import RHEL5 +from pykickstart.base import KickstartCommand +from pykickstart.constants import KS_INSTKEY_SKIP +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class RHEL5_Key(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -40,24 +40,28 @@ class RHEL5_Key(KickstartCommand): if self.key == KS_INSTKEY_SKIP: retval += "key --skip\n" - elif self.key != "": + elif self.key: retval += "key %s\n" % self.key return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--skip", action="store_true", default=False) + op = KSOptionParser(prog="key", description="set or skip the software installation key", version=RHEL5) + op.add_argument("--skip", action="store_true", default=False, + version=RHEL5, help="Skip the software installation key") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + self.set_to_self(ns) if self.skip: self.key = KS_INSTKEY_SKIP elif len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "key")) + raise KickstartParseError(_("Kickstart command %s requires one argument") % "key", lineno=self.lineno) + elif any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "key", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) else: self.key = extra[0] diff --git a/mic/3rdparty/pykickstart/commands/keyboard.py b/mic/3rdparty/pykickstart/commands/keyboard.py index 90379c4..38d1fc2 100644 --- a/mic/3rdparty/pykickstart/commands/keyboard.py +++ b/mic/3rdparty/pykickstart/commands/keyboard.py @@ -15,14 +15,16 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from textwrap import dedent +from pykickstart.base import KickstartCommand +from pykickstart.version import FC3, F18, versionToLongString +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser, commaSplit + +from pykickstart.i18n import _ -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) class FC3_Keyboard(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -36,20 +38,153 @@ class FC3_Keyboard(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.keyboard != "": + if self.keyboard: retval += "# System keyboard\nkeyboard %s\n" % self.keyboard return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="keyboard", description=""" + This required command sets system keyboard type.""", version=FC3) + op.add_argument("kbd", nargs='*', help="Keyboard type", version=FC3) + return op + + def parse(self, args): + (_ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if len(_ns.kbd) != 1: + raise KickstartParseError(_("Kickstart command %s requires one argument") % "keyboard", lineno=self.lineno) + elif extra: + mapping = {"command": "keyboard", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + self.keyboard = _ns.kbd[0] + return self + +class F18_Keyboard(FC3_Keyboard): + def __init__(self, writePriority=0, *args, **kwargs): # pylint: disable=super-init-not-called + KickstartCommand.__init__(self, writePriority, *args, **kwargs) # pylint: disable=non-parent-init-called + self.op = self._getParser() + self._keyboard = kwargs.get("_keyboard", "") + self.vc_keymap = kwargs.get("vc_keymap", "") + self.x_layouts = kwargs.get("x_layouts", []) + self.switch_options = kwargs.get("switch_options", []) + + def __str__(self): + if not any((self._keyboard, self.x_layouts, self.vc_keymap)): + return "" + + retval = "# Keyboard layouts\n" + if not self.vc_keymap and not self.x_layouts: + retval += "keyboard '%s'\n" % self._keyboard + return retval + + if self._keyboard: + retval += "# old format: keyboard %s\n" % self._keyboard + retval += "# new format:\n" + retval += "keyboard" + self._getArgsAsStr() + "\n" + + return retval + + def _getArgsAsStr(self): + retval = "" + + if self.vc_keymap: + retval += " --vckeymap=%s" % self.vc_keymap + + if self.x_layouts: + layouts_str = "'%s'" % self.x_layouts[0] + for layout in self.x_layouts[1:]: + layouts_str += ",'%s'" % layout + retval += " --xlayouts=%s" % layouts_str + + if self.switch_options: + switch_str = "'%s'" % self.switch_options[0] + for opt in self.switch_options[1:]: + switch_str += ",'%s'" % opt + retval += " --switch=%s" % switch_str + + return retval + + def _getParser(self): + op = FC3_Keyboard._getParser(self) + op.description += dedent(""" + + .. versionchanged:: %s + + See the documentation of ``--vckeymap`` option and the tip at the end + of this section for a guide how to get values accepted by this command. + + Either ``--vckeymap`` or ``--xlayouts`` must be used. + + Alternatively, use the older format, ``arg``, which is still supported. + ``arg`` can be an X layout or VConsole keymap name. + + Missing values will be automatically converted from the given one(s). + """ % versionToLongString(F18)) + + op.add_argument("--vckeymap", dest="vc_keymap", default="", help=""" + Specify VConsole keymap that should be used. is a keymap + name which is the same as the filename under + ``/usr/lib/kbd/keymaps/`` without the ``.map.gz`` extension. + """, version=F18) + op.add_argument("--xlayouts", dest="x_layouts", type=commaSplit, + version=F18, help=""" + Specify a list of X layouts that should be used + (comma-separated list without spaces). Accepts the same + values as ``setxkbmap(1)``, but uses either the layout format + (such as cz) or the 'layout (variant)' format (such as + 'cz (qwerty)'). For example:: + + ``keyboard --xlayouts=cz,'cz (qwerty)'`""") + op.add_argument("--switch", dest="switch_options", type=commaSplit, + version=F18, help=""" + Specify a list of layout switching options that should + be used (comma-separated list without spaces). Accepts + the same values as ``setxkbmap(1)`` for layout switching. + For example:: + + ``keyboard --xlayouts=cz,'cz (qwerty)' --switch=grp:alt_shift_toggle`` + """) + op.epilog = dedent(""" + *If you know only the description of the layout (e.g. Czech (qwerty)), + you can use http://vpodzime.fedorapeople.org/layouts_list.py to list + all available layouts and find the one you want to use. The string in + square brackets is the valid layout specification as Anaconda accepts + it. The same goes for switching options and + http://vpodzime.fedorapeople.org/switching_list.py*""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + + if len(ns.kbd) > 1: + message = _("A single argument is expected for the %s command") % "keyboard" + raise KickstartParseError(message, lineno=self.lineno) + elif extra: + mapping = {"command": "keyboard", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + elif not any([ns.kbd, self.vc_keymap, self.x_layouts]): + message = _("One of --xlayouts, --vckeymap options with value(s) " + "or argument is expected for the keyboard command") + raise KickstartParseError(message, lineno=self.lineno) - if len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "keyboard")) + if ns.kbd: + self._keyboard = ns.kbd[0] - self.keyboard = extra[0] return self + + # property for backwards compatibility + # pylint: disable=method-hidden + @property + def keyboard(self): + if self.x_layouts: + return self._keyboard or self.vc_keymap or self.x_layouts[0] + else: + return self._keyboard or self.vc_keymap or "" + + # pylint: disable=function-redefined,no-member + @keyboard.setter + def keyboard(self, value): + self._keyboard = value diff --git a/mic/3rdparty/pykickstart/commands/lang.py b/mic/3rdparty/pykickstart/commands/lang.py index 846a356..5186ed7 100644 --- a/mic/3rdparty/pykickstart/commands/lang.py +++ b/mic/3rdparty/pykickstart/commands/lang.py @@ -15,14 +15,14 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC3, F19 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser, commaSplit -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_Lang(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -36,25 +36,67 @@ class FC3_Lang(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.lang != "": + if self.lang: retval += "# System language\nlang %s\n" % self.lang return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="lang", description=""" + This required command sets the language to use during installation + and the default language to use on the installed system to ``<id>``. + This can be the same as any recognized setting for the ``$LANG`` + environment variable, though not all languages are supported during + installation. + + Certain languages (mainly Chinese, Japanese, Korean, and Indic + languages) are not supported during text mode installation. If one + of these languages is specified using the lang command, installation + will continue in English though the running system will have the + specified langauge by default. + + The file ``/usr/share/system-config-language/locale-list`` provides a + list the valid language codes in the first column of each line and + is part of the system-config-languages package.""", version=FC3) + op.add_argument("lang", metavar="<lang>", nargs=1, version=FC3, + help="Language ID.") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "lang")) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + assert len(ns.lang) == 1 + + if extra: + mapping = {"command": "lang", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - self.lang = extra[0] + self.set_to_self(ns) + self.lang = ns.lang[0] return self - def apply(self, instroot="/"): - if self.lang == "": return - f = open(instroot + "/etc/sysconfig/i18n", "w+") - f.write("LANG=\"%s\"\n" %(self.lang,)) - f.close() +class F19_Lang(FC3_Lang): + removedKeywords = FC3_Lang.removedKeywords + removedAttrs = FC3_Lang.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + FC3_Lang.__init__(self, writePriority, *args, **kwargs) + self.addsupport = kwargs.get("addsupport", []) + + self.op = self._getParser() + + def __str__(self): + s = FC3_Lang.__str__(self) + if s and self.addsupport: + s = s.rstrip() + s += " --addsupport=%s\n" % ",".join(self.addsupport) + return s + + def _getParser(self): + op = FC3_Lang._getParser(self) + op.add_argument("--addsupport", type=commaSplit, + metavar="LOCALE", help=""" + Install the support packages for the given locales, + specified as a comma-separated list. Each locale may be + specified in the same ways as the primary language may + be, as described above.""", version=F19) + return op diff --git a/mic/3rdparty/pykickstart/commands/langsupport.py b/mic/3rdparty/pykickstart/commands/langsupport.py index 73a9e53..db39dac 100644 --- a/mic/3rdparty/pykickstart/commands/langsupport.py +++ b/mic/3rdparty/pykickstart/commands/langsupport.py @@ -15,10 +15,13 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.version import FC3, FC5, F7, versionToLongString +from pykickstart.base import DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.errors import KickstartParseError +from pykickstart.i18n import _ +from pykickstart.options import KSOptionParser class FC3_LangSupport(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -43,16 +46,33 @@ class FC3_LangSupport(KickstartCommand): return retval + "\n" def _getParser(self): - op = KSOptionParser() - op.add_option("--default", dest="deflang", default="en_US.UTF-8") + op = KSOptionParser(prog="langsupport", description=""" + Install the support packages for the given locales.""", version=FC3) + op.add_argument("--default", dest="deflang", default="en_US.UTF-8", + version=FC3, help="Default locale") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + if any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "langsupport", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + self.set_to_self(ns) self.supported = extra return self -class FC5_LangSupport(DeprecatedCommand): - def __init__(self): +class FC5_LangSupport(DeprecatedCommand, FC3_LangSupport): + def __init__(self): # pylint: disable=super-init-not-called DeprecatedCommand.__init__(self) + + def _getParser(self): + op = FC3_LangSupport._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(FC5) + return op + +class F7_LangSupport(RemovedCommand, FC5_LangSupport): + def _getParser(self): + op = FC5_LangSupport._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F7) + return op diff --git a/mic/3rdparty/pykickstart/commands/lilocheck.py b/mic/3rdparty/pykickstart/commands/lilocheck.py index 754a32c..fcd2952 100644 --- a/mic/3rdparty/pykickstart/commands/lilocheck.py +++ b/mic/3rdparty/pykickstart/commands/lilocheck.py @@ -15,14 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC3, FC4, versionToLongString +from pykickstart.base import KickstartCommand, RemovedCommand +from pykickstart.options import KSOptionParser class FC3_LiloCheck(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -42,13 +39,16 @@ class FC3_LiloCheck(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="lilocheck", description="check LILO boot loader", version=FC3) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) > 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "lilocheck")) - + self.op.parse_args(args=args, lineno=self.lineno) self.check = True return self + +class FC4_LiloCheck(RemovedCommand, FC3_LiloCheck): + def _getParser(self): + op = FC3_LiloCheck._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(FC4) + return op diff --git a/mic/3rdparty/pykickstart/commands/liveimg.py b/mic/3rdparty/pykickstart/commands/liveimg.py new file mode 100644 index 0000000..cfd2918 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/liveimg.py @@ -0,0 +1,101 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2007, 2009, 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import F19 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser + +class F19_Liveimg(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.checksum = kwargs.get("checksum", "") + self.noverifyssl = kwargs.get("noverifyssl", None) + self.proxy = kwargs.get("proxy", None) + self.url = kwargs.get("url", None) + + self.op = self._getParser() + + def __eq__(self, other): + if not other: + return False + + return self.url == other.url and self.proxy == other.proxy and \ + self.noverifyssl == other.noverifyssl and \ + self.checksum == other.checksum + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use live disk image installation\n" + + retval += "liveimg --url=\"%s\"" % self.url + + if self.proxy: + retval += " --proxy=\"%s\"" % self.proxy + + if self.noverifyssl: + retval += " --noverifyssl" + + if self.checksum: + retval += " --checksum=\"%s\"" % self.checksum + + return retval + "\n" + + def _getParser(self): + op = KSOptionParser(prog="liveimg", description=""" + Install a disk image instead of packages. The image can be the + squashfs.img from a Live iso, or any filesystem mountable by the + install media (eg. ext4). Anaconda expects the image to contain + utilities it needs to complete the system install so the best way to + create one is to use livemedia-creator to make the disk image. If + the image contains /LiveOS/\\*.img (this is how squashfs.img is + structured) the first \\*.img file inside LiveOS will be mounted and + used to install the target system. The URL may also point to a + tarfile of the root filesystem. The file must end in .tar, .tbz, + .tgz, .txz, .tar.bz2, tar.gz, tar.xz""", version=F19) + op.add_argument("--url", metavar="<url>", required=True, version=F19, + help=""" + The URL to install from. http, https, ftp and file are + supported.""") + op.add_argument("--proxy", metavar="<proxyurl>", version=F19, help=""" + Specify an HTTP/HTTPS/FTP proxy to use while performing + the install. The various parts of the argument act like + you would expect. Syntax is:: + + ``--proxy=[protocol://][username[:password]@]host[:port]`` + """) + op.add_argument("--noverifyssl", action="store_true", version=F19, + default=False, help=""" + For a tree on a HTTPS server do not check the server's + certificate with what well-known CA validate and do not + check the server's hostname matches the certificate's + domain name.""") + op.add_argument("--checksum", metavar="<sha256>", version=F19, + help="Optional sha256 checksum of the image file") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + return self diff --git a/mic/3rdparty/pykickstart/commands/logging.py b/mic/3rdparty/pykickstart/commands/logging.py index 0708f77..22e2e75 100644 --- a/mic/3rdparty/pykickstart/commands/logging.py +++ b/mic/3rdparty/pykickstart/commands/logging.py @@ -15,14 +15,14 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC6, F34 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC6_Logging(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -33,34 +33,72 @@ class FC6_Logging(KickstartCommand): self.op = self._getParser() self.host = kwargs.get("host", "") - self.level = kwargs.get("level", "info") + self.level = kwargs.get("level", "") self.port = kwargs.get("port", "") + self._level_provided = bool(self.level) + if not self._level_provided: + self.level = "info" + def __str__(self): retval = KickstartCommand.__str__(self) - retval += "# Installation logging level\nlogging --level=%s" % self.level - if self.host != "": - retval += " --host=%s" % self.host + if self.level and self._level_provided: + retval += "# Installation logging level\nlogging --level=%s" % self.level - if self.port != "": - retval += " --port=%s" % self.port + if self.host: + retval += " --host=%s" % self.host + + if self.port: + retval += " --port=%s" % self.port return retval + "\n" def _getParser(self): - op = KSOptionParser() - op.add_option("--host") - op.add_option("--level", type="choice", default="info", - choices=["debug", "info", "warning", "error", "critical"]) - op.add_option("--port") + op = KSOptionParser(prog="logging", description=""" + This command controls the error logging of anaconda during + installation. It has no effect on the installed system.""", version=FC6) + op.add_argument("--host", version=FC6, help=""" + Send logging information to the given remote host, which must be + running a syslogd process configured to accept remote logging.""") + op.add_argument("--port", version=FC6, help=""" + If the remote syslogd process uses a port other than the default, it + may be specified with this option.""") + op.add_argument("--level", version=FC6, default="info", + choices=["debug", "info", "warning", "error", "critical"], + help=""" + Specify the minimum level of messages that appear on tty3. + All messages will still be sent to the log file regardless + of this level, however.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) - if opts.port and not opts.host: - raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Can't specify --port without --host."))) + if self.port and not self.host: + raise KickstartParseError(_("Can't specify --port without --host."), lineno=self.lineno) - self._setToSelf(self.op, opts) + self._level_provided = True return self + + +class F34_Logging(FC6_Logging): + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.host: + retval += "# Installation logging level\nlogging --host=%s" % self.host + + if self.port: + retval += " --port=%s" % self.port + + retval = retval + "\n" + + return retval + + def _getParser(self): + op = super()._getParser() + op.add_argument("--level", deprecated=F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/logvol.py b/mic/3rdparty/pykickstart/commands/logvol.py index 08bbf14..ae703e3 100644 --- a/mic/3rdparty/pykickstart/commands/logvol.py +++ b/mic/3rdparty/pykickstart/commands/logvol.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc. +# Copyright 2005, 2006, 2007, 2008, 2012 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,15 +15,16 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC3, FC4, F9, F12, F14, F15, F17, F18, F20, F21, F29 +from pykickstart.version import F23, RHEL5, RHEL6, RHEL7, RHEL8, versionToLongString +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser, commaSplit, mountpoint -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_LogVolData(BaseData): removedKeywords = BaseData.removedKeywords @@ -44,24 +45,30 @@ class FC3_LogVolData(BaseData): self.mountpoint = kwargs.get("mountpoint", "") def __eq__(self, y): + if not y: + return False + return self.vgname == y.vgname and self.name == y.name + def __ne__(self, y): + return not self == y + def _getArgsAsStr(self): retval = "" - if self.fstype != "": + if self.fstype: retval += " --fstype=\"%s\"" % self.fstype if self.grow: retval += " --grow" - if self.maxSizeMB > 0: + if self.maxSizeMB: retval += " --maxsize=%d" % self.maxSizeMB if not self.format: retval += " --noformat" - if self.percent > 0: + if self.percent: retval += " --percent=%d" % self.percent if self.recommended: retval += " --recommended" - if self.size > 0: + if self.size: retval += " --size=%d" % self.size if self.preexist: retval += " --useexisting" @@ -70,7 +77,12 @@ class FC3_LogVolData(BaseData): def __str__(self): retval = BaseData.__str__(self) - retval += "logvol %s %s --name=%s --vgname=%s\n" % (self.mountpoint, self._getArgsAsStr(), self.name, self.vgname) + + args = self._getArgsAsStr() + args += " --name=%s" % self.name + args += " --vgname=%s" % self.vgname + + retval += "logvol %s%s\n" % (self.mountpoint, args) return retval class FC4_LogVolData(FC3_LogVolData): @@ -85,9 +97,9 @@ class FC4_LogVolData(FC3_LogVolData): def _getArgsAsStr(self): retval = FC3_LogVolData._getArgsAsStr(self) - if hasattr(self, "bytesPerInode") and self.bytesPerInode != 0: + if hasattr(self, "bytesPerInode") and self.bytesPerInode: retval += " --bytes-per-inode=%d" % self.bytesPerInode - if self.fsopts != "": + if self.fsopts: retval += " --fsoptions=\"%s\"" % self.fsopts return retval @@ -107,7 +119,7 @@ class RHEL5_LogVolData(FC4_LogVolData): if self.encrypted: retval += " --encrypted" - if self.passphrase != "": + if self.passphrase: retval += " --passphrase=\"%s\"" % self.passphrase return retval @@ -128,12 +140,12 @@ class F9_LogVolData(FC4_LogVolData): def _getArgsAsStr(self): retval = FC4_LogVolData._getArgsAsStr(self) - if self.fsprofile != "": + if self.fsprofile: retval += " --fsprofile=\"%s\"" % self.fsprofile if self.encrypted: retval += " --encrypted" - if self.passphrase != "": + if self.passphrase: retval += " --passphrase=\"%s\"" % self.passphrase return retval @@ -152,7 +164,7 @@ class F12_LogVolData(F9_LogVolData): def _getArgsAsStr(self): retval = F9_LogVolData._getArgsAsStr(self) - if self.encrypted and self.escrowcert != "": + if self.encrypted and self.escrowcert: retval += " --escrowcert=\"%s\"" % self.escrowcert if self.backuppassphrase: @@ -160,7 +172,51 @@ class F12_LogVolData(F9_LogVolData): return retval -F14_LogVolData = F12_LogVolData +class RHEL6_LogVolData(F12_LogVolData): + removedKeywords = F12_LogVolData.removedKeywords + removedAttrs = F12_LogVolData.removedAttrs + + def __init__(self, *args, **kwargs): + F12_LogVolData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") + self.hibernation = kwargs.get("hibernation", False) + + self.thin_pool = kwargs.get("thin_pool", False) + self.thin_volume = kwargs.get("thin_volume", False) + self.pool_name = kwargs.get("pool_name", "") + self.chunk_size = kwargs.get("chunk_size", None) # kilobytes + self.metadata_size = kwargs.get("metadata_size", None) # megabytes + self.profile = kwargs.get("profile", "") + + def _getArgsAsStr(self): + retval = F12_LogVolData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher=\"%s\"" % self.cipher + if self.hibernation: + retval += " --hibernation" + + # these are only for thin pools + if self.thin_pool: + retval += " --thinpool" + + if self.metadata_size: + retval += " --metadatasize=%d" % self.metadata_size + + if self.chunk_size: + retval += " --chunksize=%d" % self.chunk_size + + if self.thin_volume: + retval += " --thin --poolname=%s" % self.pool_name + + if self.profile: + retval += " --profile=%s" % self.profile + + return retval + +class F14_LogVolData(F12_LogVolData): + pass class F15_LogVolData(F14_LogVolData): removedKeywords = F14_LogVolData.removedKeywords @@ -173,11 +229,163 @@ class F15_LogVolData(F14_LogVolData): def _getArgsAsStr(self): retval = F14_LogVolData._getArgsAsStr(self) - if self.label != "": + if self.label: retval += " --label=\"%s\"" % self.label return retval +class F17_LogVolData(F15_LogVolData): + removedKeywords = F15_LogVolData.removedKeywords + removedAttrs = F15_LogVolData.removedAttrs + + def __init__(self, *args, **kwargs): + F15_LogVolData.__init__(self, *args, **kwargs) + self.resize = kwargs.get("resize", False) + + def _getArgsAsStr(self): + retval = F15_LogVolData._getArgsAsStr(self) + if self.resize: + retval += " --resize" + + return retval + +class F18_LogVolData(F17_LogVolData): + removedKeywords = F17_LogVolData.removedKeywords + removedAttrs = F17_LogVolData.removedAttrs + + def __init__(self, *args, **kwargs): + F17_LogVolData.__init__(self, *args, **kwargs) + self.hibernation = kwargs.get("hibernation", False) + self.cipher = kwargs.get("cipher", "") + + def _getArgsAsStr(self): + retval = F17_LogVolData._getArgsAsStr(self) + + if self.hibernation: + retval += " --hibernation" + + if self.encrypted and self.cipher: + retval += " --cipher=\"%s\"" % self.cipher + + return retval + +class F20_LogVolData(F18_LogVolData): + removedKeywords = F18_LogVolData.removedKeywords + removedAttrs = F18_LogVolData.removedAttrs + + def __init__(self, *args, **kwargs): + F18_LogVolData.__init__(self, *args, **kwargs) + self.thin_pool = kwargs.get("thin_pool", False) + self.thin_volume = kwargs.get("thin_volume", False) + self.pool_name = kwargs.get("pool_name", "") + + # these are only for thin pools + self.chunk_size = kwargs.get("chunk_size", None) # kilobytes + self.metadata_size = kwargs.get("metadata_size", None) # megabytes + + def _getArgsAsStr(self): + retval = F18_LogVolData._getArgsAsStr(self) + + if self.thin_pool: + retval += " --thinpool" + + if self.metadata_size: + retval += " --metadatasize=%d" % self.metadata_size + + if self.chunk_size: + retval += " --chunksize=%d" % self.chunk_size + + if self.thin_volume: + retval += " --thin --poolname=%s" % self.pool_name + + return retval + +class F21_LogVolData(F20_LogVolData): + removedKeywords = F20_LogVolData.removedKeywords + removedAttrs = F20_LogVolData.removedAttrs + + def __init__(self, *args, **kwargs): + F20_LogVolData.__init__(self, *args, **kwargs) + self.profile = kwargs.get("profile", "") + + def _getArgsAsStr(self): + retval = F20_LogVolData._getArgsAsStr(self) + + if self.profile: + retval += " --profile=%s" % self.profile + + return retval + +class RHEL7_LogVolData(F21_LogVolData): + removedKeywords = F21_LogVolData.removedKeywords + removedAttrs = F21_LogVolData.removedAttrs + + def __init__(self, *args, **kwargs): + F21_LogVolData.__init__(self, *args, **kwargs) + self.mkfsopts = kwargs.get("mkfsoptions", "") or kwargs.get("mkfsopts", "") + + def _getArgsAsStr(self): + retval = F21_LogVolData._getArgsAsStr(self) + + if self.mkfsopts: + retval += " --mkfsoptions=\"%s\"" % self.mkfsopts + + return retval + +class F23_LogVolData(F21_LogVolData): + def __init__(self, *args, **kwargs): + F21_LogVolData.__init__(self, *args, **kwargs) + self.cache_size = kwargs.get("cache_size", 0) + self.cache_mode = kwargs.get("cache_mode", "") + self.cache_pvs = kwargs.get("cache_pvs", []) + self.mkfsopts = kwargs.get("mkfsoptions", "") or kwargs.get("mkfsopts", "") + + def _getArgsAsStr(self): + retval = F21_LogVolData._getArgsAsStr(self) + + if self.cache_size: + retval += " --cachesize=%d" % self.cache_size + if self.cache_pvs: + retval += " --cachepvs=%s" % ",".join(self.cache_pvs) + if self.cache_mode: + retval += " --cachemode=%s" % self.cache_mode + if self.mkfsopts: + retval += " --mkfsoptions=\"%s\"" % self.mkfsopts + + return retval + +class F29_LogVolData(F23_LogVolData): + def __init__(self, *args, **kwargs): + F23_LogVolData.__init__(self, *args, **kwargs) + self.luks_version = kwargs.get("luks_version", "") + self.pbkdf = kwargs.get("pbkdf", "") + self.pbkdf_memory = kwargs.get("pbkdf_memory", 0) + self.pbkdf_time = kwargs.get("pbkdf_time", 0) + self.pbkdf_iterations = kwargs.get("pbkdf_iterations", 0) + + def _getArgsAsStr(self): + retval = F23_LogVolData._getArgsAsStr(self) + + if self.encrypted and self.luks_version: + retval += " --luks-version=%s" % self.luks_version + + if self.encrypted and self.pbkdf: + retval += " --pbkdf=%s" % self.pbkdf + + if self.encrypted and self.pbkdf_memory: + retval += " --pbkdf-memory=%s" % self.pbkdf_memory + + if self.encrypted and self.pbkdf_time: + retval += " --pbkdf-time=%s" % self.pbkdf_time + + if self.encrypted and self.pbkdf_iterations: + retval += " --pbkdf-iterations=%s" % self.pbkdf_iterations + + return retval + +class RHEL8_LogVolData(F29_LogVolData): + pass + class FC3_LogVol(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -197,59 +405,104 @@ class FC3_LogVol(KickstartCommand): return retval def _getParser(self): - def lv_cb (option, opt_str, value, parser): - parser.values.format = False - parser.values.preexist = True - - op = KSOptionParser() - op.add_option("--fstype", dest="fstype") - op.add_option("--grow", dest="grow", action="store_true", - default=False) - op.add_option("--maxsize", dest="maxSizeMB", action="store", type="int", - nargs=1) - op.add_option("--name", dest="name", required=1) - op.add_option("--noformat", action="callback", callback=lv_cb, - dest="format", default=True, nargs=0) - op.add_option("--percent", dest="percent", action="store", type="int", - nargs=1) - op.add_option("--recommended", dest="recommended", action="store_true", - default=False) - op.add_option("--size", dest="size", action="store", type="int", - nargs=1) - op.add_option("--useexisting", dest="preexist", action="store_true", - default=False) - op.add_option("--vgname", dest="vgname", required=1) + op = KSOptionParser(prog="logvol", description=""" + Create a logical volume for Logical Volume Management + (LVM).""", version=FC3, epilog=""" + Create the partition first, create the logical volume + group, and then create the logical volume. For example:: + + part pv.01 --size 3000 + volgroup myvg pv.01 + logvol / --vgname=myvg --size=2000 --name=rootvol + """) + op.add_argument("mntpoint", metavar="<mntpoint>", type=mountpoint, nargs=1, + version=FC3, help=""" + Mountpoint for this logical volume or 'none'. + """) + op.add_argument("--fstype", version=FC3, help=""" + Sets the file system type for the logical volume. Valid + values include ext4, ext3, ext2, btrfs, swap, and vfat. + Other filesystems may be valid depending on command line + arguments passed to Anaconda to enable other filesystems. + """) + op.add_argument("--grow", action="store_true", default=False, + version=FC3, help=""" + Tells the logical volume to grow to fill available space + (if any), or up to the maximum size setting. Note that + ``--grow`` is not supported for logical volumes containing + a RAID volume on top of them.""") + op.add_argument("--maxsize", dest="maxSizeMB", type=int, + version=FC3, help=""" + The maximum size in MiB the logical volume may grow to. + Specify an integer value here, and do not append any + units. This option is only relevant if ``--grow`` is + specified as well.""") + op.add_argument("--name", required=True, version=FC3, help=""" + The name of this logical volume.""") + op.add_argument("--noformat", action="store_false", version=FC3, + dest="format", default=True, help=""" + Use an existing logical volume and do not format it. + """) + op.add_argument("--percent", dest="percent", type=int, + version=FC3, help=""" + Specify the size of the logical volume as a percentage + of available space in the volume group. Without the above + ``--grow`` option, this may not work.""") + op.add_argument("--recommended", action="store_true", default=False, + version=FC3, help=""" + Determine the size of the logical volume automatically. + """) + op.add_argument("--size", type=int, version=FC3, help=""" + Size of this logical volume.""") + op.add_argument("--useexisting", dest="preexist", version=FC3, + action="store_true", default=False, + help="Use an existing logical volume and reformat it.") + op.add_argument("--vgname", required=True, version=FC3, help=""" + Name of the Volume Group this logical volume belongs to. + """) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) - if len(extra) == 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol")) + if extra: + mapping = {"command": "logvol", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - lvd = self.handler.LogVolData() - self._setToObj(self.op, opts, lvd) + lvd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, lvd) lvd.lineno = self.lineno - lvd.mountpoint=extra[0] + lvd.mountpoint = ns.mntpoint[0] + + if not lvd.format: + lvd.preexist = True # Check for duplicates in the data list. if lvd in self.dataList(): - warnings.warn(_("A logical volume with the name %s has already been defined in volume group %s.") % (lvd.device, lvd.vgname)) + warnings.warn(_("A logical volume with the name %(logical_volume_name)s has already been defined in volume group %(volume_group)s.") % {"logical_volume_name": lvd.name, "volume_group": lvd.vgname}, KickstartParseWarning) return lvd def dataList(self): return self.lvList + @property + def dataClass(self): + return self.handler.LogVolData + class FC4_LogVol(FC3_LogVol): removedKeywords = FC3_LogVol.removedKeywords removedAttrs = FC3_LogVol.removedAttrs def _getParser(self): op = FC3_LogVol._getParser(self) - op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store", - type="int", nargs=1) - op.add_option("--fsoptions", dest="fsopts") + op.add_argument("--bytes-per-inode", dest="bytesPerInode", type=int, + version=FC4, help="Specify the bytes/inode ratio.") + op.add_argument("--fsoptions", dest="fsopts", version=FC4, help=""" + Specifies a free form string of options to be used when + mounting the filesystem. This string will be copied into + the ``/etc/fstab`` file of the installed system and should + be enclosed in quotes.""") return op class RHEL5_LogVol(FC4_LogVol): @@ -258,8 +511,17 @@ class RHEL5_LogVol(FC4_LogVol): def _getParser(self): op = FC4_LogVol._getParser(self) - op.add_option("--encrypted", action="store_true", default=False) - op.add_option("--passphrase") + op.add_argument("--encrypted", action="store_true", version=RHEL5, + default=False, help=""" + Specify that this logical volume should be encrypted. + """) + op.add_argument("--passphrase", version=RHEL5, help=""" + Specify the passphrase to use when encrypting this + logical volume. Without the above ``--encrypted`` + option, this option does nothing. If no passphrase is + specified, the default system-wide one is used, or the + installer will stop and prompt if there is no default. + """) return op class F9_LogVol(FC4_LogVol): @@ -268,11 +530,27 @@ class F9_LogVol(FC4_LogVol): def _getParser(self): op = FC4_LogVol._getParser(self) - op.add_option("--bytes-per-inode", deprecated=1) - op.add_option("--fsprofile", dest="fsprofile", action="store", - type="string", nargs=1) - op.add_option("--encrypted", action="store_true", default=False) - op.add_option("--passphrase") + op.add_argument("--bytes-per-inode", deprecated=F9) + op.add_argument("--fsprofile", version=F9, help=""" + Specifies a usage type to be passed to the program that + makes a filesystem on this partition. A usage type + defines a variety of tuning parameters to be used when + making a filesystem. For this option to work, the + filesystem must support the concept of usage types and + there must be a configuration file that lists valid + types. For ext2/3/4, this configuration file is + ``/etc/mke2fs.conf``.""") + op.add_argument("--encrypted", action="store_true", default=False, + version=F9, help=""" + Specify that this logical volume should be encrypted. + """) + op.add_argument("--passphrase", version=F9, help=""" + Specify the passphrase to use when encrypting this + logical volume. Without the above ``--encrypted`` + option, this option does nothing. If no passphrase is + specified, the default system-wide one is used, or the + installer will stop and prompt if there is no default. + """) return op class F12_LogVol(F9_LogVol): @@ -281,17 +559,95 @@ class F12_LogVol(F9_LogVol): def _getParser(self): op = F9_LogVol._getParser(self) - op.add_option("--escrowcert") - op.add_option("--backuppassphrase", action="store_true", default=False) + op.add_argument("--escrowcert", metavar="<url>", version=F12, help=""" + Load an X.509 certificate from ``<url>``. Store the data + encryption key of this logical volume, encrypted using + the certificate, as a file in ``/root``. Only relevant + if ``--encrypted`` is specified as well.""") + op.add_argument("--backuppassphrase", action="store_true", version=F12, + default=False, help=""" + Only relevant if ``--escrowcert`` is specified as well. + In addition to storing the data encryption key, generate + a random passphrase and add it to this logical volume. + Then store the passphrase, encrypted using the certificate + specified by ``--escrowcert``, as a file in ``/root``. If + more than one LUKS volume uses ``--backuppassphrase``, + the same passphrase will be used for all such volumes. + """) + return op + +class RHEL6_LogVol(F12_LogVol): + removedKeywords = F12_LogVol.removedKeywords + removedAttrs = F12_LogVol.removedAttrs + + def _getParser(self): + op = F12_LogVol._getParser(self) + op.add_argument("--cipher", version=RHEL6, help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which encryption algorithm should be used to encrypt the + filesystem.""") + op.add_argument("--hibernation", action="store_true", default=False, + version=RHEL6, help=""" + This option can be used to automatically determine the + size of the swap partition big enough for hibernation. + """) + op.add_argument("--thinpool", action="store_true", version=RHEL6, + dest="thin_pool", default=False, help=""" + Create a thin pool logical volume. Use a mountpoint of + 'none'""") + op.add_argument("--thin", action="store_true", version=RHEL6, + dest="thin_volume", default=False, help=""" + Create a thin logical volume. Requires ``--poolname``. + """) + op.add_argument("--poolname", dest="pool_name", version=RHEL6, help=""" + Specify the name of the thin pool in which to create a + thin logical volume. Requires ``--thin``.""") + op.add_argument("--chunksize", type=int, dest="chunk_size", + version=RHEL6, help=""" + Specify the chunk size (in KiB) for a new thin pool + device.""") + op.add_argument("--metadatasize", type=int, dest="metadata_size", + version=RHEL6, help=""" + Specify the metadata area size (in MiB) for a new thin + pool device.""") + op.add_argument("--profile", version=RHEL6, help=""" + Specify an LVM profile for the thin pool (see ``lvm(8)``, + standard profiles are ``default`` and ``thin-performance`` + defined in the ``/etc/lvm/profile/`` directory).""") return op + def parse(self, args): + # call the overriden method + retval = F12_LogVol.parse(self, args) + # the logvol command can't be used together with the autopart command + # due to the hard to debug behavior their combination introduces + if self.handler.autopart.seen: + errorMsg = _("The logvol and autopart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + if retval.thin_volume and retval.thin_pool: + errorMsg = _("--thin and --thinpool cannot both be specified for " + "the same logvol") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + if retval.thin_volume and not retval.pool_name: + errorMsg = _("--thin requires --poolname to specify pool name") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + if (retval.chunk_size or retval.metadata_size) and \ + not retval.thin_pool: + errorMsg = _("--chunksize and --metadatasize are for thin pools only") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + return retval + class F14_LogVol(F12_LogVol): removedKeywords = F12_LogVol.removedKeywords removedAttrs = F12_LogVol.removedAttrs def _getParser(self): op = F12_LogVol._getParser(self) - op.remove_option("--bytes-per-inode") + op.remove_argument("--bytes-per-inode", version=F14) return op class F15_LogVol(F14_LogVol): @@ -300,5 +656,292 @@ class F15_LogVol(F14_LogVol): def _getParser(self): op = F14_LogVol._getParser(self) - op.add_option("--label") + op.add_argument("--label", version=F15, help=""" + Specify the label to give to the filesystem to be made. + If the given label is already in use by another + filesystem, a new label will be created.""") + return op + +class F17_LogVol(F15_LogVol): + removedKeywords = F15_LogVol.removedKeywords + removedAttrs = F15_LogVol.removedAttrs + + def _getParser(self): + op = F15_LogVol._getParser(self) + op.add_argument("--resize", action="store_true", default=False, + version=F17, help=""" + Attempt to resize this logical volume to the size given + by ``--size=``. This option must be used with + ``--useexisting --size=``, or an error will be raised. + """) return op + + def parse(self, args): + retval = F15_LogVol.parse(self, args) + + if retval.resize and not retval.preexist: + raise KickstartParseError(_("--resize can only be used in conjunction with --useexisting"), lineno=self.lineno) + + if retval.resize and not retval.size: + raise KickstartParseError(_("--resize requires --size to indicate new size"), lineno=self.lineno) + + return retval + +class F18_LogVol(F17_LogVol): + removedKeywords = F17_LogVol.removedKeywords + removedAttrs = F17_LogVol.removedAttrs + + def _getParser(self): + op = F17_LogVol._getParser(self) + op.add_argument("--hibernation", action="store_true", default=False, + version=F18, help=""" + This option can be used to automatically determine the + size of the swap partition big enough for hibernation. + """) + + op.add_argument("--cipher", version=F18, help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which encryption algorithm should be used to encrypt the + filesystem.""") + return op + +class F20_LogVol(F18_LogVol): + removedKeywords = F18_LogVol.removedKeywords + removedAttrs = F18_LogVol.removedAttrs + + def _getParser(self): + op = F18_LogVol._getParser(self) + op.add_argument("--thinpool", action="store_true", version=F20, + dest="thin_pool", default=False, help=""" + Create a thin pool logical volume. Use a mountpoint + of 'none'.""") + op.add_argument("--thin", action="store_true", version=F20, + dest="thin_volume", default=False, help=""" + Create a thin logical volume. Requires ``--poolname``. + """) + op.add_argument("--poolname", dest="pool_name", version=F20, help=""" + Specify the name of the thin pool in which to create a + thin logical volume. Requires ``--thin``.""") + op.add_argument("--chunksize", type=int, dest="chunk_size", + version=F20, help=""" + Specify the chunk size (in KiB) for a new thin pool + device.""") + op.add_argument("--metadatasize", type=int, dest="metadata_size", + version=F20, help=""" + Specify the metadata area size (in MiB) for a new thin + pool device.""") + return op + + def parse(self, args): + retval = F18_LogVol.parse(self, args) + + if retval.thin_volume and retval.thin_pool: + err = _("--thin and --thinpool cannot both be specified for the same logvol") + raise KickstartParseError(err, lineno=self.lineno) + + if retval.thin_volume and not retval.pool_name: + err = _("--thin requires --poolname to specify pool name") + raise KickstartParseError(err, lineno=self.lineno) + + if (retval.chunk_size or retval.metadata_size) and \ + not retval.thin_pool: + err = _("--chunksize and --metadatasize are for thin pools only") + raise KickstartParseError(err, lineno=self.lineno) + + # the logvol command can't be used together with the autopart command + # due to the hard to debug behavior their combination introduces + if self.handler.autopart.seen: + errorMsg = _("The logvol and autopart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + # the same applies to the 'mount' command + if hasattr(self.handler, "mount") and self.handler.mount.seen: + errorMsg = _("The logvol and mount commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + if not retval.preexist and not retval.percent and not retval.size and not retval.recommended and not retval.hibernation: + errorMsg = _("No size given for logical volume. Use one of --useexisting, --noformat, --size, --percent, or --hibernation.") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + if retval.percent is not None and (retval.percent < 0 or retval.percent > 100): + errorMsg = _("Percentage must be between 0 and 100.") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + return retval + +class F21_LogVol(F20_LogVol): + removedKeywords = F20_LogVol.removedKeywords + removedAttrs = F20_LogVol.removedAttrs + + def _getParser(self): + op = F20_LogVol._getParser(self) + op.add_argument("--profile", version=F21, help=""" + Specify an LVM profile for the thin pool (see ``lvm(8)``, + standard profiles are ``default`` and ``thin-performance`` + defined in the ``/etc/lvm/profile/`` directory).""") + return op + + def parse(self, args): + retval = F20_LogVol.parse(self, args) + + if retval.size and retval.percent: + err = _("--size and --percent cannot both be specified for the same logvol") + raise KickstartParseError(err, lineno=self.lineno) + + return retval + +class RHEL7_LogVol(F21_LogVol): + removedKeywords = F21_LogVol.removedKeywords + removedAttrs = F21_LogVol.removedAttrs + + def _getParser(self): + op = F21_LogVol._getParser(self) + op.add_argument("--mkfsoptions", dest="mkfsopts", version=RHEL7, help=""" + Specifies additional parameters to be passed to the + program that makes a filesystem on this partition. No + processing is done on the list of arguments, so they + must be supplied in a format that can be passed directly + to the mkfs program. This means multiple options should + be comma-separated or surrounded by double quotes, + depending on the filesystem.""") + return op + + def parse(self, args): + retval = F21_LogVol.parse(self, args) + + if not retval.format and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions with --noformat has no effect."), lineno=self.lineno) + + if retval.fsprofile and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions and --fsprofile cannot be used together."), lineno=self.lineno) + + return retval + + +class F23_LogVol(F21_LogVol): + def _getParser(self): + op = F21_LogVol._getParser(self) + op.add_argument("--cachesize", type=int, dest="cache_size", + version=F23, help=""" + Requested size (in MiB) of cache attached to the logical + volume. Requires ``--cachepvs``.""") + op.add_argument("--cachemode", dest="cache_mode", version=F23, help=""" + Mode that should be used for the cache. Either + ``writeback`` or ``writethrough``.""") + op.add_argument("--cachepvs", dest="cache_pvs", type=commaSplit, + version=F23, help=""" + Comma-separated list of (fast) physical volumes that + should be used for the cache.""") + op.add_argument("--mkfsoptions", dest="mkfsopts", version=F23, help=""" + Specifies additional parameters to be passed to the + program that makes a filesystem on this partition. No + processing is done on the list of arguments, so they + must be supplied in a format that can be passed directly + to the mkfs program. This means multiple options should + be comma-separated or surrounded by double quotes, + depending on the filesystem.""") + return op + + def parse(self, args): + retval = F21_LogVol.parse(self, args) + + if retval.cache_size or retval.cache_mode or retval.cache_pvs: + if retval.preexist: + err = _("Adding a cache to an existing logical volume is not supported") + raise KickstartParseError(err, lineno=self.lineno) + + if retval.thin_volume: + err = _("Thin volumes cannot be cached") + raise KickstartParseError(err, lineno=self.lineno) + + if not retval.cache_pvs: + err = _("Cache needs to have a list of (fast) PVs specified") + raise KickstartParseError(err, lineno=self.lineno) + + if not retval.cache_size: + err = _("Cache needs to have size specified") + raise KickstartParseError(err, lineno=self.lineno) + + if retval.cache_mode and retval.cache_mode not in ("writeback", "writethrough"): + err = _("Invalid cache mode given: %s") % retval.cache_mode + raise KickstartParseError(err, lineno=self.lineno) + + if not retval.format and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions with --noformat has no effect."), lineno=self.lineno) + + if retval.fsprofile and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions and --fsprofile cannot be used together."), lineno=self.lineno) + + return retval + +class F29_LogVol(F23_LogVol): + removedKeywords = F23_LogVol.removedKeywords + removedAttrs = F23_LogVol.removedAttrs + + def _getParser(self): + op = F23_LogVol._getParser(self) + op.add_argument("--luks-version", dest="luks_version", version=F29, default="", + help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which version of LUKS format should be used to encrypt + the filesystem.""") + op.add_argument("--pbkdf", version=F29, default="", help=""" + Only relevant if ``--encrypted`` is specified. Sets + Password-Based Key Derivation Function (PBKDF) algorithm + for LUKS keyslot. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-memory", dest="pbkdf_memory", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the memory cost for PBKDF. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-time", dest="pbkdf_time", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of milliseconds to spend with PBKDF passphrase + processing. See ``--iter-time`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) + op.add_argument("--pbkdf-iterations", dest="pbkdf_iterations", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of iterations directly and avoids PBKDF benchmark. + See ``--pbkdf-force-iterations`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) + return op + + def parse(self, args): + retval = F23_LogVol.parse(self, args) + + if retval.pbkdf_time and retval.pbkdf_iterations: + msg = _("Only one of --pbkdf-time and --pbkdf-iterations can be specified.") + raise KickstartParseError(msg, lineno=self.lineno) + + return retval + +class RHEL8_LogVol(F29_LogVol): + removedKeywords = F29_LogVol.removedKeywords + removedAttrs = F29_LogVol.removedAttrs + + def parse(self, args): + retval = F29_LogVol.parse(self, args) + if retval.fstype == "btrfs": + raise KickstartParseError(_("Btrfs file system is not supported"), lineno=self.lineno) + return retval + + def _getParser(self): + "Only necessary for the type change documentation" + op = F29_LogVol._getParser(self) + for action in op._actions: + if "--fstype" in action.option_strings: + action.help += """ + + .. versionchanged:: %s + + Btrfs support was removed.""" % versionToLongString(RHEL8) + return op + +class RHEL9_LogVol(RHEL8_LogVol): + pass diff --git a/mic/3rdparty/pykickstart/commands/mediacheck.py b/mic/3rdparty/pykickstart/commands/mediacheck.py index 9a785d8..04ff414 100644 --- a/mic/3rdparty/pykickstart/commands/mediacheck.py +++ b/mic/3rdparty/pykickstart/commands/mediacheck.py @@ -15,14 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC4 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser class FC4_MediaCheck(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -41,13 +38,14 @@ class FC4_MediaCheck(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="mediacheck", description=""" + If given, this will force anaconda to run mediacheck + on the installation media. This command requires that + installs be attended, so it is disabled by default. + """, version=FC4) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) > 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "mediacheck")) - + self.op.parse_args(args=args, lineno=self.lineno) self.mediacheck = True return self diff --git a/mic/3rdparty/pykickstart/commands/method.py b/mic/3rdparty/pykickstart/commands/method.py index 3b384c1..a863d6f 100644 --- a/mic/3rdparty/pykickstart/commands/method.py +++ b/mic/3rdparty/pykickstart/commands/method.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2007, 2009 Red Hat, Inc. +# Copyright 2013 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -17,170 +17,135 @@ # subject to the GNU General Public License and may only be used or replicated # with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC3, F34, versionToLongString +from pykickstart.base import KickstartCommand, DeprecatedCommand +from pykickstart.options import KSOptionParser class FC3_Method(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs - def __init__(self, writePriority=0, *args, **kwargs): - KickstartCommand.__init__(self, writePriority, *args, **kwargs) - self.method = kwargs.get("method", "") - - # Set all these attributes so calls to this command's __call__ - # method can set them. However we don't want to provide them as - # arguments to __init__ because method is special. - self.biospart = None - self.partition = None - self.server = None - self.dir = None - self.url = None - - def __str__(self): - retval = KickstartCommand.__str__(self) - - if self.method == "cdrom": - retval += "# Use CDROM installation media\ncdrom\n" - elif self.method == "harddrive": - msg = "# Use hard drive installation media\nharddrive --dir=%s" % self.dir - - if self.biospart is not None: - retval += msg + " --biospart=%s\n" % self.biospart - else: - retval += msg + " --partition=%s\n" % self.partition - elif self.method == "nfs": - retval += "# Use NFS installation media\nnfs --server=%s --dir=%s\n" % (self.server, self.dir) - elif self.method == "url": - retval += "# Use network installation\nurl --url=\"%s\"\n" % self.url - - return retval + # These are all set up as part of the base KickstartCommand. We want to + # make sure looking them up gets redirected to the right place. + internals = ["method", + "writePriority", "currentCmd", "currentLine", "handler", "lineno", "seen"] - def _getParser(self): - op = KSOptionParser() - - # method = "cdrom" falls through to the return - if self.currentCmd == "harddrive": - op.add_option("--biospart", dest="biospart") - op.add_option("--partition", dest="partition") - op.add_option("--dir", dest="dir", required=1) - elif self.currentCmd == "nfs": - op.add_option("--server", dest="server", required=1) - op.add_option("--dir", dest="dir", required=1) - elif self.currentCmd == "url": - op.add_option("--url", dest="url", required=1) + _methods = ["cdrom", "harddrive", "nfs", "url"] - return op + def _clear_seen(self): + """ Reset all the method's seen attributes to False""" + for method in self._methods: + setattr(getattr(self.handler, method), "seen", False) - def parse(self, args): - self.method = self.currentCmd + def _get_command(self, method): + """Get a command for the given method.""" + if method is None: + # We use this to select the closest mirror option. + # TODO: Raise an error instead. + method = "url" - op = self._getParser() - (opts, extra) = op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(op, opts) + if method not in self._methods: + raise AttributeError("Unknown method: {}".format(method)) - if self.currentCmd == "harddrive": - if self.biospart is None and self.partition is None or \ - self.biospart is not None and self.partition is not None: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of biospart or partition options must be specified."))) + return getattr(self.handler, method) - return self + @property + def method(self): + """Return the seen method or None.""" + for method in self._methods: + if getattr(self.handler, method).seen: + return method -class FC6_Method(FC3_Method): - removedKeywords = FC3_Method.removedKeywords - removedAttrs = FC3_Method.removedAttrs + return None - def __init__(self, writePriority=0, *args, **kwargs): - FC3_Method.__init__(self, writePriority, *args, **kwargs) + @method.setter + def method(self, value): + """Set which method is seen.""" + self._clear_seen() - # Same reason for this attribute as the comment in FC3_Method. - self.opts = None + if value is None: + return - def __str__(self): - retval = KickstartCommand.__str__(self) + self._get_command(value).seen = True - if self.method == "cdrom": - retval += "# Use CDROM installation media\ncdrom\n" - elif self.method == "harddrive": - msg = "# Use hard drive installation media\nharddrive --dir=%s" % self.dir + def __getattr__(self, name): + """Get the attribute in the seen command. - if self.biospart is not None: - retval += msg + " --biospart=%s\n" % self.biospart - else: - retval += msg + " --partition=%s\n" % self.partition - elif self.method == "nfs": - retval += "# Use NFS installation media\nnfs --server=%s --dir=%s" % (self.server, self.dir) - if self.opts is not None: - retval += " --opts=\"%s\"" % self.opts - retval += "\n" - elif self.method == "url": - retval += "# Use network installation\nurl --url=\"%s\"\n" % self.url + Called when an attribute lookup has not found + the attribute in the usual places. + """ + # Prevent recursion in copy and deepcopy. + # See commit f5dbcfb for explanation. + if name in ["handler", "method", "_methods"]: + raise AttributeError() - return retval + command = self._get_command(self.method) + return getattr(command, name) - def _getParser(self): - op = FC3_Method._getParser(self) + def __setattr__(self, name, value): + """Set the attribute in the seen command. - if self.currentCmd == "nfs": - op.add_option("--opts", dest="opts") + Called when an attribute assignment is attempted. + """ + if name in self.internals: + super(FC3_Method, self).__setattr__(name, value) + return - return op + command = self._get_command(self.method) + # Check if the kickstart command has the attribute. + # Instead of using hasattr, that calls getattr and catches the exception + # that we would have to raise again, we call getattr directly. + getattr(command, name) + # Set the attribute of the kickstart command. + command.__setattr__(name, value) -class F13_Method(FC6_Method): - removedKeywords = FC6_Method.removedKeywords - removedAttrs = FC6_Method.removedAttrs + def _getParser(self): + """Return a parser.""" - def __init__(self, *args, **kwargs): - FC6_Method.__init__(self, *args, **kwargs) + description = "Proxy to the actual installation method. Valid installation methods are:\n\n" + for method in self._methods: + description += "* ``%s``\n" % method - # And same as all the other __init__ methods. - self.proxy = "" + return KSOptionParser(prog="method", description=description, version=FC3) - def __str__(self): - retval = FC6_Method.__str__(self) - if self.method == "url" and self.proxy: - retval = retval.strip() - retval += " --proxy=\"%s\"\n" % self.proxy +# These are all just for compat. Calling into the appropriate version-specific +# method command will deal with making sure the right options are used. +class FC6_Method(FC3_Method): + pass - return retval +class F13_Method(FC6_Method): + pass - def _getParser(self): - op = FC6_Method._getParser(self) +class F14_Method(F13_Method): + pass - if self.currentCmd == "url": - op.add_option("--proxy") +class RHEL6_Method(F14_Method): + pass - return op +class F18_Method(F14_Method): + pass -class F14_Method(F13_Method): - removedKeywords = F13_Method.removedKeywords - removedAttrs = F13_Method.removedAttrs +class F19_Method(FC3_Method): + removedKeywords = FC3_Method.removedKeywords + removedAttrs = FC3_Method.removedAttrs - def __init__(self, *args, **kwargs): - F13_Method.__init__(self, *args, **kwargs) + _methods = FC3_Method._methods + ["liveimg"] - self.noverifyssl = False +class RHEL7_Method(F19_Method): + removedKeywords = F19_Method.removedKeywords + removedAttrs = F19_Method.removedAttrs - def __str__(self): - retval = F13_Method.__str__(self) + _methods = F19_Method._methods + ["hmc"] - if self.method == "url" and self.noverifyssl: - retval = retval.strip() - retval += " --noverifyssl\n" +class F28_Method(RHEL7_Method): + pass - return retval +class F34_Method(DeprecatedCommand, F19_Method): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) def _getParser(self): - op = F13_Method._getParser(self) - - if self.currentCmd == "url": - op.add_option("--noverifyssl", action="store_true", default=False) - + op = F19_Method._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F34) return op - -RHEL6_Method = F14_Method diff --git a/mic/3rdparty/pykickstart/commands/module.py b/mic/3rdparty/pykickstart/commands/module.py new file mode 100644 index 0000000..3abb182 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/module.py @@ -0,0 +1,167 @@ +# +# Martin Kolman <mkolman@redhat.com> +# +# Copyright 2018 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# + +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser +from pykickstart.version import F29, RHEL8 + +from pykickstart.i18n import _ + + +class F29_ModuleData(BaseData): + removedKeywords = BaseData.removedKeywords + removedAttrs = BaseData.removedAttrs + + def __init__(self, *args, **kwargs): + BaseData.__init__(self, *args, **kwargs) + self.name = kwargs.get("name", "") + self.stream = kwargs.get("stream", "") + + def __eq__(self, y): + if not y: + return False + return (self.name == y.name and self.stream == y.stream) + + def __ne__(self, y): + return not self == y + + + def __str__(self): + retval = BaseData.__str__(self) + + args = self._getArgsAsStr() + if args: + retval += "module%s\n" % args + + return retval + + def _getArgsAsStr(self): + retval = " --name=%s" % self.name + # --stream is optional + if self.stream: + retval += " --stream=%s" % self.stream + return retval + +class RHEL8_ModuleData(F29_ModuleData): + removedKeywords = F29_ModuleData.removedKeywords + removedAttrs = F29_ModuleData.removedAttrs + + def __init__(self, *args, **kwargs): + F29_ModuleData.__init__(self, *args, **kwargs) + self.enable = kwargs.get("enable", True) + + def _getArgsAsStr(self): + retval = F29_ModuleData._getArgsAsStr(self) + + # --disable is optional + if not self.enable: + retval += " --disable" + + return retval + +class F31_ModuleData(RHEL8_ModuleData): + removedKeywords = RHEL8_ModuleData.removedKeywords + removedAttrs = RHEL8_ModuleData.removedAttrs + +class F29_Module(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + + self.moduleList = kwargs.get("moduleList", []) + self.op = self._getParser() + + def __str__(self): + retval = "" + + for module in self.moduleList: + retval += module.__str__() + + return retval + + def _getParser(self): + op = KSOptionParser(prog="module", description=""" + The module command makes it possible to manipulate + modules. + + (In this case we mean modules as introduced by the + Fedora modularity initiative.) + + A module is defined by a unique name and a stream id, + where single module can (and usually has) multiple + available streams. + + Streams will in most cases corresponds to stable + releases of the given software components + (such as Node.js, Django, etc.) but there could be + also other use cases, such as a raw upstream master + branch stream or streams corresponding to an upcoming + stable release. + + For more information see the Fedora modularity + initiative documentation: + https://docs.pagure.org/modularity/""", version=F29) + op.add_argument("--name", metavar="<module_name>", version=F29, required=True, + help=""" + Name of the module to enable.""") + op.add_argument("--stream", metavar="<module_stream_name>", version=F29, required=False, + help=""" + Name of the module stream to enable.""") + + return op + + def parse(self, args): + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if len(extra) > 0: + msg = _("The enable module command does not take position arguments!") + raise KickstartParseError(msg, lineno=self.lineno) + + enable_module_data = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, enable_module_data) + enable_module_data.lineno = self.lineno + + return enable_module_data + + def dataList(self): + return self.moduleList + + @property + def dataClass(self): + return self.handler.ModuleData + +class RHEL8_Module(F29_Module): + removedKeywords = F29_Module.removedKeywords + removedAttrs = F29_Module.removedAttrs + + def _getParser(self): + op = F29_Module._getParser(self) + op.add_argument("--disable", version=RHEL8, + action="store_false", + dest="enable", + help="Disable module.") + return op + +class F31_Module(RHEL8_Module): + removedKeywords = RHEL8_Module.removedKeywords + removedAttrs = RHEL8_Module.removedAttrs diff --git a/mic/3rdparty/pykickstart/commands/monitor.py b/mic/3rdparty/pykickstart/commands/monitor.py index 57f1e51..6448f21 100644 --- a/mic/3rdparty/pykickstart/commands/monitor.py +++ b/mic/3rdparty/pykickstart/commands/monitor.py @@ -15,14 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC3, FC6, F10, F18, versionToLongString +from pykickstart.base import DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.options import KSOptionParser class FC3_Monitor(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -38,35 +35,45 @@ class FC3_Monitor(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - retval += "monitor" - if self.hsync != "": + if self.hsync: retval += " --hsync=%s" % self.hsync - if self.monitor != "": + if self.monitor: retval += " --monitor=\"%s\"" % self.monitor - if self.vsync != "": + if self.vsync: retval += " --vsync=%s" % self.vsync - if retval != "monitor": - return retval + "\n" - else: - return "" + if retval: + retval = "monitor%s\n" % retval + + return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--hsync") - op.add_option("--monitor") - op.add_option("--vsync") + op = KSOptionParser(prog="monitor", description=""" + If the monitor command is not given, anaconda will + use X to automatically detect your monitor settings. + Please try this before manually configuring your + monitor.""", version=FC3) + op.add_argument("--hsync", version=FC3, help=""" + Specifies the horizontal sync frequency of the monitor. + """) + op.add_argument("--monitor", version=FC3, help=""" + Use specified monitor; monitor name should be from the + list of monitors in ``/usr/share/hwdata/MonitorsDB`` from + the hwdata package. The list of monitors can also be + found on the X Configuration screen of the + Kickstart Configurator. This is ignored if ``--hsync`` or + ``--vsync`` is provided. If no monitor information is + provided, the installation program tries to probe for + it automatically.""") + op.add_argument("--vsync", version=FC3, help=""" + Specifies the vertical sync frequency of the monitor. + """) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if extra: - mapping = {"cmd": "monitor", "options": extra} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(cmd)s command: %(options)s") % mapping)) - - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self class FC6_Monitor(FC3_Monitor): @@ -79,28 +86,39 @@ class FC6_Monitor(FC3_Monitor): def __str__(self): retval = KickstartCommand.__str__(self) - retval += "monitor" - if self.hsync != "": + if self.hsync: retval += " --hsync=%s" % self.hsync - if self.monitor != "": + if self.monitor: retval += " --monitor=\"%s\"" % self.monitor if not self.probe: retval += " --noprobe" - if self.vsync != "": + if self.vsync: retval += " --vsync=%s" % self.vsync - if retval != "monitor": - return retval + "\n" - else: - return "" + if retval: + retval = "monitor%s\n" % retval + + return retval def _getParser(self): op = FC3_Monitor._getParser(self) - op.add_option("--noprobe", dest="probe", action="store_false", - default=True) + op.add_argument("--noprobe", dest="probe", action="store_false", + default=True, version=FC6, help=""" + Do not probe the monitor.""") return op -class F10_Monitor(DeprecatedCommand): - def __init__(self): +class F10_Monitor(DeprecatedCommand, FC6_Monitor): + def __init__(self): # pylint: disable=super-init-not-called DeprecatedCommand.__init__(self) + + def _getParser(self): + op = FC6_Monitor._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F10) + return op + +class F18_Monitor(RemovedCommand, F10_Monitor): + def _getParser(self): + op = F10_Monitor._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F18) + return op diff --git a/mic/3rdparty/pykickstart/commands/mount.py b/mic/3rdparty/pykickstart/commands/mount.py new file mode 100644 index 0000000..b5c9d8b --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/mount.py @@ -0,0 +1,209 @@ +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Vratislav Podzimek <vpodzime@redhat.com> +# + +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser, mountpoint +from pykickstart.version import F27 + +from pykickstart.i18n import _ + +class F27_MountData(BaseData): + removedKeywords = BaseData.removedKeywords + removedAttrs = BaseData.removedAttrs + + def __init__(self, *args, **kwargs): + BaseData.__init__(self, *args, **kwargs) + self.mount_point = kwargs.get("mount_point", "") + self.device = kwargs.get("device", "") + self.format = kwargs.get("format", "") + self.reformat = kwargs.get("reformat", False) + self.mkfs_opts = kwargs.get("mkfs_opts", "") + self.mount_opts = kwargs.get("mount_opts", "") + + def __eq__(self, other): + if not other: + return False + + return self.mount_point == other.mount_point + + def __ne__(self, other): + return not self == other + + def _getArgsAsStr(self): + retval = "%s" % self.device + + retval += " %s" % self.mount_point or "none" + + if self.reformat: + retval += " --reformat" + if self.format: + retval += "=%s" % self.format + + if self.mkfs_opts: + retval += " --mkfsoptions=\"%s\"" % self.mkfs_opts + + if self.mount_opts: + retval += " --mountoptions=\"%s\"" % self.mount_opts + + return retval + + def __str__(self): + retval = BaseData.__str__(self) + retval += "mount %s\n" % self._getArgsAsStr() + return retval + + +class F27_Mount(KickstartCommand): + """The 'mount' kickstart command""" + + def __init__(self, *args, **kwargs): + KickstartCommand.__init__(self, *args, **kwargs) + self.op = self._getParser() + self.mount_points = kwargs.get("mount_points") or list() + + def __str__(self): + retval = KickstartCommand.__str__(self) + + for mpoint in self.mount_points: + retval += str(mpoint) + + if retval != "": + retval = "# Mount points configuration\n" + retval + "\n" + + return retval + + def _getParser(self): + op = KSOptionParser(prog="mount", description=""" + Assigns a mount point to a block device and + optionally reformats it to a given format. It at + least requires a device and a mount point where the + mount point can be ``none`` in case the format on + the device is not mountable or in case the device + should just be reformatted. + + The difference between this command and the other + commands for storage configuration (``part``, + ``logvol``,...) is that it doesn't require the whole + storage stack to be described in the kickstart + file. The user just needs to make sure that the + specified block device exists in the system. The + installer doesn't necessarily have to know all the + details about of the given device. If, on the other + hand, the installer is supposed to **create** the + storage stack with all the devices mounted at + various places, the ``part``, ``logvol``, ``raid``, + etc. commands have to be used. + """, version=F27) + + op.add_argument("device", metavar="<device>", nargs=1, version=F27, + help="""The block device to mount""") + op.add_argument("mntpoint", metavar="<mntpoint>", type=mountpoint, nargs=1, + version=F27, help=""" + The ``<mntpoint>`` is where the <device> will be + mounted. Must be a valid mount point, for example + ``/``, ``/usr``, ``/home``, or ``none`` if the device + cannot (e.g. swap) or should not be mounted.""") + + op.add_argument("--reformat", dest="reformat", nargs="?", version=F27, const=True, default=False, + help="Specifies the new format (e.g. a file system) for the device.") + op.add_argument("--mkfsoptions", dest="mkfs_opts", action="store", version=F27, + help=""" + Specifies additional parameters to be passed to the + program that makes a filesystem on this partition. No + processing is done on the list of arguments, so they + must be supplied in a format that can be passed directly + to the mkfs program. This means multiple options should + be comma-separated or surrounded by double quotes, + depending on the filesystem.""") + op.add_argument("--mountoptions", dest="mount_opts", action="store", version=F27, + help=""" + Specifies a free form string of options to be used when + mounting the filesystem. This string will be copied into + the /etc/fstab file of the installed system and should + be enclosed in quotes.""") + + return op + + def parse(self, args): + # the 'mount' command can't be used together with any other + # partitioning-related command + conflicting_command = None + + # seen indicates that the corresponding + # command has been seen in kickstart + if self.handler.autopart.seen: + conflicting_command = "autopart" + if self.handler.partition.seen: + conflicting_command = "part/partition" + elif self.handler.raid.seen: + conflicting_command = "raid" + elif self.handler.volgroup.seen: + conflicting_command = "volgroup" + elif self.handler.logvol.seen: + conflicting_command = "logvol" + elif hasattr(self.handler, "reqpart") and self.handler.reqpart.seen: + conflicting_command = "reqpart" + + if conflicting_command: + # allow for translation of the error message + errorMsg = _("The '%s' and 'mount' commands can't be used at the same time") % \ + conflicting_command + raise KickstartParseError(errorMsg, lineno=self.lineno) + + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if extra: + mapping = {"command": "mount", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + md = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, md) + md.lineno = self.lineno + md.device = ns.device[0] + md.mount_point = ns.mntpoint[0] + + if md.mount_point.lower() != "none" and not md.mount_point.startswith("/"): + raise KickstartParseError(_("Invalid mount point '%s' given") % md.mount_point, lineno=self.lineno) + + if md.reformat is False and md.mkfs_opts: + raise KickstartParseError(_("'--mkfsoptions' requires --reformat"), lineno=self.lineno) + + # The semantics is as follows: + # --reformat -> just reformat with the same format as existing + # --reformat=SOME_FMT -> reformat to given format + # no '--reformat' -> don't reformat + # + # md.reformat can either be 'False' (not specified), 'True' (just + # '--reformat') or a non-empty string ('--reformat=FORMAT'). Only the + # last case requires special treatment. + if md.reformat and md.reformat is not True: + # a new format given + md.format = md.reformat + md.reformat = True + + return md + + def dataList(self): + return self.mount_points + + @property + def dataClass(self): + return self.handler.MountData diff --git a/mic/3rdparty/pykickstart/commands/mouse.py b/mic/3rdparty/pykickstart/commands/mouse.py index d7ad1ae..2268327 100644 --- a/mic/3rdparty/pykickstart/commands/mouse.py +++ b/mic/3rdparty/pykickstart/commands/mouse.py @@ -17,12 +17,12 @@ # subject to the GNU General Public License and may only be used or replicated # with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import versionToLongString, RHEL3, FC3, F7 +from pykickstart.base import DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class RHEL3_Mouse(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -50,21 +50,38 @@ class RHEL3_Mouse(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--device", dest="device", default="") - op.add_option("--emulthree", dest="emulthree", default=False, action="store_true") + op = KSOptionParser(prog="mouse", description=""" + Configure the system mouse""", version=RHEL3) + op.add_argument("--device", default="", version=RHEL3, + help="Which device node to use for mouse") + op.add_argument("--emulthree", default=False, action="store_true", + version=RHEL3, help="If set emulate 3 mouse buttons") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) if len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s requires one argument") % "mouse")) + raise KickstartParseError(_("Kickstart command %s requires one argument") % "mouse", lineno=self.lineno) + elif any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "mouse", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + self.set_to_self(ns) self.mouse = extra[0] return self -class FC3_Mouse(DeprecatedCommand): - def __init__(self): +class FC3_Mouse(DeprecatedCommand, RHEL3_Mouse): + def __init__(self): # pylint: disable=super-init-not-called DeprecatedCommand.__init__(self) + + def _getParser(self): + op = RHEL3_Mouse._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(FC3) + return op + +class F7_Mouse(RemovedCommand, FC3_Mouse): + def _getParser(self): + op = FC3_Mouse._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F7) + return op diff --git a/mic/3rdparty/pykickstart/commands/multipath.py b/mic/3rdparty/pykickstart/commands/multipath.py index 4d5b26b..acb58bb 100644 --- a/mic/3rdparty/pykickstart/commands/multipath.py +++ b/mic/3rdparty/pykickstart/commands/multipath.py @@ -16,14 +16,14 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import versionToLongString, FC6, F24, F34 +from pykickstart.base import BaseData, DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC6_MpPathData(BaseData): removedKeywords = BaseData.removedKeywords @@ -34,6 +34,7 @@ class FC6_MpPathData(BaseData): self.mpdev = kwargs.get("mpdev", "") self.device = kwargs.get("device", "") self.rule = kwargs.get("rule", "") + self.name = "" def __str__(self): return " --device=%s --rule=\"%s\"" % (self.device, self.rule) @@ -51,7 +52,7 @@ class FC6_MultiPathData(BaseData): retval = BaseData.__str__(self) for path in self.paths: - retval += "multipath --mpdev=%s %s\n" % (self.name, path.__str__()) + retval += "multipath --name=%s%s\n" % (self.name, path.__str__()) return retval @@ -73,21 +74,20 @@ class FC6_MultiPath(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--name", dest="name", action="store", type="string", - required=1) - op.add_option("--device", dest="device", action="store", type="string", - required=1) - op.add_option("--rule", dest="rule", action="store", type="string", - required=1) + op = KSOptionParser(prog="multipath", description="define a multipath storage device", version=FC6) + op.add_argument("--name", required=True, version=FC6, help="multipath device name") + op.add_argument("--device", required=True, notest=True, + version=FC6, help="multipath device node") + op.add_argument("--rule", required=True, notest=True, + version=FC6, help="multipath device rule") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + ns = self.op.parse_args(args=args, lineno=self.lineno) dd = FC6_MpPathData() - self._setToObj(self.op, opts, dd) + self.set_to_obj(ns, dd) dd.lineno = self.lineno - dd.mpdev = dd.mpdev.split('/')[-1] + dd.mpdev = dd.name.split('/')[-1] parent = None for x in range(0, len(self.mpaths)): @@ -95,17 +95,37 @@ class FC6_MultiPath(KickstartCommand): for path in mpath.paths: if path.device == dd.device: mapping = {"device": path.device, "multipathdev": path.mpdev} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Device '%(device)s' is already used in multipath '%(multipathdev)s'") % mapping)) + raise KickstartParseError(_("Device '%(device)s' is already used in multipath '%(multipathdev)s'") % mapping, lineno=self.lineno) if mpath.name == dd.mpdev: parent = x - if parent is None: - mpath = FC6_MultiPathData() + if not parent: + mpath = self.dataClass(name=dd.name) # pylint: disable=not-callable + mpath.paths.append(dd) return mpath else: mpath = self.mpaths[parent] - - return dd + mpath.paths.append(dd) + return dd def dataList(self): return self.mpaths + + @property + def dataClass(self): + return self.handler.MultiPathData + +class F24_MultiPath(DeprecatedCommand, FC6_MultiPath): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = FC6_MultiPath._getParser(self) + op.description += "\n\n.. deprecated:: %s" % versionToLongString(F24) + return op + +class F34_MultiPath(RemovedCommand, F24_MultiPath): + def _getParser(self): + op = F24_MultiPath._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F34) + return op diff --git a/mic/3rdparty/pykickstart/commands/network.py b/mic/3rdparty/pykickstart/commands/network.py index 9b67f92..8b348e3 100644 --- a/mic/3rdparty/pykickstart/commands/network.py +++ b/mic/3rdparty/pykickstart/commands/network.py @@ -15,16 +15,21 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.errors import * -from pykickstart.options import * +from textwrap import dedent +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.version import versionToLongString, RHEL4, RHEL5, RHEL6, RHEL7 +from pykickstart.version import FC3, FC4, FC6, F8, F9, F16, F19, F20, F21, F22, F25, F27 +from pykickstart.constants import BOOTPROTO_BOOTP, BOOTPROTO_DHCP, BOOTPROTO_IBFT, BOOTPROTO_QUERY, BOOTPROTO_STATIC, BIND_TO_MAC +from pykickstart.options import KSOptionParser, ksboolean +from pykickstart.errors import KickstartParseError, KickstartParseWarning -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ + +MIN_VLAN_ID = 0 +MAX_VLAN_ID = 4095 class FC3_NetworkData(BaseData): removedKeywords = BaseData.removedKeywords @@ -48,38 +53,44 @@ class FC3_NetworkData(BaseData): self.wepkey = kwargs.get("wepkey", "") def __eq__(self, y): - return self.device and self.device == y.device + if not y: + return False + + return self.device == y.device + + def __ne__(self, y): + return not self == y def _getArgsAsStr(self): retval = "" - if self.bootProto != "": + if self.bootProto: retval += " --bootproto=%s" % self.bootProto - if self.dhcpclass != "": + if self.dhcpclass: retval += " --dhcpclass=%s" % self.dhcpclass - if self.device != "": + if self.device: retval += " --device=%s" % self.device - if self.essid != "": + if self.essid: retval += " --essid=\"%s\"" % self.essid - if self.ethtool != "": + if self.ethtool: retval += " --ethtool=\"%s\"" % self.ethtool - if self.gateway != "": + if self.gateway: retval += " --gateway=%s" % self.gateway - if self.hostname != "": + if self.hostname: retval += " --hostname=%s" % self.hostname - if self.ip != "": + if self.ip: retval += " --ip=%s" % self.ip - if self.mtu != "": + if self.mtu: retval += " --mtu=%s" % self.mtu - if self.nameserver != "": + if self.nameserver: retval += " --nameserver=%s" % self.nameserver - if self.netmask != "": + if self.netmask: retval += " --netmask=%s" % self.netmask if self.nodns: retval += " --nodns" if not self.onboot: retval += " --onboot=off" - if self.wepkey != "": + if self.wepkey: retval += " --wepkey=%s" % self.wepkey return retval @@ -135,8 +146,8 @@ class F8_NetworkData(FC6_NetworkData): def _getArgsAsStr(self): retval = FC6_NetworkData._getArgsAsStr(self) - if self.ipv6 != "": - retval += " --ipv6" % self.ipv6 + if self.ipv6: + retval += " --ipv6=%s" % self.ipv6 return retval @@ -146,7 +157,7 @@ class F16_NetworkData(F8_NetworkData): def __init__(self, *args, **kwargs): F8_NetworkData.__init__(self, *args, **kwargs) - self.activate = kwargs.get("activate", False) + self.activate = kwargs.get("activate", None) self.nodefroute = kwargs.get("nodefroute", False) self.wpakey = kwargs.get("wpakey", "") @@ -157,9 +168,116 @@ class F16_NetworkData(F8_NetworkData): retval += " --activate" if self.nodefroute: retval += " --nodefroute" - if self.wpakey != "": - retval += "--wpakey=%s" % self.wpakey + if self.wpakey: + retval += " --wpakey=%s" % self.wpakey + + return retval + +class F19_NetworkData(F16_NetworkData): + removedKeywords = F16_NetworkData.removedKeywords + removedAttrs = F16_NetworkData.removedAttrs + + def __init__(self, *args, **kwargs): + F16_NetworkData.__init__(self, *args, **kwargs) + self.bondslaves = kwargs.get("bondslaves", "") + self.bondopts = kwargs.get("bondopts", "") + self.vlanid = kwargs.get("vlanid", "") + self.ipv6gateway = kwargs.get("ipv6gateway", "") + + def _getArgsAsStr(self): + retval = F16_NetworkData._getArgsAsStr(self) + + if self.bondslaves: + retval += " --bondslaves=%s" % self.bondslaves + if self.bondopts: + retval += " --bondopts=%s" % self.bondopts + if self.vlanid: + retval += " --vlanid=%s" % self.vlanid + if self.ipv6gateway: + retval += " --ipv6gateway=%s" % self.ipv6gateway + + return retval + +class F20_NetworkData(F19_NetworkData): + removedKeywords = F19_NetworkData.removedKeywords + removedAttrs = F19_NetworkData.removedAttrs + + def __init__(self, *args, **kwargs): + F19_NetworkData.__init__(self, *args, **kwargs) + self.teamslaves = kwargs.get("teamslaves", []) + self.teamconfig = kwargs.get("teamconfig", "") + + def _getArgsAsStr(self): + retval = F19_NetworkData._getArgsAsStr(self) + + # see the tests for format description + if self.teamslaves: + slavecfgs = [] + for slave, config in self.teamslaves: + if config: + config = "'" + config + "'" + slavecfgs.append(slave + config) + slavecfgs = ",".join(slavecfgs).replace('"', r'\"') + retval += ' --teamslaves="%s"' % slavecfgs + if self.teamconfig: + retval += ' --teamconfig="%s"' % self.teamconfig.replace('"', r'\"') + return retval + +class F21_NetworkData(F20_NetworkData): + removedKeywords = F20_NetworkData.removedKeywords + removedAttrs = F20_NetworkData.removedAttrs + + def __init__(self, *args, **kwargs): + F20_NetworkData.__init__(self, *args, **kwargs) + self.interfacename = kwargs.get("interfacename", "") + + def _getArgsAsStr(self): + retval = F20_NetworkData._getArgsAsStr(self) + if self.interfacename: + retval += " --interfacename=%s" % self.interfacename + + return retval + +class F22_NetworkData(F21_NetworkData): + removedKeywords = F21_NetworkData.removedKeywords + removedAttrs = F21_NetworkData.removedAttrs + + def __init__(self, *args, **kwargs): + F21_NetworkData.__init__(self, *args, **kwargs) + self.bridgeslaves = kwargs.get("bridgeslaves", "") + self.bridgeopts = kwargs.get("bridgeopts", "") + + def _getArgsAsStr(self): + retval = F21_NetworkData._getArgsAsStr(self) + if self.bridgeslaves: + retval += " --bridgeslaves=%s" % self.bridgeslaves + if self.bridgeopts: + retval += " --bridgeopts=%s" % self.bridgeopts + + return retval + +class F25_NetworkData(F22_NetworkData): + removedKeywords = F22_NetworkData.removedKeywords + removedAttrs = F22_NetworkData.removedAttrs + + def _getArgsAsStr(self): + retval = F22_NetworkData._getArgsAsStr(self) + if self.activate == False: + retval += " --no-activate" + return retval +class F27_NetworkData(F25_NetworkData): + removedKeywords = F25_NetworkData.removedKeywords + removedAttrs = F25_NetworkData.removedAttrs + + def __init__(self, *args, **kwargs): + F25_NetworkData.__init__(self, *args, **kwargs) + self.bindto = kwargs.get("bindto", None) + + def _getArgsAsStr(self): + retval = F25_NetworkData._getArgsAsStr(self) + if self.bindto == BIND_TO_MAC: + retval += " --bindto=%s" % self.bindto return retval class RHEL4_NetworkData(FC3_NetworkData): @@ -184,8 +302,11 @@ class RHEL6_NetworkData(F8_NetworkData): def __init__(self, *args, **kwargs): F8_NetworkData.__init__(self, *args, **kwargs) - self.activate = kwargs.get("activate", False) + self.activate = kwargs.get("activate", None) self.nodefroute = kwargs.get("nodefroute", False) + self.vlanid = kwargs.get("vlanid", "") + self.bondslaves = kwargs.get("bondslaves", "") + self.bondopts = kwargs.get("bondopts", "") def _getArgsAsStr(self): retval = F8_NetworkData._getArgsAsStr(self) @@ -194,6 +315,35 @@ class RHEL6_NetworkData(F8_NetworkData): retval += " --activate" if self.nodefroute: retval += " --nodefroute" + if self.vlanid: + retval += " --vlanid=%s" % self.vlanid + if self.bondslaves: + retval += " --bondslaves=%s" % self.bondslaves + if self.bondopts: + retval += " --bondopts=%s" % self.bondopts + + return retval + +class RHEL7_NetworkData(F21_NetworkData): + removedKeywords = F21_NetworkData.removedKeywords + removedAttrs = F21_NetworkData.removedAttrs + + def __init__(self, *args, **kwargs): + F21_NetworkData.__init__(self, *args, **kwargs) + self.bridgeslaves = kwargs.get("bridgeslaves", "") + self.bridgeopts = kwargs.get("bridgeopts", "") + self.bindto = kwargs.get("bindto", None) + + def _getArgsAsStr(self): + retval = F21_NetworkData._getArgsAsStr(self) + if self.bridgeslaves: + retval += " --bridgeslaves=%s" % self.bridgeslaves + if self.bridgeopts: + retval += " --bridgeopts=%s" % self.bridgeopts + if self.activate == False: + retval += " --no-activate" + if self.bindto == BIND_TO_MAC: + retval += " --bindto=%s" % self.bindto return retval @@ -216,56 +366,128 @@ class FC3_Network(KickstartCommand): for nic in self.network: retval += nic.__str__() - if retval != "": + if retval: return "# Network information\n" + retval else: return "" def _getParser(self): - op = KSOptionParser() - op.add_option("--bootproto", dest="bootProto", - default=BOOTPROTO_DHCP, - choices=self.bootprotoList) - op.add_option("--dhcpclass", dest="dhcpclass") - op.add_option("--device", dest="device") - op.add_option("--essid", dest="essid") - op.add_option("--ethtool", dest="ethtool") - op.add_option("--gateway", dest="gateway") - op.add_option("--hostname", dest="hostname") - op.add_option("--ip", dest="ip") - op.add_option("--mtu", dest="mtu") - op.add_option("--nameserver", dest="nameserver") - op.add_option("--netmask", dest="netmask") - op.add_option("--nodns", dest="nodns", action="store_true", - default=False) - op.add_option("--onboot", dest="onboot", action="store", - type="ksboolean") - op.add_option("--wepkey", dest="wepkey") + op = KSOptionParser(prog="network", description=""" + Configures network information for target system + and activates network devices in installer + environment. The device specified in the first + network command is activated automatically. + Activation of the device can be also explicitly + required by ``--activate`` option""", version=FC3) + op.add_argument("--bootproto", dest="bootProto", version=FC3, + default=BOOTPROTO_DHCP, choices=self.bootprotoList, + help=""" + The method of IPv4 configuration. For IPv6 + configuration use ``--ipv6`` option. + + The default setting is ``dhcp``. To turn IPv4 + configuration off use ``--noipv4`` option. + + - The ``dhcp`` method uses a DHCP server system to obtain its networking configuration. + + - The ``static`` method requires that you specify at least IP address and netmask with ``--ip`` and ``--netmask`` options. + + For example:: + + ``network --device=link --bootproto=static --ip=10.0.2.15 --netmask=255.255.255.0 --gateway=10.0.2.254 --nameserver=10.0.2.1`` + + - ``ibft`` setting is for reading the configuration from iBFT table.""") + op.add_argument("--dhcpclass", version=FC3, help=""" + Specifies the DHCP vendor class identifier. The dhcpd + service will see this value as vendor-class-identifier.""") + op.add_argument("--device", version=FC3, help=""" + Specifies the device to be configured (and eventually + activated in Anaconda) with the network command. + + You can specify a device to be activated in any of the following ways: + + - the device name of the interface, for example, ``em1`` + - the MAC address of the interface, for example, ``01:23:45:67:89:ab`` + - the keyword ``link``, which specifies the first interface with its link in the up state + - the keyword ``bootif``, which uses the MAC address that pxelinux set in the ``BOOTIF`` variable. Set ``IPAPPEND 2`` in your pxelinux.cfg file to have pxelinux set the ``BOOTIF`` variable. + + For example:: + + ``network --bootproto=dhcp --device=ens3`` + + If the ``--device=`` option is missing on the first use + of the network command, the value of the ``ksdevice=`` + Anaconda boot option is used, if available. If + ``ksdevice=`` is not set, ``link`` value is used. Note + that this is considered deprecated behavior; in most + cases, you should always specify a ``--device=`` for + every network command. The behavior of any subsequent + network command in the same Kickstart file is + unspecified if its ``--device=`` option is missing. + Make sure you specify this option for any network + command beyond the first. + """) + op.add_argument("--essid", version=FC3, + help="The network ID for wireless networks.") + op.add_argument("--ethtool", version=FC3, help=""" + Specifies additional low-level settings for the network + device which will be passed to the ethtool program.""") + op.add_argument("--gateway", version=FC3, + help="Default gateway, as a single IPv4 address.") + op.add_argument("--hostname", version=FC3, + help=""" + The host name for the installed system. + + The host name can either be a fully-qualified domain + name (FQDN) in the format hostname.domainname, or a + short host name with no domain. Many networks have a + DHCP service which automatically supplies connected + systems with a domain name; to allow DHCP to assign the + domain name, only specify a short host name.""") + op.add_argument("--ip", version=FC3, + help="IPv4 address for the interface.") + op.add_argument("--mtu", version=FC3, help="The MTU of the device.") + op.add_argument("--nameserver", version=FC3, help=""" + Primary nameserver, as an IP address. Multiple + nameservers must be comma separated.""") + op.add_argument("--netmask", version=FC3, + help="IPv4 network mask of the device.") + op.add_argument("--nodns", action="store_true", default=False, + version=FC3, help="Do not configure any DNS server.") + op.add_argument("--onboot", type=ksboolean, version=FC3, help=""" + Whether or not to enable the device a boot time.""") + op.add_argument("--wepkey", version=FC3, + help="The WEP encryption key for wireless networks.") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - nd = self.handler.NetworkData() - self._setToObj(self.op, opts, nd) + ns = self.op.parse_args(args=args, lineno=self.lineno) + nd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, nd) nd.lineno = self.lineno # Check for duplicates in the data list. if nd in self.dataList(): - warnings.warn(_("A network device with the name %s has already been defined.") % nd.device) + warnings.warn(_("A network device with the name %s has already been defined.") % nd.device, KickstartParseWarning) return nd def dataList(self): return self.network + @property + def dataClass(self): + return self.handler.NetworkData + class FC4_Network(FC3_Network): removedKeywords = FC3_Network.removedKeywords removedAttrs = FC3_Network.removedAttrs def _getParser(self): op = FC3_Network._getParser(self) - op.add_option("--notksdevice", dest="notksdevice", action="store_true", - default=False) + op.add_argument("--notksdevice", action="store_true", default=False, + version=FC4, help=""" + This network device is not used for kickstart.""") return op class FC6_Network(FC4_Network): @@ -274,10 +496,10 @@ class FC6_Network(FC4_Network): def _getParser(self): op = FC4_Network._getParser(self) - op.add_option("--noipv4", dest="noipv4", action="store_true", - default=False) - op.add_option("--noipv6", dest="noipv6", action="store_true", - default=False) + op.add_argument("--noipv4", action="store_true", default=False, + version=FC6, help="Disable IPv4 configuration of this device.") + op.add_argument("--noipv6", action="store_true", default=False, + version=FC6, help="Disable IPv6 configuration of this device.") return op class F8_Network(FC6_Network): @@ -286,7 +508,12 @@ class F8_Network(FC6_Network): def _getParser(self): op = FC6_Network._getParser(self) - op.add_option("--ipv6", dest="ipv6") + op.add_argument("--ipv6", version=F8, help=""" + IPv6 address for the interface. This can be: + - the static address in form ``<IPv6 address>[/<prefix length>]``, e.g. ``3ffe:ffff:0:1::1/128`` (if prefix is omitted 64 is assumed), + - ``auto`` for stateless automatic address autoconfiguration, or + - ``dhcp`` for DHCPv6-only configuration (no router advertisements). + """) return op class F9_Network(F8_Network): @@ -299,9 +526,14 @@ class F9_Network(F8_Network): def _getParser(self): op = F8_Network._getParser(self) - op.add_option("--bootproto", dest="bootProto", - default=BOOTPROTO_DHCP, - choices=self.bootprotoList) + for action in op._actions: + if "--bootproto" in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + The 'query' value was added.""" % versionToLongString(F9)) + break return op class F16_Network(F9_Network): @@ -314,21 +546,292 @@ class F16_Network(F9_Network): def _getParser(self): op = F9_Network._getParser(self) - op.add_option("--activate", dest="activate", action="store_true", - default=False) - op.add_option("--nodefroute", dest="nodefroute", action="store_true", - default=False) - op.add_option("--wpakey", dest="wpakey", action="store", default="") + for action in op._actions: + if "--bootproto" in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + The 'ibft' value was added.""" % versionToLongString(F16)) + break + op.add_argument("--activate", action="store_true", version=F16, + default=None, help=""" + As noted above, using this option ensures any matching + devices beyond the first will also be activated.""") + op.add_argument("--nodefroute", action="store_true", version=F16, + default=False, help=""" + Prevents grabbing of the default route by the device. + It can be useful when activating additional devices in + installer using ``--activate`` option.""") + op.add_argument("--wpakey", default="", version=F16, help=""" + The WPA encryption key for wireless networks.""") return op +class F18_Network(F16_Network): + + @property + def hostname(self): + for nd in self.dataList(): + if nd.hostname: + return nd.hostname + return None + +class F19_Network(F18_Network): + + def _getParser(self): + op = F18_Network._getParser(self) + op.add_argument("--bondslaves", default="", version=F19, help=""" + Bonded device with name specified by ``--device`` option + will be created using slaves specified in this option. + Example:: + + ``network --device bond0 --bootproto static --ip=10.34.102.222 --netmask=255.255.255.0 --gateway=10.34.102.254 --nameserver=10.34.39.2 --bondslaves=ens7,ens8 --bondopts=mode=active-backup,primary=ens7 --activate`` + """) + op.add_argument("--bondopts", default="", version=F19, help=""" + A comma-separated list of optional parameters for bonded + interface specified by ``--bondslaves`` and ``--device`` + options. Example:: + + ``--bondopts=mode=active-backup,primary=eth1`` + + If an option itself contains comma as separator use + semicolon to separate the options. Example:: + + ``--bondopts=mode=active-backup,balance-rr;primary=eth1`` + """) + op.add_argument("--vlanid", version=F19, help=""" + Id (802.1q tag) of vlan device to be created using parent + device specified by ``--device`` option. For example:: + + ``network --device=eth0 --vlanid=171`` + + will create vlan device ``eth0.171``.""") + op.add_argument("--ipv6gateway", default="", version=F19, help=""" + Default gateway, as a single IPv6 address. + """) + return op + +class F20_Network(F19_Network): + + def _getParser(self): + # see the tests for teamslaves option + def teamslaves_cb(value): + # value is of: "<DEV1>['<JSON_CONFIG1>'],<DEV2>['<JSON_CONFIG2>'],..." + # for example: "eth1,eth2'{"prio": 100}',eth3" + teamslaves = [] + if value: + # Although slaves, having optional config, are separated by "," + # first extract json configs because they can contain the "," + parts = value.split("'") + # parts == ['eth1,eth2', '{"prio": 100}', ',eth3'] + # ensure the list has even number of items for further zipping, + # for odd number of items + if len(parts) % 2 == 1: + # if the list ends with an empty string which must be a leftover + # from splitting string not ending with device eg + # "eth1,eth2'{"prio":100}'" + if not parts[-1]: + # just remove it + parts = parts[:-1] + # if not (our example), add empty config for the last device + else: + parts.append('') + # parts == ['eth1,eth2', '{"prio": 100}', ',eth3', ''] + # zip devices with their configs + it = iter(parts) + for devs, cfg in zip(it, it): + # first loop: + # devs == "eth1,eth2", cfg == '{"prio": 100}' + devs = devs.strip(',').split(',') + # devs == ["eth1", "eth2"] + # initialize config of all devs but the last one to empty + for d in devs[:-1]: + teamslaves.append((d, '')) + # teamslaves == [("eth1", '')] + # and set config of the last device + teamslaves.append((devs[-1], cfg)) + # teamslaves == [('eth1', ''), ('eth2', '{"prio": 100}'] + + return teamslaves + + op = F19_Network._getParser(self) + op.add_argument("--teamslaves", type=teamslaves_cb, version=F20, + help=""" + Team device with name specified by ``--device`` option + will be created using slaves specified in this option. + Slaves are separated by comma. A slave can be followed + by its configuration which is a single-quoted json format + string with double qoutes escaped by ``'\'`` character. + Example:: + + ``--teamslaves="p3p1'{\"prio\": -10, \"sticky\": true}',p3p2'{\"prio\": 100}'"``. + + See also ``--teamconfig`` option.""") + op.add_argument("--teamconfig", default="", version=F20, help=""" + Double-quoted team device configuration which is a json + format string with double quotes escaped with ``'\'`` + character. The device name is specified by ``--device`` + option and its slaves and their configuration by + ``--teamslaves`` option. Example:: + + ``network --device team0 --activate --bootproto static --ip=10.34.102.222 --netmask=255.255.255.0 --gateway=10.34.102.254 --nameserver=10.34.39.2 --teamslaves="p3p1'{\"prio\": -10, \"sticky\": true}',p3p2'{\"prio\": 100}'" --teamconfig="{\"runner\": {\"name\": \"activebackup\"}}"`` + """) + return op + +class F21_Network(F20_Network): + def _getParser(self): + op = F20_Network._getParser(self) + op.add_argument("--interfacename", default="", version=F21, help=""" + Specify a custom interface name for a virtual LAN + device. This option should be used when the default + name generated by the ``--vlanid=`` option is not + desirable. This option must be used along with + ``--vlanid=``. For example:: + + ``network --device=em1 --vlanid=171 --interfacename=vlan171`` + + The above command creates a virtual LAN interface named + ``vlan171`` on the em1 device with an ID of 171. The + interface name can be arbitrary (for example, + ``my-vlan``), but in specific cases, the following + conventions must be followed: + + If the name contains a dot (.), it must take the form + of NAME.ID. The NAME is arbitrary, but the ID must be + the VLAN ID. For example: ``em1.171`` or + ``my-vlan.171``. Names starting with vlan must take + the form of vlanID - for example: ``vlan171``.""") + return op + +class F22_Network(F21_Network): + def _getParser(self): + op = F21_Network._getParser(self) + op.add_argument("--bridgeslaves", default="", version=F22, help=""" + When this option is used, the network bridge with + device name specified using the ``--device=`` option + will be created and devices defined in the + ``--bridgeslaves=`` option will be added to the bridge. + For example:: + + ``network --device=bridge0 --bridgeslaves=em1``""") + op.add_argument("--bridgeopts", default="", version=F22, help=""" + An optional comma-separated list of parameters for the + bridged interface. Available values are ``stp``, + ``priority``, ``forward-delay``, ``hello-time``, + ``max-age``, and ``ageing-time``. For information about + these parameters, see the bridge setting table in the + nm-settings(5) man page or at + https://developer.gnome.org/NetworkManager/0.9/ref-settings.html. + """) + return op + + def parse(self, args): + # call the overridden command to do it's job first + retval = F21_Network.parse(self, args) + + if retval.bridgeopts: + if not retval.bridgeslaves: + msg = _("Option --bridgeopts requires --bridgeslaves to be specified") + raise KickstartParseError(msg, lineno=self.lineno) + opts = retval.bridgeopts.split(",") + for opt in opts: + _key, _sep, value = opt.partition("=") + if not value or "=" in value: + msg = _("Bad format of --bridgeopts, expecting key=value options separated by ','") + raise KickstartParseError(msg, lineno=self.lineno) + + return retval + +class F24_Network(F22_Network): + removedKeywords = F22_Network.removedKeywords + removedAttrs = F22_Network.removedAttrs + + def parse(self, args): + retval = F22_Network.parse(self, args) + + # If we specify noipv4 then we need to make sure bootproto is zero'ed + # out + if retval.noipv4: + retval.bootProto = "" + return retval + +class F25_Network(F24_Network): + removedKeywords = F24_Network.removedKeywords + removedAttrs = F24_Network.removedAttrs + + def _getParser(self): + op = F24_Network._getParser(self) + op.add_argument("--no-activate", default=None, version=F25, dest="activate", + action="store_false", help=""" + Use this option with first network command to prevent + activation of the device in istaller environment""") + return op + +class F27_Network(F25_Network): + removedKeywords = F25_Network.removedKeywords + removedAttrs = F25_Network.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + self.bind_to_choices = [BIND_TO_MAC] + F25_Network.__init__(self, writePriority, *args, **kwargs) + + def _getParser(self): + op = F25_Network._getParser(self) + op.add_argument("--bindto", dest="bindto", default=None, version=F27, + choices=self.bind_to_choices, help=""" + Optionally allows to specify how the connection + configuration created for the device should be bound. If + the option is not used, the connection binds to + interface name (``DEVICE`` value in ifcfg file). For + virtual devices (bond, team, bridge) it configures + binding of slaves. Not applicable to vlan devices. + + Note that this option is independent of how the + ``--device`` is specified. + + Currently only the value ``mac`` is suported. + ``--bindto=mac`` will bind the connection to MAC address + of the device (``HWADDR`` value in ifcfg file). + + For example:: + + ``network --device=01:23:45:67:89:ab --bootproto=dhcp --bindto=mac`` + + will bind the configuration of the device specified by + MAC address ``01:23:45:67:89:ab`` to its MAC address. + + ``network --device=01:23:45:67:89:ab --bootproto=dhcp`` + + will bind the configuration of the device specified by + MAC address ``01:23:45:67:89:ab`` to its interface name + (eg ``ens3``). + + ``network --device=ens3 --bootproto=dhcp --bindto=mac`` + + will bind the configuration of the device specified by + interface name ``ens3`` to its MAC address. + """) + return op + + def parse(self, args): + # call the overridden command to do it's job first + retval = F25_Network.parse(self, args) + + if retval.bindto == BIND_TO_MAC: + if retval.vlanid and not retval.bondopts: + msg = _("--bindto=%s is not supported for this type of device") % BIND_TO_MAC + raise KickstartParseError(msg, lineno=self.lineno) + + return retval + class RHEL4_Network(FC3_Network): removedKeywords = FC3_Network.removedKeywords removedAttrs = FC3_Network.removedAttrs def _getParser(self): op = FC3_Network._getParser(self) - op.add_option("--notksdevice", dest="notksdevice", action="store_true", - default=False) + op.add_argument("--notksdevice", action="store_true", default=False, + version=RHEL4, help="This network device is not used for kickstart.") return op class RHEL5_Network(FC6_Network): @@ -341,9 +844,14 @@ class RHEL5_Network(FC6_Network): def _getParser(self): op = FC6_Network._getParser(self) - op.add_option("--bootproto", dest="bootProto", - default=BOOTPROTO_DHCP, - choices=self.bootprotoList) + for action in op._actions: + if "--bootproto" in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + The 'query' value was added.""" % versionToLongString(RHEL5)) + break return op class RHEL6_Network(F9_Network): @@ -356,8 +864,188 @@ class RHEL6_Network(F9_Network): def _getParser(self): op = F9_Network._getParser(self) - op.add_option("--activate", dest="activate", action="store_true", - default=False) - op.add_option("--nodefroute", dest="nodefroute", action="store_true", - default=False) + for action in op._actions: + if "--bootproto" in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + The 'ibft' value was added.""" % versionToLongString(RHEL6)) + break + op.add_argument("--activate", action="store_true", version=RHEL6, + default=None, help=""" + Activate this device in the installation environment. + + If the device has already been activated (for example, + an interface you configured with boot options so that + the system could retrieve the Kickstart file) the + device is reactivated to use the configuration + specified in the Kickstart file.""") + op.add_argument("--nodefroute", action="store_true", version=RHEL6, + default=False, help=""" + Prevents the interface being set as the default route. + Use this option when you activate additional devices + with the ``--activate=`` option, for example, a NIC on + a separate subnet for an iSCSI target.""") + op.add_argument("--vlanid", version=RHEL6, help=""" + Id (802.1q tag) of vlan device to be created using parent + device specified by ``--device`` option. For example:: + + ``network --device=eth0 --vlanid=171`` + + will create vlan device ``eth0.171``.""") + op.add_argument("--bondslaves", version=RHEL6, help=""" + Bonded device with name specified by ``--device`` option + will be created using slaves specified in this option. + Example:: + + ``network --device bond0 --bootproto static --ip=10.34.102.222 --netmask=255.255.255.0 --gateway=10.34.102.254 --nameserver=10.34.39.2 --bondslaves=eth0,eth1 --bondopts=mode=active-backup,primary=eth0 --activate`` + + """) + op.add_argument("--bondopts", version=RHEL6, help=""" + A comma-separated list of optional parameters for bonded + interface specified by ``--bondslaves`` and ``--device`` + options. Example:: + + ``--bondopts=mode=active-backup,primary=eth1`` + + If an option itself contains comma as separator use + semicolon to separate the options. Example:: + + ``--bondopts=mode=active-backup,balance-rr;primary=eth1`` + """) return op + +def validate_network_interface_name(name): + """Check if the given network interface name is valid, return an error message + if an error is found or None if no errors are found + + :param str name: name to validate + :returns: error message or None if no error is found + :rtype: str or NoneType + """ + # (for reference see the NetworkManager source code: + # NetworkManager/src/settings/plugins/ifcfg-rh/reader.c + # and the make_vlan_setting function) + + vlan_id = None + + # if it contains '.', vlan id should follow (eg 'ens7.171', 'mydev.171') + (vlan, dot, id_candidate) = name.partition(".") + if dot: + # 'vlan' can't be followed by a '.' + if vlan == "vlan": + return _("When using the <prefix>.<vlan id> interface name notation, <prefix> can't be equal to 'vlan'.") + try: + vlan_id = int(id_candidate) + except ValueError: + return _("If network --interfacename contains a '.', valid vlan id should follow.") + + # if it starts with 'vlan', vlan id should follow ('vlan171') + (empty, sep, id_candidate) = name.partition("vlan") + if sep and empty == "": + # if we checked only for empty == "", we would evaluate missing interface name as an error + try: + vlan_id = int(id_candidate) + except ValueError: + return _("If network --interfacename starts with 'vlan', valid vlan id should follow.") + + # check if the vlan id is in range + if vlan_id is not None: + if not(MIN_VLAN_ID <= vlan_id <= MAX_VLAN_ID): + return _("The vlan id is out of the %(minimum)d-%(maximum)d vlan id range.") % {"minimum": MIN_VLAN_ID, "maximum": MAX_VLAN_ID} + + # network interface name seems to be valid (no error found) + return None + +class RHEL7_Network(F21_Network): + def __init__(self, writePriority=0, *args, **kwargs): + self.bind_to_choices = [BIND_TO_MAC] + F21_Network.__init__(self, writePriority, *args, **kwargs) + + def _getParser(self): + op = F21_Network._getParser(self) + op.add_argument("--bridgeslaves", default="", version=RHEL7, help=""" + When this option is used, the network bridge with + device name specified using the ``--device=`` option + will be created and devices defined in the + ``--bridgeslaves=`` option will be added to the bridge. + For example:: + + ``network --device=bridge0 --bridgeslaves=em1``""") + op.add_argument("--bridgeopts", default="", version=RHEL7, help=""" + An optional comma-separated list of parameters for the + bridged interface. Available values are ``stp``, + ``priority``, ``forward-delay``, ``hello-time``, + ``max-age``, and ``ageing-time``. For information about + these parameters, see the bridge setting table in the + nm-settings(5) man page or at + https://developer.gnome.org/NetworkManager/0.9/ref-settings.html. + """) + op.add_argument("--no-activate", default=None, version=RHEL7, dest="activate", + action="store_false", help=""" + Use this option with first network command to prevent + activation of the device in istaller environment""") + op.add_argument("--bindto", dest="bindto", default=None, version=RHEL7, + choices=self.bind_to_choices, help=""" + Optionally allows to specify how the connection + configuration created for the device should be bound. If + the option is not used, the connection binds to + interface name (``DEVICE`` value in ifcfg file). For + virtual devices (bond, team, bridge) it configures + binding of slaves. Not applicable to vlan devices. + + Note that this option is independent of how the + ``--device`` is specified. + + Currently only the value ``mac`` is suported. + ``--bindto=mac`` will bind the connection to MAC address + of the device (``HWADDR`` value in ifcfg file). + + For example:: + + ``network --device=01:23:45:67:89:ab --bootproto=dhcp --bindto=mac`` + + will bind the configuration of the device specified by + MAC address ``01:23:45:67:89:ab`` to its MAC address. + + ``network --device=01:23:45:67:89:ab --bootproto=dhcp`` + + will bind the configuration of the device specified by + MAC address ``01:23:45:67:89:ab`` to its interface name + (eg ``ens3``). + + ``network --device=ens3 --bootproto=dhcp --bindto=mac`` + + will bind the configuration of the device specified by + interface name ``ens3`` to its MAC address. + """) + return op + + def parse(self, args): + # call the overridden command to do it's job first + retval = F21_Network.parse(self, args) + + # validate the network interface name + error_message = validate_network_interface_name(retval.interfacename) + # something is wrong with the interface name + if error_message: + raise KickstartParseError(error_message, lineno=self.lineno) + + if retval.bridgeopts: + if not retval.bridgeslaves: + msg = _("Option --bridgeopts requires --bridgeslaves to be specified") + raise KickstartParseError(msg, lineno=self.lineno) + opts = retval.bridgeopts.split(",") + for opt in opts: + _key, _sep, value = opt.partition("=") + if not value or "=" in value: + msg = _("Bad format of --bridgeopts, expecting key=value options separated by ','") + raise KickstartParseError(msg, lineno=self.lineno) + + if retval.bindto == BIND_TO_MAC: + if retval.vlanid and not retval.bondopts: + msg = _("--bindto=%s is not supported for this type of device") % BIND_TO_MAC + raise KickstartParseError(msg, lineno=self.lineno) + + return retval diff --git a/mic/3rdparty/pykickstart/commands/nfs.py b/mic/3rdparty/pykickstart/commands/nfs.py new file mode 100644 index 0000000..7536668 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/nfs.py @@ -0,0 +1,106 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2007, 2009, 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import FC3, FC6 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser + +class FC3_NFS(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.server = kwargs.get("server", None) + self.dir = kwargs.get("dir", None) + + self.op = self._getParser() + + def __eq__(self, other): + if not other: + return False + + return self.server == other.server and self.dir == other.dir + + def __ne__(self, other): + return not self == other + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use NFS installation media\nnfs --server=%s --dir=%s\n" % (self.server, self.dir) + return retval + + def _getParser(self): + op = KSOptionParser(prog="nfs", description=""" + Install from the NFS server specified. This can + either be an exploded installation tree or a + directory of ISO images. In the latter case, the + install.img must also be provided subject to the + same rules as with the harddrive installation + method described above.""", version=FC3) + op.add_argument("--server", metavar="<hostname>", required=True, + version=FC3, help=""" + Server from which to install (hostname or IP).""") + op.add_argument("--dir", metavar="<directory>", required=True, + version=FC3, help=""" + Directory containing the ``Packages/`` directory of the + installation tree. If doing an ISO install, this + directory must also contain images/install.img.""") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + return self + +class FC6_NFS(FC3_NFS): + removedKeywords = FC3_NFS.removedKeywords + removedAttrs = FC3_NFS.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + FC3_NFS.__init__(self, writePriority, *args, **kwargs) + self.opts = kwargs.get("opts", None) + + def __eq__(self, other): + if not FC3_NFS.__eq__(self, other): + return False + + return self.opts == other.opts + + def __str__(self): + retval = FC3_NFS.__str__(self) + + if self.seen and self.opts: + retval = retval.rstrip() + retval += " --opts=\"%s\"\n" % self.opts + + return retval + + def _getParser(self): + op = FC3_NFS._getParser(self) + op.add_argument("--opts", metavar="<options>", version=FC6, help=""" + Mount options to use for mounting the NFS export. Any + options that can be specified in ``/etc/fstab`` for an NFS + mount are allowed. The options are listed in the ``nfs(5)`` + man page. Multiple options are separated with a comma. + """) + return op diff --git a/mic/3rdparty/pykickstart/commands/nvdimm.py b/mic/3rdparty/pykickstart/commands/nvdimm.py new file mode 100644 index 0000000..a01652f --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/nvdimm.py @@ -0,0 +1,172 @@ +# +# Radek Vykydal <rvykydal@redhat.com> +# +# Copyright 2018 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# + +import warnings +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser, commaSplit +from pykickstart.constants import NVDIMM_MODE_SECTOR, NVDIMM_ACTION_RECONFIGURE, \ + NVDIMM_ACTION_USE +from pykickstart.version import F28 + +from pykickstart.i18n import _ + + +class F28_NvdimmData(BaseData): + removedKeywords = BaseData.removedKeywords + removedAttrs = BaseData.removedAttrs + + def __init__(self, *args, **kwargs): + BaseData.__init__(self, *args, **kwargs) + self.action = kwargs.get("action", None) + self.namespace = kwargs.get("namespace", "") + self.mode = kwargs.get("mode", None) + self.sectorsize = kwargs.get("sectorsize", None) + self.blockdevs = kwargs.get("blockdevs", []) + + def __eq__(self, y): + if not y: + return False + return (self.action == y.action and + self.namespace == y.namespace and + self.blockdevs == y.blockdevs) + + def __ne__(self, y): + return not self == y + + def _getArgsAsStr(self): + retval = "%s" % self.action + if self.action == NVDIMM_ACTION_RECONFIGURE: + if self.namespace: + retval += " --namespace=%s" % self.namespace + if self.mode == NVDIMM_MODE_SECTOR: + retval += " --mode=%s" % NVDIMM_MODE_SECTOR + if self.sectorsize: + retval += " --sectorsize=%d" % self.sectorsize + elif self.action == NVDIMM_ACTION_USE: + if self.namespace: + retval += " --namespace=%s" % self.namespace + if self.blockdevs: + retval += " --blockdevs=%s" % ",".join(self.blockdevs) + + return retval + + def __str__(self): + retval = BaseData.__str__(self) + retval += "nvdimm %s" % self._getArgsAsStr() + return retval.strip() + "\n" + + +class F28_Nvdimm(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=80, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + + self.actionList = kwargs.get("actionList", []) + self.validActions = [NVDIMM_ACTION_RECONFIGURE, NVDIMM_ACTION_USE] + self.validModes = [NVDIMM_MODE_SECTOR] + + self.op = self._getParser() + + def __str__(self): + retval = "" + + for action in self.actionList: + retval += action.__str__() + + if retval != "": + retval = "# NVDIMM devices setup\n" + retval + "\n" + + return retval + + def _getParser(self): + op = KSOptionParser(prog="nvdimm", version=F28, description=""" + Perform an action on an nvdimm device.""") + op.add_argument("action", choices=self.validActions, nargs=1, default=NVDIMM_ACTION_RECONFIGURE, + version=F28, help=""" + The action to be performed on the device specified by further options. + The device can be specified by ``--namespace`` or ``--blockdevs`` options, + depending on the action. + + Valid actions: + - ``reconfigure``: Reconfigures the device specified by ``--namespace`` + into the mode specified by ``--mode`` and (depending on the mode) + ``--sectorsize`` options. The device reconfigured into sector mode + will be allowed to be used for storage configuration. + - ``use``: Allow the device to be used for storage configuration. By default nvdimm + devices are ignored. Only devices in sector mode can be used. + """) + op.add_argument("--namespace", metavar="<namespace>", version=F28, + help="""The device specification by namespace.""") + op.add_argument("--blockdevs", metavar="<devspec1>,<devspec2>,...,<devspecN>", type=commaSplit, version=F28, + help="""Specification of devices by comma separated list of block device names.""") + op.add_argument("--mode", choices=self.validModes, default=NVDIMM_MODE_SECTOR, + version=F28, help="""The mode specification.""") + op.add_argument("--sectorsize", type=int, version=F28, + help="""Size of a sector for sector mode.""") + return op + + def parse(self, args): + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if extra: + raise KickstartParseError(_("Unexpected arguments to nvdimm command: %(arguments)s") % + {"arguments": extra}, lineno=self.lineno) + + nvdimm_data = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, nvdimm_data) + nvdimm_data.lineno = self.lineno + action = ns.action[0] + nvdimm_data.action = action + + if nvdimm_data.namespace and nvdimm_data.blockdevs: + raise KickstartParseError(_("Only one of --namespace and --blockdevs device specifications can be used")) + + # Check for duplicates in the data list. + if nvdimm_data in self.dataList(): + if nvdimm_data.namespace: + warnings.warn(_("An action %(action)s on namespace %(namespace)s has already been defined.") + % {"action": action, "namespace": nvdimm_data.namespace}, KickstartParseWarning) + if nvdimm_data.blockdevs: + warnings.warn(_("An action %(action)s on devices %(blockdevs)s has already been defined.") + % {"action": action, "blockdevs": nvdimm_data.blockdevs}, KickstartParseWarning) + + if action == NVDIMM_ACTION_RECONFIGURE: + if not nvdimm_data.namespace: + raise KickstartParseError(_("Action %(action)s requires --namespace argument to be set") + % {"action": action}) + if nvdimm_data.mode == NVDIMM_MODE_SECTOR and not nvdimm_data.sectorsize: + raise KickstartParseError(_("Action %(action)s with mode %(mode)s requires --sectorsize argument to be set") + % {"action": action, "mode": nvdimm_data.mode}) + elif action == NVDIMM_ACTION_USE: + if not nvdimm_data.namespace and not nvdimm_data.blockdevs: + raise KickstartParseError(_("Action %(action)s requires --namespace or --blockdevs argument to be set") + % {"action": action}) + + return nvdimm_data + + def dataList(self): + return self.actionList + + @property + def dataClass(self): + return self.handler.NvdimmData diff --git a/mic/3rdparty/pykickstart/commands/ostreesetup.py b/mic/3rdparty/pykickstart/commands/ostreesetup.py new file mode 100644 index 0000000..27e9463 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/ostreesetup.py @@ -0,0 +1,95 @@ +# +# Copyright (C) 2014 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +from pykickstart.version import F21 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +class F21_OSTreeSetup(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, *args, **kwargs): + KickstartCommand.__init__(self, *args, **kwargs) + self.op = self._getParser() + self.osname = kwargs.get('osname', None) + self.remote = kwargs.get("remote", self.osname) + self.url = kwargs.get('url', None) + self.ref = kwargs.get('ref', None) + self.nogpg = kwargs.get('nogpg', False) + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.osname: + retval += "# OSTree setup\n" + retval += "ostreesetup %s\n" % self._getArgsAsStr() + + return retval + + def _getArgsAsStr(self): + retcmd = [] + if self.osname: + retcmd.append('--osname="%s"' % self.osname) + if self.remote: + retcmd.append('--remote="%s"' % self.remote) + if self.url: + retcmd.append('--url="%s"' % self.url) + if self.ref: + retcmd.append('--ref="%s"' % self.ref) + if self.nogpg: + retcmd.append('--nogpg') + return ' '.join(retcmd) + + def _getParser(self): + op = KSOptionParser(prog="ostreesetup", description=""" + Used for OSTree installations. See + https://wiki.gnome.org/action/show/Projects/OSTree + for more information about OSTree. + """, version=F21) + op.add_argument("--osname", required=True, version=F21, help=""" + Management root for OS installation.""") + op.add_argument("--remote", version=F21, help=""" + Management root for OS installation.""") + op.add_argument("--url", required=True, version=F21, help=""" + Repository URL.""") + op.add_argument("--ref", required=True, version=F21, help=""" + Name of branch inside the repository.""") + op.add_argument("--nogpg", action="store_true", version=F21, help=""" + Disable GPG key verification.""") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + if not self.remote: + self.remote = self.osname + + if not self.url.startswith(("file:", "http:", "https:")): + raise KickstartParseError("ostree repos must use file, HTTP or HTTPS protocol.", lineno=self.lineno) + + return self + +class RHEL7_OSTreeSetup(F21_OSTreeSetup): + pass + +class RHEL8_OSTreeSetup(F21_OSTreeSetup): + pass + +class RHEL9_OSTreeSetup(F21_OSTreeSetup): + pass diff --git a/mic/3rdparty/pykickstart/commands/partition.py b/mic/3rdparty/pykickstart/commands/partition.py index 5dbd4d4..703f290 100755..100644 --- a/mic/3rdparty/pykickstart/commands/partition.py +++ b/mic/3rdparty/pykickstart/commands/partition.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005, 2006, 2007, 2008 Red Hat, Inc. +# Copyright 2005, 2006, 2007, 2008, 2012 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,15 +15,16 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import RHEL5, RHEL6, RHEL8, versionToLongString +from pykickstart.version import FC3, FC4, F9, F11, F12, F14, F17, F18, F23, F29, F34 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser, mountpoint -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_PartData(BaseData): removedKeywords = BaseData.removedKeywords @@ -47,11 +48,16 @@ class FC3_PartData(BaseData): self.mountpoint = kwargs.get("mountpoint", "") def __eq__(self, y): + if not y: + return False if self.mountpoint: return self.mountpoint == y.mountpoint else: return False + def __ne__(self, y): + return not self == y + def _getArgsAsStr(self): retval = "" @@ -61,7 +67,7 @@ class FC3_PartData(BaseData): retval += " --asprimary" if hasattr(self, "end") and self.end != 0: retval += " --end=%s" % self.end - if self.fstype != "": + if self.fstype: retval += " --fstype=\"%s\"" % self.fstype if self.grow: retval += " --grow" @@ -69,11 +75,11 @@ class FC3_PartData(BaseData): retval += " --maxsize=%d" % self.maxSizeMB if not self.format: retval += " --noformat" - if self.onbiosdisk != "": + if self.onbiosdisk: retval += " --onbiosdisk=%s" % self.onbiosdisk - if self.disk != "": + if self.disk: retval += " --ondisk=%s" % self.disk - if self.onPart != "": + if self.onPart: retval += " --onpart=%s" % self.onPart if self.recommended: retval += " --recommended" @@ -109,9 +115,9 @@ class FC4_PartData(FC3_PartData): if hasattr(self, "bytesPerInode") and self.bytesPerInode != 0: retval += " --bytes-per-inode=%d" % self.bytesPerInode - if self.fsopts != "": + if self.fsopts: retval += " --fsoptions=\"%s\"" % self.fsopts - if self.label != "": + if self.label: retval += " --label=%s" % self.label if self.fslabel != "": retval += " --fslabel=%s" % self.fslabel @@ -133,7 +139,7 @@ class RHEL5_PartData(FC4_PartData): if self.encrypted: retval += " --encrypted" - if self.passphrase != "": + if self.passphrase: retval += " --passphrase=\"%s\"" % self.passphrase return retval @@ -155,12 +161,12 @@ class F9_PartData(FC4_PartData): def _getArgsAsStr(self): retval = FC4_PartData._getArgsAsStr(self) - if self.fsprofile != "": + if self.fsprofile: retval += " --fsprofile=\"%s\"" % self.fsprofile if self.encrypted: retval += " --encrypted" - if self.passphrase != "": + if self.passphrase: retval += " --passphrase=\"%s\"" % self.passphrase return retval @@ -182,7 +188,7 @@ class F12_PartData(F11_PartData): def _getArgsAsStr(self): retval = F11_PartData._getArgsAsStr(self) - if self.encrypted and self.escrowcert != "": + if self.encrypted and self.escrowcert: retval += " --escrowcert=\"%s\"" % self.escrowcert if self.backuppassphrase: @@ -190,7 +196,115 @@ class F12_PartData(F11_PartData): return retval -F14_PartData = F12_PartData +class RHEL6_PartData(F12_PartData): + removedKeywords = F12_PartData.removedKeywords + removedAttrs = F12_PartData.removedAttrs + + def __init__(self, *args, **kwargs): + F12_PartData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") + self.hibernation = kwargs.get("hibernation", False) + + def _getArgsAsStr(self): + retval = F12_PartData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher=\"%s\"" % self.cipher + if self.hibernation: + retval += " --hibernation" + + return retval + +class F14_PartData(F12_PartData): + pass + +class F17_PartData(F14_PartData): + removedKeywords = F14_PartData.removedKeywords + removedAttrs = F14_PartData.removedAttrs + + def __init__(self, *args, **kwargs): + F14_PartData.__init__(self, *args, **kwargs) + + self.resize = kwargs.get("resize", False) + + def _getArgsAsStr(self): + retval = F14_PartData._getArgsAsStr(self) + + if self.resize: + retval += " --resize" + + return retval + +class F18_PartData(F17_PartData): + removedKeywords = F17_PartData.removedKeywords + removedAttrs = F17_PartData.removedAttrs + + def __init__(self, *args, **kwargs): + F17_PartData.__init__(self, *args, **kwargs) + + self.hibernation = kwargs.get("hibernation", False) + self.cipher = kwargs.get("cipher", "") + + def _getArgsAsStr(self): + retval = F17_PartData._getArgsAsStr(self) + + if self.hibernation: + retval += " --hibernation" + + if self.encrypted and self.cipher: + retval += " --cipher=\"%s\"" % self.cipher + + return retval + +class F23_PartData(F18_PartData): + def __init__(self, *args, **kwargs): + F18_PartData.__init__(self, *args, **kwargs) + + self.mkfsopts = kwargs.get("mkfsoptions", "") or kwargs.get("mkfsopts", "") + + def _getArgsAsStr(self): + retval = F18_PartData._getArgsAsStr(self) + + if self.mkfsopts: + retval += " --mkfsoptions=\"%s\"" % self.mkfsopts + + return retval + +class RHEL7_PartData(F23_PartData): + pass + +class F29_PartData(F23_PartData): + def __init__(self, *args, **kwargs): + F23_PartData.__init__(self, *args, **kwargs) + self.luks_version = kwargs.get("luks_version", "") + self.pbkdf = kwargs.get("pbkdf", "") + self.pbkdf_memory = kwargs.get("pbkdf_memory", 0) + self.pbkdf_time = kwargs.get("pbkdf_time", 0) + self.pbkdf_iterations = kwargs.get("pbkdf_iterations", 0) + + def _getArgsAsStr(self): + retval = F23_PartData._getArgsAsStr(self) + + if self.encrypted and self.luks_version: + retval += " --luks-version=%s" % self.luks_version + + if self.encrypted and self.pbkdf: + retval += " --pbkdf=%s" % self.pbkdf + + if self.encrypted and self.pbkdf_memory: + retval += " --pbkdf-memory=%s" % self.pbkdf_memory + + if self.encrypted and self.pbkdf_time: + retval += " --pbkdf-time=%s" % self.pbkdf_time + + if self.encrypted and self.pbkdf_iterations: + retval += " --pbkdf-iterations=%s" % self.pbkdf_iterations + + return retval + +class RHEL8_PartData(F29_PartData): + pass class FC3_Partition(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -208,48 +322,92 @@ class FC3_Partition(KickstartCommand): for part in self.partitions: retval += part.__str__() - if retval != "": + if retval: return "# Disk partitioning information\n" + retval else: return "" def _getParser(self): - def part_cb (option, opt_str, value, parser): + def part_cb(value): if value.startswith("/dev/"): - parser.values.ensure_value(option.dest, value[5:]) + return value[5:] else: - parser.values.ensure_value(option.dest, value) - - op = KSOptionParser() - op.add_option("--active", dest="active", action="store_true", - default=False) - op.add_option("--asprimary", dest="primOnly", action="store_true", - default=False) - op.add_option("--end", dest="end", action="store", type="int", - nargs=1) - op.add_option("--fstype", "--type", dest="fstype") - op.add_option("--grow", dest="grow", action="store_true", default=False) - op.add_option("--maxsize", dest="maxSizeMB", action="store", type="int", - nargs=1) - op.add_option("--noformat", dest="format", action="store_false", - default=True) - op.add_option("--onbiosdisk", dest="onbiosdisk") - op.add_option("--ondisk", "--ondrive", dest="disk") - op.add_option("--onpart", "--usepart", dest="onPart", action="callback", - callback=part_cb, nargs=1, type="string") - op.add_option("--recommended", dest="recommended", action="store_true", - default=False) - op.add_option("--size", dest="size", action="store", type="int", - nargs=1) - op.add_option("--start", dest="start", action="store", type="int", - nargs=1) + return value + + op = KSOptionParser(prog="part|partition", description=""" + Creates a partition on the system. This command is + required. All partitions created will be formatted + as part of the installation process unless + ``--noformat`` and ``--onpart`` are used. + """, epilog=""" + If partitioning fails for any reason, diagnostic + messages will appear on virtual console 3.""", + version=FC3) + op.add_argument("--active", action="store_true", default=False, + version=FC3, help="Set partition as active") + op.add_argument("--asprimary", dest="primOnly", action="store_true", + default=False, version=FC3, help=""" + Forces automatic allocation of the partition as a primary + partition or the partitioning will fail. + + **TIP:** The ``--asprimary`` option only makes sense + with the MBR partitioning scheme and is ignored when the + GPT partitioning scheme is used.""") + op.add_argument("--start", type=int, version=FC3, help="REMOVED") + op.add_argument("--end", type=int, version=FC3, help="REMOVED") + op.add_argument("--fstype", "--type", dest="fstype", version=FC3, + help=""" + Sets the file system type for the partition. Valid + values include ext4, ext3, ext2, xfs, btrfs, swap, and + vfat. Other filesystems may be valid depending on + command line arguments passed to anaconda to enable + other filesystems.""") + op.add_argument("--grow", action="store_true", default=False, + version=FC3, help=""" + Tells the partition to grow to fill available space + (if any), or up to the maximum size setting. Note that + ``--grow`` is not supported for partitions containing a + RAID volume on top of them.""") + op.add_argument("--maxsize", dest="maxSizeMB", type=int, + version=FC3, help=""" + The maximum size in MiB the partition may grow to. + Specify an integer value here, and do not append any + units. This option is only relevant if ``--grow`` is + specified as well.""") + op.add_argument("--noformat", dest="format", version=FC3, + action="store_false", default=True, help=""" + Tells the installation program not to format the + partition, for use with the ``--onpart`` command.""") + op.add_argument("--onbiosdisk", version=FC3, help=""" + Forces the partition to be created on a particular disk + as discovered by the BIOS.""") + op.add_argument("--ondisk", "--ondrive", dest="disk", + version=FC3, help=""" + Forces the partition to be created on a particular disk. + """) + op.add_argument("--onpart", "--usepart", dest="onPart", type=part_cb, + version=FC3, help=""" + Put the partition on an already existing device. Use + ``--onpart=LABEL=name`` or ``--onpart=UUID=name`` to specify + a partition by label or uuid respectively. + + Anaconda may create partitions in any particular order, + so it is safer to use labels than absolute partition + names.""") + op.add_argument("--recommended", action="store_true", default=False, + version=FC3, help=""" + Determine the size of the partition automatically. + """) + op.add_argument("--size", type=int, version=FC3, help=""" + The minimum partition size in MiB. Specify an integer + value here and do not append any units.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) - pd = self.handler.PartData() - self._setToObj(self.op, opts, pd) + pd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, pd) pd.lineno = self.lineno if extra: pd.mountpoint = extra[0] @@ -257,72 +415,79 @@ class FC3_Partition(KickstartCommand): warnings.warn(_("A partition with the mountpoint %s has already been defined.") % pd.mountpoint) else: pd.mountpoint = None - return pd def dataList(self): return self.partitions + @property + def dataClass(self): + return self.handler.PartData + class FC4_Partition(FC3_Partition): removedKeywords = FC3_Partition.removedKeywords removedAttrs = FC3_Partition.removedAttrs - def __init__(self, writePriority=130, *args, **kwargs): - FC3_Partition.__init__(self, writePriority, *args, **kwargs) - - def part_cb (option, opt_str, value, parser): - if value.startswith("/dev/"): - parser.values.ensure_value(option.dest, value[5:]) - else: - parser.values.ensure_value(option.dest, value) - def _getParser(self): op = FC3_Partition._getParser(self) - op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store", - type="int", nargs=1) - op.add_option("--fsoptions", dest="fsopts") - op.add_option("--label", dest="label") - op.add_option("--fslabel", dest="fslabel") + op.add_argument("--bytes-per-inode", dest="bytesPerInode", type=int, + version=FC4, help="Specify the bytes/inode ratio.") + op.add_argument("--fsoptions", dest="fsopts", version=FC4, help=""" + Specifies a free form string of options to be used when + mounting the filesystem. This string will be copied into + the /etc/fstab file of the installed system and should + be enclosed in quotes.""") + op.add_argument("--label", version=FC4, help=""" + Specify the label to give to the filesystem to be made + on the partition. If the given label is already in use + by another filesystem, a new label will be created for + this partition.""") + op.add_argument("--fslabel", dest="fslabel", version=FC4, help=""" + label for file system.""") return op class RHEL5_Partition(FC4_Partition): removedKeywords = FC4_Partition.removedKeywords removedAttrs = FC4_Partition.removedAttrs - def __init__(self, writePriority=130, *args, **kwargs): - FC4_Partition.__init__(self, writePriority, *args, **kwargs) - - def part_cb (option, opt_str, value, parser): - if value.startswith("/dev/"): - parser.values.ensure_value(option.dest, value[5:]) - else: - parser.values.ensure_value(option.dest, value) - def _getParser(self): op = FC4_Partition._getParser(self) - op.add_option("--encrypted", action="store_true", default=False) - op.add_option("--passphrase") + op.add_argument("--encrypted", action="store_true", version=RHEL5, + default=False, help=""" + Specify that this partition should be encrypted.""") + op.add_argument("--passphrase", version=RHEL5, help=""" + Specify the passphrase to use when encrypting this + partition. Without the above --encrypted option, this + option does nothing. If no passphrase is specified, the + default system-wide one is used, or the installer will + stop and prompt if there is no default.""") return op class F9_Partition(FC4_Partition): removedKeywords = FC4_Partition.removedKeywords removedAttrs = FC4_Partition.removedAttrs - def __init__(self, writePriority=130, *args, **kwargs): - FC4_Partition.__init__(self, writePriority, *args, **kwargs) - - def part_cb (option, opt_str, value, parser): - if value.startswith("/dev/"): - parser.values.ensure_value(option.dest, value[5:]) - else: - parser.values.ensure_value(option.dest, value) - def _getParser(self): op = FC4_Partition._getParser(self) - op.add_option("--bytes-per-inode", deprecated=1) - op.add_option("--fsprofile") - op.add_option("--encrypted", action="store_true", default=False) - op.add_option("--passphrase") + op.add_argument("--bytes-per-inode", deprecated=F9) + op.add_argument("--fsprofile", version=F9, help=""" + Specifies a usage type to be passed to the program that + makes a filesystem on this partition. A usage type + defines a variety of tuning parameters to be used when + making a filesystem. For this option to work, the + filesystem must support the concept of usage types and + there must be a configuration file that lists valid + types. For ext2/3/4, this configuration file is + ``/etc/mke2fs.conf``.""") + op.add_argument("--encrypted", action="store_true", version=F9, + default=False, help=""" + Specify that this partition should be encrypted.""") + op.add_argument("--passphrase", version=F9, help=""" + Specify the passphrase to use when encrypting this + partition. Without the above --encrypted option, this + option does nothing. If no passphrase is specified, the + default system-wide one is used, or the installer will + stop and prompt if there is no default.""") return op class F11_Partition(F9_Partition): @@ -331,8 +496,8 @@ class F11_Partition(F9_Partition): def _getParser(self): op = F9_Partition._getParser(self) - op.add_option("--start", deprecated=1) - op.add_option("--end", deprecated=1) + op.add_argument("--start", deprecated=F11) + op.add_argument("--end", deprecated=F11) return op class F12_Partition(F11_Partition): @@ -341,17 +506,259 @@ class F12_Partition(F11_Partition): def _getParser(self): op = F11_Partition._getParser(self) - op.add_option("--escrowcert") - op.add_option("--backuppassphrase", action="store_true", default=False) + op.add_argument("--escrowcert", metavar="<url>", version=F12, help=""" + Load an X.509 certificate from ``<url>``. Store the + data encryption key of this partition, encrypted using + the certificate, as a file in ``/root``. Only relevant + if ``--encrypted`` is specified as well.""") + op.add_argument("--backuppassphrase", action="store_true", version=F12, + default=False, help=""" + Only relevant if ``--escrowcert`` is specified as well. + In addition to storing the data encryption key, generate + a random passphrase and add it to this partition. Then + store the passphrase, encrypted using the certificate + specified by ``--escrowcert``, as a file in ``/root``. + If more than one LUKS volume uses ``--backuppassphrase``, + the same passphrase will be used for all such volumes. + """) + return op + +class RHEL6_Partition(F12_Partition): + removedKeywords = F12_Partition.removedKeywords + removedAttrs = F12_Partition.removedAttrs + + def _getParser(self): + op = F12_Partition._getParser(self) + op.add_argument("--cipher", version=RHEL6, help=""" + Only relevant if ``--encrypted`` is specified. + Specifies which encryption algorithm should be used to + encrypt the filesystem.""") + op.add_argument("--hibernation", action="store_true", default=False, + version=RHEL6, help=""" + This option can be used to automatically determine the + size of the swap partition big enough for hibernation. + """) return op + def parse(self, args): + # first call the overriden command + retval = F12_Partition.parse(self, args) + # the part command can't be used together with the autopart command + # due to the hard to debug behavior their combination introduces + if self.handler.autopart.seen: + errorMsg = _("The part/partition and autopart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + return retval + class F14_Partition(F12_Partition): removedKeywords = F12_Partition.removedKeywords removedAttrs = F12_Partition.removedAttrs def _getParser(self): op = F12_Partition._getParser(self) - op.remove_option("--bytes-per-inode") - op.remove_option("--start") - op.remove_option("--end") + op.remove_argument("--bytes-per-inode", version=F14) + op.remove_argument("--start", version=F14) + op.remove_argument("--end", version=F14) + return op + +class F17_Partition(F14_Partition): + removedKeywords = F14_Partition.removedKeywords + removedAttrs = F14_Partition.removedAttrs + + def _getParser(self): + op = F14_Partition._getParser(self) + op.add_argument("--resize", action="store_true", version=F17, + default=False, help=""" + Attempt to resize this partition to the size given by + ``--size=``. This option must be used with + ``--onpart --size=``, or an error will be raised.""") + return op + + def parse(self, args): + retval = F14_Partition.parse(self, args) + + if retval.resize and not retval.onPart: + raise KickstartParseError(_("--resize can only be used in conjunction with --onpart"), lineno=self.lineno) + + if retval.resize and not retval.size: + raise KickstartParseError(_("--resize requires --size to specify new size"), lineno=self.lineno) + + return retval + +class F18_Partition(F17_Partition): + removedKeywords = F17_Partition.removedKeywords + removedAttrs = F17_Partition.removedAttrs + + def _getParser(self): + op = F17_Partition._getParser(self) + op.add_argument("--hibernation", action="store_true", default=False, + version=F18, help=""" + This option can be used to automatically determine the + size of the swap partition big enough for hibernation. + """) + op.add_argument("--cipher", version=F18, help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which encryption algorithm should be used to encrypt the + filesystem.""") + return op + +class F20_Partition(F18_Partition): + removedKeywords = F18_Partition.removedKeywords + removedAttrs = F18_Partition.removedAttrs + + def parse(self, args): + # first call the overriden command + retval = F18_Partition.parse(self, args) + # the part command can't be used together with the autopart command + # due to the hard to debug behavior their combination introduces + if self.handler.autopart.seen: + errorMsg = _("The part/partition and autopart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + # the same applies to the 'mount' command + if hasattr(self.handler, "mount") and self.handler.mount.seen: + errorMsg = _("The part/partition and mount commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + # when using tmpfs, grow is not suported + if retval.fstype == "tmpfs": + if retval.grow or retval.maxSizeMB != 0: + errorMsg = _("The --fstype=tmpfs option can't be used together with --grow or --maxsize") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + return retval + +class F23_Partition(F20_Partition): + removedKeywords = F20_Partition.removedKeywords + removedAttrs = F20_Partition.removedAttrs + + def _getParser(self): + op = F20_Partition._getParser(self) + op.add_argument("--mkfsoptions", dest="mkfsopts", version=F23, help=""" + Specifies additional parameters to be passed to the + program that makes a filesystem on this partition. This + is similar to ``--fsprofile`` but works for all + filesystems, not just the ones that support the profile + concept. No processing is done on the list of arguments, + so they must be supplied in a format that can be passed + directly to the mkfs program. This means multiple + options should be comma-separated or surrounded by + double quotes, depending on the filesystem.""") + return op + + def parse(self, args): + retval = F20_Partition.parse(self, args) + + if not retval.format and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions with --noformat has no effect."), lineno=self.lineno) + + if retval.fsprofile and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions and --fsprofile cannot be used together."), lineno=self.lineno) + + return retval + +class RHEL7_Partition(F23_Partition): + pass + +class F29_Partition(F23_Partition): + removedKeywords = F23_Partition.removedKeywords + removedAttrs = F23_Partition.removedAttrs + + def _getParser(self): + op = F23_Partition._getParser(self) + op.add_argument("--active", action="store_true", default=False, + deprecated=F29, help="") + op.add_argument("--luks-version", dest="luks_version", version=F29, default="", + help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which version of LUKS format should be used to encrypt + the filesystem.""") + op.add_argument("--pbkdf", version=F29, default="", help=""" + Only relevant if ``--encrypted`` is specified. Sets + Password-Based Key Derivation Function (PBKDF) algorithm + for LUKS keyslot. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-memory", dest="pbkdf_memory", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the memory cost for PBKDF. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-time", dest="pbkdf_time", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of milliseconds to spend with PBKDF passphrase + processing. See ``--iter-time`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) + op.add_argument("--pbkdf-iterations", dest="pbkdf_iterations", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of iterations directly and avoids PBKDF benchmark. + See ``--pbkdf-force-iterations`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) + return op + + def parse(self, args): + retval = F23_Partition.parse(self, args) + + if retval.pbkdf_time and retval.pbkdf_iterations: + msg = _("Only one of --pbkdf-time and --pbkdf-iterations can be specified.") + raise KickstartParseError(msg, lineno=self.lineno) + + return retval + +class RHEL8_Partition(F29_Partition): + removedKeywords = F29_Partition.removedKeywords + removedAttrs = F29_Partition.removedAttrs + + def parse(self, args): + retval = F29_Partition.parse(self, args) + if retval.mountpoint.startswith("btrfs.") or retval.fstype == "btrfs": + raise KickstartParseError(_("Btrfs file system is not supported"), lineno=self.lineno) + return retval + + def _getParser(self): + "Only necessary for the type change documentation" + op = F29_Partition._getParser(self) + for action in op._actions: + if "--fstype" in action.option_strings: + action.help += """ + + .. versionchanged:: %s + + Btrfs support was removed.""" % versionToLongString(RHEL8) + return op + +class F34_Partition(F29_Partition): + removedKeywords = F29_Partition.removedKeywords + removedAttrs = F29_Partition.removedAttrs + + def _getParser(self): + op = F29_Partition._getParser(self) + op.remove_argument("--active", version=F34) + return op + + +class RHEL9_Partition(F34_Partition): + removedKeywords = F34_Partition.removedKeywords + removedAttrs = F34_Partition.removedAttrs + + def parse(self, args): + retval = F34_Partition.parse(self, args) + if retval.mountpoint.startswith("btrfs.") or retval.fstype == "btrfs": + raise KickstartParseError(_("Btrfs file system is not supported"), lineno=self.lineno) + return retval + + def _getParser(self): + "Only necessary for the type change documentation" + op = F34_Partition._getParser(self) + for action in op._actions: + if "--fstype" in action.option_strings: + action.help += """ + + .. versionchanged:: %s + + Btrfs support was removed.""" % versionToLongString(RHEL8) return op diff --git a/mic/3rdparty/pykickstart/commands/raid.py b/mic/3rdparty/pykickstart/commands/raid.py index adf3524..7c00ea5 100644 --- a/mic/3rdparty/pykickstart/commands/raid.py +++ b/mic/3rdparty/pykickstart/commands/raid.py @@ -15,15 +15,17 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from textwrap import dedent +from pykickstart.version import versionToLongString, RHEL5, RHEL6, FC3, FC4, FC5, F29 +from pykickstart.version import F7, F9, F12, F13, F14, F15, F18, F23, F25, RHEL8 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser, mountpoint -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_RaidData(BaseData): removedKeywords = BaseData.removedKeywords @@ -41,17 +43,26 @@ class FC3_RaidData(BaseData): self.members = kwargs.get("members", []) def __eq__(self, y): + if not y: + return False + return self.device == y.device + def __ne__(self, y): + return not self == y + def _getArgsAsStr(self): retval = "" - if self.device != "": + # NB: using str(device) b/c when device=0 (as int) the condition fails + # I'm not sure if we want to modify the tests b/c they compare device=md0 to device=0 + # and expect both to be equal + if str(self.device): retval += " --device=%s" % self.device - if self.fstype != "": + if self.fstype: retval += " --fstype=\"%s\"" % self.fstype - if self.level != "": - retval += " --level=%s" % self.level + if self.level: + retval += " --level=%s" % self.level.upper() if not self.format: retval += " --noformat" if self.spares != 0: @@ -63,9 +74,14 @@ class FC3_RaidData(BaseData): def __str__(self): retval = BaseData.__str__(self) - retval += "raid %s%s %s\n" % (self.mountpoint, self._getArgsAsStr(), - " ".join(self.members)) - return retval + retval += "raid %s%s" % (self.mountpoint, self._getArgsAsStr()) + + # Do not output the members list if --preexist was passed in. + # This would be invalid input according to the parse method. + if not self.preexist: + retval += " " + " ".join(self.members) + + return retval.strip() + "\n" class FC4_RaidData(FC3_RaidData): removedKeywords = FC3_RaidData.removedKeywords @@ -78,7 +94,7 @@ class FC4_RaidData(FC3_RaidData): def _getArgsAsStr(self): retval = FC3_RaidData._getArgsAsStr(self) - if self.fsopts != "": + if self.fsopts: retval += " --fsoptions=\"%s\"" % self.fsopts return retval @@ -114,19 +130,20 @@ class RHEL5_RaidData(FC5_RaidData): if self.encrypted: retval += " --encrypted" - if self.passphrase != "": + if self.passphrase: retval += " --passphrase=\"%s\"" % self.passphrase return retval -F7_RaidData = FC5_RaidData +class F7_RaidData(FC5_RaidData): + pass -class F9_RaidData(FC5_RaidData): - removedKeywords = FC5_RaidData.removedKeywords + ["bytesPerInode"] - removedAttrs = FC5_RaidData.removedAttrs + ["bytesPerInode"] +class F9_RaidData(F7_RaidData): + removedKeywords = F7_RaidData.removedKeywords + ["bytesPerInode"] + removedAttrs = F7_RaidData.removedAttrs + ["bytesPerInode"] def __init__(self, *args, **kwargs): - FC5_RaidData.__init__(self, *args, **kwargs) + F7_RaidData.__init__(self, *args, **kwargs) self.deleteRemovedAttrs() self.fsprofile = kwargs.get("fsprofile", "") @@ -134,14 +151,14 @@ class F9_RaidData(FC5_RaidData): self.passphrase = kwargs.get("passphrase", "") def _getArgsAsStr(self): - retval = FC5_RaidData._getArgsAsStr(self) + retval = F7_RaidData._getArgsAsStr(self) - if self.fsprofile != "": + if self.fsprofile: retval += " --fsprofile=\"%s\"" % self.fsprofile if self.encrypted: retval += " --encrypted" - if self.passphrase != "": + if self.passphrase: retval += " --passphrase=\"%s\"" % self.passphrase return retval @@ -160,16 +177,35 @@ class F12_RaidData(F9_RaidData): def _getArgsAsStr(self): retval = F9_RaidData._getArgsAsStr(self) - if self.encrypted and self.escrowcert != "": + if self.encrypted and self.escrowcert: retval += " --escrowcert=\"%s\"" % self.escrowcert if self.backuppassphrase: retval += " --backuppassphrase" return retval -F13_RaidData = F12_RaidData +class F13_RaidData(F12_RaidData): + pass + +class RHEL6_RaidData(F13_RaidData): + removedKeywords = F13_RaidData.removedKeywords + removedAttrs = F13_RaidData.removedAttrs + + def __init__(self, *args, **kwargs): + F13_RaidData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") -F14_RaidData = F13_RaidData + def _getArgsAsStr(self): + retval = F13_RaidData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher=\"%s\"" % self.cipher + + return retval + +class F14_RaidData(F13_RaidData): + pass class F15_RaidData(F14_RaidData): removedKeywords = F14_RaidData.removedKeywords @@ -184,28 +220,111 @@ class F15_RaidData(F14_RaidData): def _getArgsAsStr(self): retval = F14_RaidData._getArgsAsStr(self) - if self.label != "": + if self.label: retval += " --label=%s" % self.label return retval +class F18_RaidData(F15_RaidData): + removedKeywords = F15_RaidData.removedKeywords + removedAttrs = F15_RaidData.removedAttrs + + def __init__(self, *args, **kwargs): + F15_RaidData.__init__(self, *args, **kwargs) + + self.cipher = kwargs.get("cipher", "") + + def _getArgsAsStr(self): + retval = F15_RaidData._getArgsAsStr(self) + + if self.encrypted and self.cipher: + retval += " --cipher=\"%s\"" % self.cipher + + return retval + +class F23_RaidData(F18_RaidData): + removedKeywords = F18_RaidData.removedKeywords + removedAttrs = F18_RaidData.removedAttrs + + def __init__(self, *args, **kwargs): + F18_RaidData.__init__(self, *args, **kwargs) + self.mkfsopts = kwargs.get("mkfsoptions", "") or kwargs.get("mkfsopts", "") + + def _getArgsAsStr(self): + retval = F18_RaidData._getArgsAsStr(self) + + if self.mkfsopts: + retval += " --mkfsoptions=\"%s\"" % self.mkfsopts + + return retval + +class F25_RaidData(F23_RaidData): + removedKeywords = F23_RaidData.removedKeywords + removedAttrs = F23_RaidData.removedAttrs + + def __init__(self, *args, **kwargs): + F23_RaidData.__init__(self, *args, **kwargs) + self.chunk_size = kwargs.get("chunk_size", None) + + def _getArgsAsStr(self): + retval = F23_RaidData._getArgsAsStr(self) + + if self.chunk_size: + retval += " --chunksize=%d" % self.chunk_size + + return retval + +class RHEL7_RaidData(F25_RaidData): + pass + +class F29_RaidData(F25_RaidData): + def __init__(self, *args, **kwargs): + F25_RaidData.__init__(self, *args, **kwargs) + self.luks_version = kwargs.get("luks_version", "") + self.pbkdf = kwargs.get("pbkdf", "") + self.pbkdf_memory = kwargs.get("pbkdf_memory", 0) + self.pbkdf_time = kwargs.get("pbkdf_time", 0) + self.pbkdf_iterations = kwargs.get("pbkdf_iterations", 0) + + def _getArgsAsStr(self): + retval = F25_RaidData._getArgsAsStr(self) + + if self.encrypted and self.luks_version: + retval += " --luks-version=%s" % self.luks_version + + if self.encrypted and self.pbkdf: + retval += " --pbkdf=%s" % self.pbkdf + + if self.encrypted and self.pbkdf_memory: + retval += " --pbkdf-memory=%s" % self.pbkdf_memory + + if self.encrypted and self.pbkdf_time: + retval += " --pbkdf-time=%s" % self.pbkdf_time + + if self.encrypted and self.pbkdf_iterations: + retval += " --pbkdf-iterations=%s" % self.pbkdf_iterations + + return retval + +class RHEL8_RaidData(F29_RaidData): + pass + class FC3_Raid(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs def __init__(self, writePriority=131, *args, **kwargs): KickstartCommand.__init__(self, writePriority, *args, **kwargs) - self.op = self._getParser() - # A dict of all the RAID levels we support. This means that if we # support more levels in the future, subclasses don't have to # duplicate too much. - self.levelMap = { "RAID0": "RAID0", "0": "RAID0", - "RAID1": "RAID1", "1": "RAID1", - "RAID5": "RAID5", "5": "RAID5", - "RAID6": "RAID6", "6": "RAID6" } + self.levelMap = {"RAID0": "RAID0", "0": "RAID0", + "RAID1": "RAID1", "1": "RAID1", + "RAID5": "RAID5", "5": "RAID5", + "RAID6": "RAID6", "6": "RAID6"} self.raidList = kwargs.get("raidList", []) + self.op = self._getParser() def __str__(self): retval = "" @@ -216,69 +335,154 @@ class FC3_Raid(KickstartCommand): return retval def _getParser(self): - def raid_cb (option, opt_str, value, parser): - parser.values.format = False - parser.values.preexist = True - - def device_cb (option, opt_str, value, parser): + def device_cb(value): if value[0:2] == "md": - parser.values.ensure_value(option.dest, value[2:]) + return value[2:] else: - parser.values.ensure_value(option.dest, value) - - def level_cb (option, opt_str, value, parser): - if self.levelMap.has_key(value): - parser.values.ensure_value(option.dest, self.levelMap[value]) - - op = KSOptionParser() - op.add_option("--device", action="callback", callback=device_cb, - dest="device", type="string", nargs=1, required=1) - op.add_option("--fstype", dest="fstype") - op.add_option("--level", dest="level", action="callback", - callback=level_cb, type="string", nargs=1) - op.add_option("--noformat", action="callback", callback=raid_cb, - dest="format", default=True, nargs=0) - op.add_option("--spares", dest="spares", action="store", type="int", - nargs=1, default=0) - op.add_option("--useexisting", dest="preexist", action="store_true", - default=False) - return op - - def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + return value - if len(extra) == 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "raid")) - if len(extra) == 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Partitions required for %s") % "raid")) - - rd = self.handler.RaidData() - self._setToObj(self.op, opts, rd) - rd.lineno = self.lineno + def level_cb(value): + if value.upper() in self.levelMap: + return self.levelMap[value.upper()] + else: + raise KickstartParseError(_("Invalid raid level: %s") % value, lineno=self.lineno) + + op = KSOptionParser(prog="raid", description=""" + Assembles a software RAID device.""", + epilog=""" + The following example shows how to create a RAID + level 1 partition for /, and a RAID level 5 for + /usr, assuming there are three disks on the + system. It also creates three swap partitions, one + on each drive:: + + part raid.01 --size=6000 --ondisk=sda + part raid.02 --size=6000 --ondisk=sdb + part raid.03 --size=6000 --ondisk=sdc + + part swap1 --size=512 --ondisk=sda + part swap2 --size=512 --ondisk=sdb + part swap3 --size=512 --ondisk=sdc + + part raid.11 --size=6000 --ondisk=sda + part raid.12 --size=6000 --ondisk=sdb + part raid.13 --size=6000 --ondisk=sdc + + raid / --level=1 --device=md0 raid.01 raid.02 raid.03 + raid /usr --level=5 --device=md1 raid.11 raid.12 raid.13 + """, version=FC3) + op.add_argument("mntpoint", metavar="<mntpoint>", type=mountpoint, nargs=1, + version=FC3, help=""" + Location where the RAID file system is mounted. If it + is /, the RAID level must be 1 unless a boot partition + (/boot) is present. If a boot partition is present, the + /boot partition must be level 1 and the root (/) + partition can be any of the available types.""") + op.add_argument("partitions", metavar="<partitions*>", nargs="*", + version=FC3, help=""" + The software raid partitions lists the RAID identifiers + to add to the RAID array.""") + op.add_argument("--device", type=device_cb, required=True, + version=FC3, help=""" + Name of the RAID device to use (such as 'fedora-root' + or 'home'). As of Fedora 19, RAID devices are no longer + referred to by names like 'md0'. If you have an old + (v0.90 metadata) array that you cannot assign a name to, + you can specify the array by a filesystem label or UUID + (eg: --device=LABEL=fedora-root).""") + op.add_argument("--fstype", version=FC3, help=""" + Sets the file system type for the RAID array. Valid + values include ext4, ext3, ext2, btrfs, swap, and vfat. + Other filesystems may be valid depending on command + line arguments passed to anaconda to enable other + filesystems.""") + op.add_argument("--level", type=level_cb, version=FC3, help=""" + RAID level to use %s.""" % set(self.levelMap.values())) + op.add_argument("--noformat", dest="format", action="store_false", + default=True, version=FC3, help=""" + Use an existing RAID device and do not format the RAID + array.""") + op.add_argument("--spares", type=int, default=0, version=FC3, help=""" + Specifies the number of spare drives allocated for the + RAID array. Spare drives are used to rebuild the array + in case of drive failure.""") + op.add_argument("--useexisting", dest="preexist", action="store_true", + default=False, version=FC3, help=""" + Use an existing RAID device and reformat it.""") + return op + def _getDevice(self, s): + """ Convert the argument to --device= to its internal format. """ # --device can't just take an int in the callback above, because it # could be specificed as "mdX", which causes optparse to error when # it runs int(). - rd.device = int(rd.device) - rd.mountpoint = extra[0] - rd.members = extra[1:] + return int(s) + + def parse(self, args): + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + if any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "raid", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + # because positional argumnets with variable number of values + # don't parse very well + if not ns.partitions and extra: + ns.partitions = extra + extra = [] + + if not ns.format: + ns.preexist = True + + assert len(ns.mntpoint) == 1 + if not ns.partitions and not ns.preexist: + raise KickstartParseError(_("Partitions required for %s") % "raid", lineno=self.lineno) + elif ns.partitions and ns.preexist: + raise KickstartParseError(_("Members may not be specified for preexisting RAID device"), lineno=self.lineno) + + rd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, rd) + rd.lineno = self.lineno + + # In older pykickstart --device was always specifying a minor, so + # rd.device had to be an integer. + # In newer pykickstart it has to be the array name since the minor + # cannot be reliably predicted due to lack of mdadm.conf during boot. + rd.device = self._getDevice(rd.device) + rd.mountpoint = ns.mntpoint[0] + + if len(ns.partitions) > 0: + rd.members = ns.partitions # Check for duplicates in the data list. if rd in self.dataList(): - warnings.warn(_("A RAID device with the name %s has already been defined.") % rd.device) + warnings.warn(_("A RAID device with the name %s has already been defined.") % rd.device, KickstartParseWarning) + + if not rd.preexist and not rd.level: + raise KickstartParseError("RAID Partition defined without RAID level", lineno=self.lineno) + + if rd.preexist and rd.device == "": + raise KickstartParseError("Device required for preexisting RAID device", lineno=self.lineno) return rd def dataList(self): return self.raidList + @property + def dataClass(self): + return self.handler.RaidData + class FC4_Raid(FC3_Raid): removedKeywords = FC3_Raid.removedKeywords removedAttrs = FC3_Raid.removedAttrs def _getParser(self): op = FC3_Raid._getParser(self) - op.add_option("--fsoptions", dest="fsopts") + op.add_argument("--fsoptions", dest="fsopts", version=FC4, help=""" + Specifies a free form string of options to be used when + mounting the filesystem. This string will be copied into + the /etc/fstab file of the installed system and should + be enclosed in quotes.""") return op class FC5_Raid(FC4_Raid): @@ -287,8 +491,8 @@ class FC5_Raid(FC4_Raid): def _getParser(self): op = FC4_Raid._getParser(self) - op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store", - type="int", nargs=1) + op.add_argument("--bytes-per-inode", dest="bytesPerInode", type=int, + version=FC5, help="Specify the bytes/inode ratio.") return op class RHEL5_Raid(FC5_Raid): @@ -302,8 +506,25 @@ class RHEL5_Raid(FC5_Raid): def _getParser(self): op = FC5_Raid._getParser(self) - op.add_option("--encrypted", action="store_true", default=False) - op.add_option("--passphrase") + for action in op._actions: + if "--level" in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + The "RAID10" level was added.""" % versionToLongString(RHEL5)) + break + + op.add_argument("--encrypted", action="store_true", + default=False, version=RHEL5, help=""" + Specify that this RAID device should be encrypted. + """) + op.add_argument("--passphrase", version=RHEL5, help=""" + Specify the passphrase to use when encrypting this RAID + device. Without the above --encrypted option, this + option does nothing. If no passphrase is specified, the + default system-wide one is used, or the installer will + stop and prompt if there is no default.""") return op class F7_Raid(FC5_Raid): @@ -315,16 +536,43 @@ class F7_Raid(FC5_Raid): self.levelMap.update({"RAID10": "RAID10", "10": "RAID10"}) + def _getParser(self): + op = FC5_Raid._getParser(self) + for action in op._actions: + if "--level" in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + The "RAID10" level was added.""" % versionToLongString(F7)) + break + return op + class F9_Raid(F7_Raid): removedKeywords = F7_Raid.removedKeywords removedAttrs = F7_Raid.removedAttrs def _getParser(self): op = F7_Raid._getParser(self) - op.add_option("--bytes-per-inode", deprecated=1) - op.add_option("--fsprofile") - op.add_option("--encrypted", action="store_true", default=False) - op.add_option("--passphrase") + op.add_argument("--bytes-per-inode", deprecated=F9) + op.add_argument("--fsprofile", version=F9, help=""" + Specifies a usage type to be passed to the program that + makes a filesystem on this partition. A usage type + defines a variety of tuning parameters to be used when + making a filesystem. For this option to work, the + filesystem must support the concept of usage types and + there must be a configuration file that lists valid + types. For ext2/3/4, this configuration file is + ``/etc/mke2fs.conf``.""") + op.add_argument("--encrypted", action="store_true", version=F9, + default=False, help=""" + Specify that this RAID device should be encrypted.""") + op.add_argument("--passphrase", version=F9, help=""" + Specify the passphrase to use when encrypting this RAID + device. Without the above --encrypted option, this option + does nothing. If no passphrase is specified, the default + system-wide one is used, or the installer will stop and + prompt if there is no default.""") return op class F12_Raid(F9_Raid): @@ -333,8 +581,21 @@ class F12_Raid(F9_Raid): def _getParser(self): op = F9_Raid._getParser(self) - op.add_option("--escrowcert") - op.add_option("--backuppassphrase", action="store_true", default=False) + op.add_argument("--escrowcert", metavar="<url>", version=F12, help=""" + Load an X.509 certificate from ``<url>``. Store the + data encryption key of this partition, encrypted using + the certificate, as a file in ``/root``. Only relevant + if ``--encrypted`` is specified as well.""") + op.add_argument("--backuppassphrase", action="store_true", + default=False, version=F12, help=""" + Only relevant if ``--escrowcert`` is specified as well. + In addition to storing the data encryption key, generate + a random passphrase and add it to this partition. Then + store the passphrase, encrypted using the certificate + specified by ``--escrowcert``, as a file in ``/root``. + If more than one LUKS volume uses ``--backuppassphrase``, + the same passphrase will be used for all such volumes. + """) return op class F13_Raid(F12_Raid): @@ -346,13 +607,47 @@ class F13_Raid(F12_Raid): self.levelMap.update({"RAID4": "RAID4", "4": "RAID4"}) + def _getParser(self): + op = F12_Raid._getParser(self) + for action in op._actions: + if "--level" in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + The "RAID4" level was added.""" % versionToLongString(F13)) + break + return op + +class RHEL6_Raid(F13_Raid): + removedKeywords = F13_Raid.removedKeywords + removedAttrs = F13_Raid.removedAttrs + + def _getParser(self): + op = F13_Raid._getParser(self) + op.add_argument("--cipher", version=RHEL6, help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which encryption algorithm should be used to encrypt the + filesystem.""") + return op + + def parse(self, args): + # first call the overriden method + retval = F13_Raid.parse(self, args) + # the raid command can't be used together with the autopart command + # due to the hard to debug behavior their combination introduces + if self.handler.autopart.seen: + errorMsg = _("The raid and autopart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + return retval + class F14_Raid(F13_Raid): removedKeywords = F13_Raid.removedKeywords removedAttrs = F13_Raid.removedAttrs def _getParser(self): op = F13_Raid._getParser(self) - op.remove_option("--bytes-per-inode") + op.remove_argument("--bytes-per-inode", version=F14) return op class F15_Raid(F14_Raid): @@ -361,5 +656,160 @@ class F15_Raid(F14_Raid): def _getParser(self): op = F14_Raid._getParser(self) - op.add_option("--label") + op.add_argument("--label", version=F15, help=""" + Specify the label to give to the filesystem to be made. + If the given label is already in use by another + filesystem, a new label will be created.""") return op + +class F18_Raid(F15_Raid): + removedKeywords = F15_Raid.removedKeywords + removedAttrs = F15_Raid.removedAttrs + + def _getParser(self): + op = F15_Raid._getParser(self) + op.add_argument("--cipher", version=F18, help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which encryption algorithm should be used to encrypt the + filesystem.""") + return op + +class F19_Raid(F18_Raid): + removedKeywords = F18_Raid.removedKeywords + removedAttrs = F18_Raid.removedAttrs + + def _getDevice(self, s): + return s + +class F20_Raid(F19_Raid): + removedKeywords = F19_Raid.removedKeywords + removedAttrs = F19_Raid.removedAttrs + + def parse(self, args): + # first call the overriden method + retval = F19_Raid.parse(self, args) + # the raid command can't be used together with the autopart command + # due to the hard to debug behavior their combination introduces + if self.handler.autopart.seen: + errorMsg = _("The raid and autopart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + # the same applies to the 'mount' command + if hasattr(self.handler, "mount") and self.handler.mount.seen: + errorMsg = _("The raid and mount commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + return retval + +class F23_Raid(F20_Raid): + removedKeywords = F20_Raid.removedKeywords + removedAttrs = F20_Raid.removedAttrs + + def _getParser(self): + op = F20_Raid._getParser(self) + op.add_argument("--mkfsoptions", dest="mkfsopts", version=F23, help=""" + Specifies additional parameters to be passed to the + program that makes a filesystem on this partition. No + processing is done on the list of arguments, so they + must be supplied in a format that can be passed directly + to the mkfs program. This means multiple options should + be comma-separated or surrounded by double quotes, + depending on the filesystem.""") + return op + + def parse(self, args): + retval = F20_Raid.parse(self, args) + + if not retval.format and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions with --noformat has no effect."), lineno=self.lineno) + + if retval.fsprofile and retval.mkfsopts: + raise KickstartParseError(_("--mkfsoptions and --fsprofile cannot be used together."), lineno=self.lineno) + + return retval + +class F25_Raid(F23_Raid): + removedKeywords = F23_Raid.removedKeywords + removedAttrs = F23_Raid.removedAttrs + + def _getParser(self): + op = F23_Raid._getParser(self) + op.add_argument("--chunksize", type=int, dest="chunk_size", + version=F25, help=""" + Specify the chunk size (in KiB) for this RAID array. + """) + return op + +class RHEL7_Raid(F25_Raid): + pass + +class F29_Raid(F25_Raid): + removedKeywords = F25_Raid.removedKeywords + removedAttrs = F25_Raid.removedAttrs + + def _getParser(self): + op = F25_Raid._getParser(self) + op.add_argument("--luks-version", dest="luks_version", version=F29, default="", + help=""" + Only relevant if ``--encrypted`` is specified. Specifies + which version of LUKS format should be used to encrypt + the filesystem.""") + op.add_argument("--pbkdf", version=F29, default="", help=""" + Only relevant if ``--encrypted`` is specified. Sets + Password-Based Key Derivation Function (PBKDF) algorithm + for LUKS keyslot. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-memory", dest="pbkdf_memory", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the memory cost for PBKDF. See ``man cryptsetup``.""") + op.add_argument("--pbkdf-time", dest="pbkdf_time", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of milliseconds to spend with PBKDF passphrase + processing. See ``--iter-time`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) + op.add_argument("--pbkdf-iterations", dest="pbkdf_iterations", type=int, default=0, + version=F29, help=""" + Only relevant if ``--encrypted`` is specified. Sets + the number of iterations directly and avoids PBKDF benchmark. + See ``--pbkdf-force-iterations`` in ``man cryptsetup``. + + Only one of ``--pbkdf-time`` and ``--pbkdf-iterations`` + can be specified. + """) + return op + + def parse(self, args): + retval = F25_Raid.parse(self, args) + + if retval.pbkdf_time and retval.pbkdf_iterations: + msg = _("Only one of --pbkdf-time and --pbkdf-iterations can be specified.") + raise KickstartParseError(msg, lineno=self.lineno) + + return retval + +class RHEL8_Raid(F29_Raid): + removedKeywords = F29_Raid.removedKeywords + removedAttrs = F29_Raid.removedAttrs + + def parse(self, args): + retval = F29_Raid.parse(self, args) + if retval.fstype == "btrfs": + raise KickstartParseError(_("Btrfs file system is not supported"), lineno=self.lineno) + return retval + + def _getParser(self): + "Only necessary for the type change documentation" + op = F29_Raid._getParser(self) + for action in op._actions: + if "--fstype" in action.option_strings: + action.help += """ + + .. versionchanged:: %s + + Btrfs support was removed.""" % versionToLongString(RHEL8) + return op + +class RHEL9_Raid(RHEL8_Raid): + pass diff --git a/mic/3rdparty/pykickstart/commands/realm.py b/mic/3rdparty/pykickstart/commands/realm.py new file mode 100644 index 0000000..53b52f6 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/realm.py @@ -0,0 +1,104 @@ +# +# Stef Walter <stefw@redhat.com> +# +# Copyright 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import F19 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser +from pykickstart.errors import KickstartParseError + +import getopt +import pipes +import shlex + +from pykickstart.i18n import _ + +class F19_Realm(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.join_realm = None + self.join_args = [] + self.discover_options = [] + + def _parseArguments(self, string): + if self.join_realm: + raise KickstartParseError(_("The realm command 'join' should only be specified once"), lineno=self.lineno) + args = shlex.split(string) + if not args: + raise KickstartParseError(_("Missing realm command arguments"), lineno=self.lineno) + command = args.pop(0) + if command == "join": + self._parseJoin(args) + else: + raise KickstartParseError(_("Unsupported realm '%s' command") % command, lineno=self.lineno) + + def _parseJoin(self, args): + try: + # We only support these args + opts, remaining = getopt.getopt(args, "", ("client-software=", + "server-software=", + "membership-software=", + "one-time-password=", + "no-password", + "computer-ou=")) + except getopt.GetoptError as ex: + raise KickstartParseError(_("Invalid realm arguments: %s") % ex, lineno=self.lineno) + + if len(remaining) != 1: + raise KickstartParseError(_("Specify only one realm to join"), lineno=self.lineno) + + # Parse successful, just use this as the join command + self.join_realm = remaining[0] + self.join_args = args + + # Build a discovery command + self.discover_options = [] + supported_discover_options = ("--client-software", + "--server-software", + "--membership-software") + for (o, a) in opts: + if o in supported_discover_options: + self.discover_options.append("%s=%s" % (o, a)) + + def _getCommandsAsStrings(self): + commands = [] + if self.join_args: + args = [pipes.quote(arg) for arg in self.join_args] + commands.append("realm join " + " ".join(args)) + return commands + + def __str__(self): + retval = KickstartCommand.__str__(self) + + commands = self._getCommandsAsStrings() + if commands: + retval += "# Realm or domain membership\n" + retval += "\n".join(commands) + retval += "\n" + + return retval + + def parse(self, args): + self._parseArguments(self.currentLine[len(self.currentCmd):].strip()) + return self + + def _getParser(self): + return KSOptionParser(prog="realm", description="define an Active Directory realm to join", version=F19) diff --git a/mic/3rdparty/pykickstart/commands/reboot.py b/mic/3rdparty/pykickstart/commands/reboot.py index 391af14..75a6d91 100644 --- a/mic/3rdparty/pykickstart/commands/reboot.py +++ b/mic/3rdparty/pykickstart/commands/reboot.py @@ -15,12 +15,13 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.errors import * -from pykickstart.options import * +from textwrap import dedent +from pykickstart.version import versionToLongString, FC3, FC6, F18, F23 +from pykickstart.base import KickstartCommand +from pykickstart.constants import KS_REBOOT, KS_SHUTDOWN, KS_WAIT +from pykickstart.options import KSOptionParser class FC3_Reboot(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -30,24 +31,53 @@ class FC3_Reboot(KickstartCommand): KickstartCommand.__init__(self, writePriority, *args, **kwargs) self.action = kwargs.get("action", None) + def _getArgsAsStr(self): + return "" + def __str__(self): retval = KickstartCommand.__str__(self) if self.action == KS_REBOOT: - retval += "# Reboot after installation\nreboot\n" + retval += "# Reboot after installation\nreboot" + retval += self._getArgsAsStr() + "\n" elif self.action == KS_SHUTDOWN: - retval += "# Shutdown after installation\nshutdown\n" + retval += "# Shutdown after installation\nshutdown" + retval += self._getArgsAsStr() + "\n" return retval def parse(self, args): if self.currentCmd == "reboot": self.action = KS_REBOOT - else: + elif self.currentCmd in ["shutdown", "poweroff"]: self.action = KS_SHUTDOWN return self + def _getParser(self): + op = KSOptionParser(prog="reboot|poweroff|shutdown", description=""" + + ``reboot`` + + Reboot after the installation is complete. Normally, + kickstart displays a message and waits for the user + to press a key before rebooting. + + ``poweroff`` + + Turn off the machine after the installation is complete. + Normally, kickstart displays a message and waits for + the user to press a key before rebooting. + + ``shutdown`` + + At the end of installation, shut down the machine. + This is the same as the poweroff command. Normally, + kickstart displays a message and waits for the user + to press a key before rebooting.""", version=FC3) + return op + + class FC6_Reboot(FC3_Reboot): removedKeywords = FC3_Reboot.removedKeywords removedAttrs = FC3_Reboot.removedAttrs @@ -58,22 +88,90 @@ class FC6_Reboot(FC3_Reboot): self.eject = kwargs.get("eject", False) - def __str__(self): - retval = FC3_Reboot.__str__(self).rstrip() + def _getArgsAsStr(self): + retval = FC3_Reboot._getArgsAsStr(self) if self.eject: retval += " --eject" - return retval + "\n" + return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--eject", dest="eject", action="store_true", - default=False) + op = FC3_Reboot._getParser(self) + op.add_argument("--eject", action="store_true", version=FC6, + default=False, help=""" + Attempt to eject CD or DVD media before rebooting. + """) return op def parse(self, args): FC3_Reboot.parse(self, args) - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self + +class F18_Reboot(FC6_Reboot): + removedKeywords = FC6_Reboot.removedKeywords + removedAttrs = FC6_Reboot.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + FC6_Reboot.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + def __str__(self): + retval = FC6_Reboot.__str__(self) + + if self.action == KS_WAIT: + retval = "# Halt after installation\nhalt" + retval += self._getArgsAsStr() + "\n" + + return retval + + def parse(self, args): + FC6_Reboot.parse(self, args) + if self.currentCmd == "halt": + self.action = KS_WAIT + return self + + def _getParser(self): + op = FC6_Reboot._getParser(self) + op.prog += "|halt" + op.description += dedent(""" + + ``halt`` + + At the end of installation, display a message and wait for the user to + press a key before rebooting. This is the default action. + + .. versionchanged:: %s + + The 'halt' command was added! + + """ % versionToLongString(F18)) + return op + +class F23_Reboot(F18_Reboot): + removedKeywords = F18_Reboot.removedKeywords + removedAttrs = F18_Reboot.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + F18_Reboot.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + self.kexec = kwargs.get("kexec", False) + + def _getArgsAsStr(self): + retval = F18_Reboot._getArgsAsStr(self) + + if self.kexec: + retval += " --kexec" + + return retval + + def _getParser(self): + op = F18_Reboot._getParser(self) + op.add_argument("--kexec", action="store_true", version=F23, + default=False, help=""" + Use kexec to reboot into the new system, bypassing + BIOS/Firmware and bootloader.""") + return op diff --git a/mic/3rdparty/pykickstart/commands/repo.py b/mic/3rdparty/pykickstart/commands/repo.py index b673982..f050985 100644 --- a/mic/3rdparty/pykickstart/commands/repo.py +++ b/mic/3rdparty/pykickstart/commands/repo.py @@ -15,16 +15,17 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.errors import * -from pykickstart.options import * +from textwrap import dedent +from pykickstart.version import versionToLongString +from pykickstart.version import FC6, F8, F11, F13, F14, F15, F21, F27, F30, F33 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartError, KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser, commaSplit, ksboolean -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC6_RepoData(BaseData): removedKeywords = BaseData.removedKeywords @@ -37,8 +38,14 @@ class FC6_RepoData(BaseData): self.name = kwargs.get("name", "") def __eq__(self, y): + if not y: + return False + return self.name == y.name + def __ne__(self, y): + return not self == y + def _getArgsAsStr(self): retval = "" @@ -123,9 +130,73 @@ class F14_RepoData(F13_RepoData): return retval -RHEL6_RepoData = F14_RepoData +class RHEL6_RepoData(F14_RepoData): + pass + +class F15_RepoData(F14_RepoData): + pass + +class F21_RepoData(F15_RepoData): + removedKeywords = F15_RepoData.removedKeywords + removedAttrs = F15_RepoData.removedAttrs + + def __init__(self, *args, **kwargs): + F15_RepoData.__init__(self, *args, **kwargs) + self.install = kwargs.get("install", False) + + def _getArgsAsStr(self): + retval = F15_RepoData._getArgsAsStr(self) + + if self.install: + retval += " --install" + + return retval + +class F27_RepoData(F21_RepoData): + removedKeywords = F21_RepoData.removedKeywords + removedAttrs = F21_RepoData.removedAttrs + + def __init__(self, *args, **kwargs): + F21_RepoData.__init__(self, *args, **kwargs) + self.metalink = kwargs.get("metalink", False) + + def _getArgsAsStr(self): + retval = F21_RepoData._getArgsAsStr(self) -F15_RepoData = F14_RepoData + if self.metalink: + retval += " --metalink=%s" % self.metalink + + return retval + +class F30_RepoData(F27_RepoData): + removedKeywords = F27_RepoData.removedKeywords + removedAttrs = F27_RepoData.removedAttrs + + def __init__(self, *args, **kwargs): + F27_RepoData.__init__(self, *args, **kwargs) + self.sslcacert = kwargs.get("sslcacert", None) + self.sslclientcert = kwargs.get("sslclientcert", None) + self.sslclientkey = kwargs.get("sslclientkey", None) + + def _getArgsAsStr(self): + retval = F27_RepoData._getArgsAsStr(self) + + if self.sslcacert: + retval += " --sslcacert=\"%s\"" % self.sslcacert + + if self.sslclientcert: + retval += " --sslclientcert=\"%s\"" % self.sslclientcert + + if self.sslclientkey: + retval += " --sslclientkey=\"%s\"" % self.sslclientkey + + return retval + +class RHEL7_RepoData(F21_RepoData): + pass + +class RHEL8_RepoData(F30_RepoData): + pass class FC6_Repo(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -138,6 +209,8 @@ class FC6_Repo(KickstartCommand): self.op = self._getParser() self.repoList = kwargs.get("repoList", []) + self.exclusive_required_options = [("mirrorlist", "--mirrorlist"), + ("baseurl", "--baseurl")] def __str__(self): retval = "" @@ -147,40 +220,88 @@ class FC6_Repo(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--name", dest="name", required=1) - op.add_option("--baseurl") - op.add_option("--mirrorlist") + op = KSOptionParser(prog="repo", description=""" + Configures additional yum repositories that may be + used as sources for package installation. Multiple + repo lines may be specified. By default, anaconda + has a configured set of repos taken from + /etc/anaconda.repos.d plus a special Installation + Repo in the case of a media install. The exact set + of repos in this directory changes from release to + release and cannot be listed here. There will + likely always be a repo named "updates". + + Note: If you want to enable one of the repos in + /etc/anaconda.repos.d that is disabled by default + (like "updates"), you should use --name= but none + of the other options. anaconda will look for a repo + by this name automatically. Providing a baseurl or + mirrorlist URL will result in anaconda attempting + to add another repo by the same name, which will + cause a conflicting repo error.""", + version=FC6) + op.add_argument("--name", required=True, version=FC6, help=""" + The repo id. This option is required. The RepoId must + not contain spaces (do not confuse with the optional name + used by yum). If a repo has a name that conflicts with a + previously added one, the new repo will be ignored. + Because anaconda has a populated list of repos when it + starts, this means that users cannot create new repos + that override these names. + Please check /etc/anaconda.repos.d from the operating + system you wish to install to see what names are not + available.""") + op.add_argument("--baseurl", version=FC6, help=""" + The URL for the repository. The variables that may be + used in yum repo config files are not supported here. + You may use one of either this option or + ``--mirrorlist``, not both. If an NFS repository is + specified, it should be of the form + ``nfs://host:/path/to/repo``. Note that there is a + colon after the host. Anaconda passes everything after + "nfs:// " directly to the mount command instead of + parsing URLs according to RFC 2224. Variable + substitution is done for $releasever and $basearch in + the url.""") + op.add_argument("--mirrorlist", version=FC6, help=""" + The URL pointing at a list of mirrors for the + repository. The variables that may be used in yum repo + config files are not supported here. You may use one of + either this option or ``--baseurl``, not both. Variable + substitution is done for $releasever and $basearch in + the url.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if len(extra) != 0: - mapping = {"command": "repo", "options": extra} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) - - # This is lame, but I can't think of a better way to make sure only - # one of these two is specified. - if opts.baseurl and opts.mirrorlist: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command."))) - - if self.urlRequired and not opts.baseurl and not opts.mirrorlist: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command."))) - - rd = self.handler.RepoData() - self._setToObj(self.op, opts, rd) + ns = self.op.parse_args(args=args, lineno=self.lineno) + + # Check that just one of exclusive required options is specified + used_options = [opt for attr, opt in self.exclusive_required_options + if getattr(ns, attr, None)] + if self.urlRequired and not used_options: + mapping = {"options_list": ", ".join((opt for attr, opt in self.exclusive_required_options))} + raise KickstartParseError(_("One of -%(options_list)s options must be specified for repo command.") % mapping, lineno=self.lineno) + if len(used_options) > 1: + mapping = {"options_list": ", ".join((opt for opt in used_options))} + raise KickstartParseError(_("Only one of %(options_list)s options may be specified for repo command.") % mapping, lineno=self.lineno) + + rd = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, rd) rd.lineno = self.lineno # Check for duplicates in the data list. if rd in self.dataList(): - warnings.warn(_("A repo with the name %s has already been defined.") % rd.name) + warnings.warn(_("A repo with the name %s has already been defined.") % rd.name, KickstartParseWarning) return rd def dataList(self): return self.repoList + @property + def dataClass(self): + return self.handler.RepoData + class F8_Repo(FC6_Repo): removedKeywords = FC6_Repo.removedKeywords removedAttrs = FC6_Repo.removedAttrs @@ -193,21 +314,32 @@ class F8_Repo(FC6_Repo): return retval def _getParser(self): - def list_cb (option, opt_str, value, parser): - for d in value.split(','): - parser.values.ensure_value(option.dest, []).append(d) - op = FC6_Repo._getParser(self) - op.add_option("--cost", action="store", type="int") - op.add_option("--excludepkgs", action="callback", callback=list_cb, - nargs=1, type="string") - op.add_option("--includepkgs", action="callback", callback=list_cb, - nargs=1, type="string") + op.add_argument("--cost", type=int, version=F8, help=""" + An integer value to assign a cost to this repository. + If multiple repositories provide the same packages, + this number will be used to prioritize which repository + will be used before another. Repositories with a lower + cost take priority over repositories with higher cost. + """) + op.add_argument("--excludepkgs", type=commaSplit, version=F8, help=""" + A comma-separated list of package names and globs that + must not be fetched from this repository. This is useful + if multiple repositories provide the same package and + you want to make sure it is not fetched from a particular + repository during installation.""") + op.add_argument("--includepkgs", type=commaSplit, version=F8, help=""" + A comma-separated list of package names and globs that + can be pulled from this repository. Any other packages + provided by the repository not on this list will be ignored. + This is useful if you want to install just a single package + or set of packages from a repository while including all + other packages the repository provides.""") return op def methodToRepo(self): if not self.handler.method.url: - raise KickstartError (formatErrorMsg(self.handler.method.lineno, msg=_("Method must be a url to be added to the repo list."))) + raise KickstartError(_("Method must be a url to be added to the repo list."), lineno=self.handler.method.lineno) reponame = "ks-method-url" repourl = self.handler.method.url rd = self.handler.RepoData(name=reponame, baseurl=repourl) @@ -219,7 +351,12 @@ class F11_Repo(F8_Repo): def _getParser(self): op = F8_Repo._getParser(self) - op.add_option("--ignoregroups", action="store", type="ksboolean") + op.add_argument("--ignoregroups", type=ksboolean, version=F11, help=""" + This option is used when composing installation trees + and has no effect on the installation process itself. + It tells the compose tools to not look at the package + group information when mirroring trees so as to avoid + mirroring large amounts of unnecessary data.""") return op class F13_Repo(F11_Repo): @@ -228,7 +365,15 @@ class F13_Repo(F11_Repo): def _getParser(self): op = F11_Repo._getParser(self) - op.add_option("--proxy") + op.add_argument("--proxy", version=F13, help=""" + Specify an HTTP/HTTPS/FTP proxy to use just for this + repository. This setting does not affect any other + repositories, nor how the install.img is fetched on + HTTP installs. The various parts of the argument act + like you would expect. The syntax is:: + + ``--proxy=[protocol://][username[:password]@]host[:port]`` + """) return op class F14_Repo(F13_Repo): @@ -237,13 +382,116 @@ class F14_Repo(F13_Repo): def _getParser(self): op = F13_Repo._getParser(self) - op.add_option("--noverifyssl", action="store_true", default=False) + op.add_argument("--noverifyssl", action="store_true", version=F14, + default=False, help=""" + For a https repo do not check the server's certificate + with what well-known CA validate and do not check the + server's hostname matches the certificate's domain name. + """) return op -RHEL6_Repo = F14_Repo +class RHEL6_Repo(F14_Repo): + pass class F15_Repo(F14_Repo): removedKeywords = F14_Repo.removedKeywords removedAttrs = F14_Repo.removedAttrs urlRequired = False + + def _getParser(self): + op = F14_Repo._getParser(self) + for action in op._actions: + for option in ['--baseurl', '--mirrorlist']: + if option in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + ``--mirrorlist`` and ``--baseurl`` are not required anymore! + """ % versionToLongString(F15)) + return op + +class F21_Repo(F15_Repo): + removedKeywords = F15_Repo.removedKeywords + removedAttrs = F15_Repo.removedAttrs + + def _getParser(self): + op = F15_Repo._getParser(self) + op.add_argument("--install", action="store_true", version=F21, + default=False, help=""" + Install this repository to the target system so that it + can be used after reboot.""") + return op + +class F27_Repo(F21_Repo): + removedKeywords = F21_Repo.removedKeywords + removedAttrs = F21_Repo.removedAttrs + + def __init__(self, *args, **kwargs): + F21_Repo.__init__(self, *args, **kwargs) + self.exclusive_required_options.append(("metalink", "--metalink")) + + def _getParser(self): + op = F21_Repo._getParser(self) + op.add_argument("--metalink", version=F27, help=""" + The URL pointing at a metalink for the repository. The + variables that may be used in yum repo config files are + not supported here. You may use only one of the + ``--baseurl``, ``--mirrorlist``, or ``--metalink`` + options. Variable substitution is done for $releasever + and $basearch in the url.""") + for action in op._actions: + for option in ['--baseurl', '--mirrorlist']: + if option in action.option_strings: + action.help += dedent(""" + + .. versionchanged:: %s + + ``Another mutually exclusive option --metalink`` was added. + """ % versionToLongString(F27)) + return op + +class F30_Repo(F27_Repo): + removedKeywords = F27_Repo.removedKeywords + removedAttrs = F27_Repo.removedAttrs + + def _getParser(self): + op = F27_Repo._getParser(self) + op.add_argument("--sslcacert", version=F30, help=""" + Path to the file holding one or more SSL certificates + to verify the repository host with. + + **Note** Usage of this parameter is discouraged. It is + designed for a specific image building tool use and + there are plans for a replacement.""") + op.add_argument("--sslclientcert", version=F30, help=""" + Path to the SSL client certificate (PEM file) which + should be used to connect to the repository. + + **Note** Usage of this parameter is discouraged. It is + designed for a specific image building tool use and + there are plans for a replacement.""") + op.add_argument("--sslclientkey", version=F30, help=""" + Path to the private key file associated with the client + certificate given with --sslclientcert. + + **Note** Usage of this parameter is discouraged. It is + designed for a specific image building tool use and + there are plans for a replacement.""") + return op + +class F33_Repo(F30_Repo): + removedKeywords = F30_Repo.removedKeywords + removedAttrs = F30_Repo.removedAttrs + + def _getParser(self): + op = F30_Repo._getParser(self) + op.add_argument("--ignoregroups", type=ksboolean, deprecated=F33) + return op + +class RHEL7_Repo(F21_Repo): + pass + +class RHEL8_Repo(F30_Repo): + pass diff --git a/mic/3rdparty/pykickstart/commands/reqpart.py b/mic/3rdparty/pykickstart/commands/reqpart.py new file mode 100644 index 0000000..87c9891 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/reqpart.py @@ -0,0 +1,92 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import F23 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ + +class F23_ReqPart(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=100, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.reqpart = kwargs.get("reqpart", False) + self.addBoot = kwargs.get("addBoot", False) + + self.op = self._getParser() + + def _getArgsAsStr(self): + retval = "" + + if self.addBoot: + retval += " --add-boot" + + return retval + + def __str__(self): + retval = KickstartCommand.__str__(self) + if self.reqpart: + retval += "reqpart%s\n" % self._getArgsAsStr() + return retval + + def _getParser(self): + op = KSOptionParser(prog="reqpart", description=""" + Automatically create partitions required by your + hardware platform. These include a ``/boot/efi`` + for x86_64 and Aarch64 systems with UEFI firmware, + ``biosboot`` for x86_64 systems with BIOS firmware + and GPT, and ``PRePBoot`` for IBM Power Systems. + + Note: This command can not be used together with + ``autopart``, because ``autopart`` does the same + and creates other partitions or logical volumes + such as ``/`` and ``swap`` on top. In contrast with + ``autopart``, this command only creates + platform-specific partitions and leaves the rest of + the drive empty, allowing you to create a custom + layout.""", version=F23) + op.add_argument("--add-boot", action="store_true", version=F23, + dest="addBoot", default=False, help=""" + Create a separate ``/boot`` partition in addition to the + platform-specific partition created by the base command. + """) + return op + + def parse(self, args): + # Using reqpart and autopart at the same time is not allowed. + if self.handler.autopart.seen: + errorMsg = _("The %s and reqpart commands can't be used at the same time") % \ + "autopart" + raise KickstartParseError(errorMsg, lineno=self.lineno) + # the same applies to the 'mount' command + if hasattr(self.handler, "mount") and self.handler.mount.seen: + errorMsg = _("The mount and reqpart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + self.reqpart = True + return self + +class RHEL7_ReqPart(F23_ReqPart): + pass diff --git a/mic/3rdparty/pykickstart/commands/rescue.py b/mic/3rdparty/pykickstart/commands/rescue.py index 682fefa..b3ffaa1 100644 --- a/mic/3rdparty/pykickstart/commands/rescue.py +++ b/mic/3rdparty/pykickstart/commands/rescue.py @@ -15,14 +15,14 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import F10 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class F10_Rescue(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -52,17 +52,30 @@ class F10_Rescue(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--nomount", dest="nomount", action="store_true", default=False) - op.add_option("--romount", dest="romount", action="store_true", default=False) + op = KSOptionParser(prog="rescue", description=""" + Automatically enter the installer's rescue mode. + This gives you a chance to repair the system should + something catastrophic happen.""", epilog=""" + By default, the installer will find your system and + mount it in read-write mode, telling you where it has + performed this mount. You may optionally choose to + not mount anything or mount in read-only mode. Only + one of these two options may be given at any one + time.""", version=F10) + op.add_argument("--nomount", action="store_true", version=F10, + default=False, help=""" + Don't mount the installed system.""") + op.add_argument("--romount", action="store_true", version=F10, + default=False, help=""" + Mount the installed system in read-only mode.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + ns = self.op.parse_args(args=args, lineno=self.lineno) - if opts.nomount and opts.romount: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --nomount and --romount may be specified for rescue command."))) + if ns.nomount and ns.romount: + raise KickstartParseError(_("Only one of --nomount and --romount may be specified for rescue command."), lineno=self.lineno) - self._setToSelf(self.op, opts) + self.set_to_self(ns) self.rescue = True return self diff --git a/mic/3rdparty/pykickstart/commands/rhsm.py b/mic/3rdparty/pykickstart/commands/rhsm.py new file mode 100644 index 0000000..fdf10d1 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/rhsm.py @@ -0,0 +1,112 @@ +# +# Copyright 2019 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# + +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser +from pykickstart.version import RHEL8 + +from pykickstart.i18n import _ + +class RHEL8_RHSM(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + self.organization = kwargs.get("organization", None) + self.activation_keys = kwargs.get("activation_keys", None) + self.connect_to_insights = kwargs.get("connect_to_insights", None) + self.proxy = kwargs.get("proxy", None) + self.server_hostname = kwargs.get("server_hostname", None) + self.rhsm_baseurl = kwargs.get("rhsm_baseurl", None) + + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if not retval and not any([self.organization, self.activation_keys, + self.proxy, self.server_hostname, + self.rhsm_baseurl]): + return "" + + retval += '# Red Hat Subscription Manager\nrhsm' + # TODO: check if including the organization name & activation key in + # the output kickstart is expected and safe + if self.organization: + retval+=' --organization="%s"' % self.organization + for key in self.activation_keys: + retval+=' --activation-key="%s"' % key + if self.connect_to_insights: + retval+=' --connect-to-insights' + if self.proxy: + retval += ' --proxy="%s"' % self.proxy + if self.server_hostname: + retval+=' --server-hostname="%s"' % self.server_hostname + if self.rhsm_baseurl: + retval+=' --rhsm-baseurl="%s"' % self.rhsm_baseurl + retval+='\n' + return retval + + def _getParser(self): + op = KSOptionParser(prog="rhsm", description=""" + The rhsm command is used to configure a Red Hat subscription. + A Red Hat subscription is required for installing from + the Red Hat CDN installation source as well connecting the target + system to Red Hat Insights. + + Subscription attached during the installation will also be available + on the target system after the installation. + + System Purpose data specified via the syspurpose command may influence + what subscription will be attached to the system. System Purpose data + set via the syspurpose command will override system purpose data attached + to activation keys. + + An organization id needs to be specified, as well as at least one activation key. + """, version=RHEL8) + op.add_argument("--organization", metavar="<organization_name>", version=RHEL8, required=True, + help="Organization id.") + op.add_argument("--activation-key", metavar="<activation_key>", action="append", dest="activation_keys", + version=RHEL8, required=True, + help="Activation key. Option can be used multiple times, once per activation key.") + op.add_argument("--connect-to-insights", version=RHEL8, action="store_true", default=False, + help="Connect to Red Hat Insights.") + op.add_argument("--proxy", version=RHEL8, help=""" + Specify an HTTP proxy to use for subscription purposes. + The syntax is:: + + ``--proxy=[protocol://][username[:password]@]host[:port]`` + """) + op.add_argument("--server-hostname", metavar="<subscription_service_server_url>", version=RHEL8, required=False, + help="Red Hat subscription service server URL.") + op.add_argument("--rhsm-baseurl", metavar="<content_base_url>", version=RHEL8, required=False, + help="Content base URL.") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + + for key in ns.activation_keys: + if key == "": + raise KickstartParseError(_("Empty string is not a valid activation key."), lineno=self.lineno) + + self.set_to_self(ns) + return self diff --git a/mic/3rdparty/pykickstart/commands/rootpw.py b/mic/3rdparty/pykickstart/commands/rootpw.py index 4237db8..cdc6d37 100644 --- a/mic/3rdparty/pykickstart/commands/rootpw.py +++ b/mic/3rdparty/pykickstart/commands/rootpw.py @@ -15,14 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC3, F8, F37 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) class FC3_RootPw(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -46,25 +47,44 @@ class FC3_RootPw(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.password != "": - retval += "# Root password\nrootpw%s %s\n" % (self._getArgsAsStr(), self.password) + if self.password: + if '#' in self.password: + password = '\"' + self.password + '\"' + else: + password = self.password + + retval += "# Root password\nrootpw%s %s\n" % (self._getArgsAsStr(), password) return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--iscrypted", dest="isCrypted", action="store_true", - default=False) + op = KSOptionParser(prog="rootpw", description=""" + This required command sets the system's root + password.""", version=FC3) + op.add_argument('password', metavar='<password>', nargs='?', version=FC3, + help="The desired root password.") + op.add_argument("--iscrypted", dest="isCrypted", action="store_true", + default=False, version=FC3, help=""" + If this is present, the password argument is assumed to + already be encrypted. To create an encrypted password + you can use python:: + + ``python -c 'import crypt; print(crypt.crypt("My Password", "$6$My Salt"))'`` + + This will generate sha512 crypt of your password using + your provided salt.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) - if len(extra) != 1: - raise KickstartValueError ( formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "rootpw")) + if not ns.password: + raise KickstartParseError(_("A single argument is expected for the %s command") % "rootpw", lineno=self.lineno) + elif extra: + mapping = {"command": "rootpw", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - self.password = extra[0] + self.set_to_self(ns) return self class F8_RootPw(FC3_RootPw): @@ -88,6 +108,62 @@ class F8_RootPw(FC3_RootPw): def _getParser(self): op = FC3_RootPw._getParser(self) - op.add_option("--lock", dest="lock", action="store_true", default=False) - op.add_option("--plaintext", dest="isCrypted", action="store_false") + op.add_argument("--lock", action="store_true", default=False, + version=F8, help=""" + If this is present, the root account is locked by + default. That is, the root user will not be able to + login from the console. When this option is present + the <password> argument is not required.""") + op.add_argument("--plaintext", dest="isCrypted", action="store_false", + version=F8, help=""" + The password argument is assumed to not be encrypted. + This is the default!""") + return op + +class F18_RootPw(F8_RootPw): + removedKeywords = F8_RootPw.removedKeywords + removedAttrs = F8_RootPw.removedAttrs + + def __str__(self): + retval = F8_RootPw.__str__(self) + + if not retval and self.lock: + retval = "#Root password\nrootpw --lock\n" + + return retval + + def parse(self, args): + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if not (ns.password or ns.lock): + raise KickstartParseError(_("A single argument is expected for the %s command") % "rootpw", lineno=self.lineno) + elif extra: + mapping = {"command": "rootpw", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + self.set_to_self(ns) + return self + +class F37_RootPw(F18_RootPw): + removedKeywords = F18_RootPw.removedKeywords + removedAttrs = F18_RootPw.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + F18_RootPw.__init__(self, writePriority, *args, **kwargs) + self.allow_ssh = kwargs.get("allow_ssh", False) + + def _getArgsAsStr(self): + retval = F18_RootPw._getArgsAsStr(self) + + if self.allow_ssh: + retval += " --allow-ssh" + + return retval + + def _getParser(self): + op = F18_RootPw._getParser(self) + op.add_argument("--allow-ssh", action="store_true", default=False, + version=F37, help=""" + This will allow remote root logins via ssh using only + the password. Only use as a last resort.""") return op diff --git a/mic/3rdparty/pykickstart/commands/selinux.py b/mic/3rdparty/pykickstart/commands/selinux.py index 9f8059c..4cfed0d 100644 --- a/mic/3rdparty/pykickstart/commands/selinux.py +++ b/mic/3rdparty/pykickstart/commands/selinux.py @@ -15,11 +15,12 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.options import * +from pykickstart.version import FC3 +from pykickstart.base import KickstartCommand +from pykickstart.constants import SELINUX_DISABLED, SELINUX_ENFORCING, SELINUX_PERMISSIVE +from pykickstart.options import KSOptionParser class FC3_SELinux(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -49,16 +50,29 @@ class FC3_SELinux(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--disabled", dest="selinux", action="store_const", - const=SELINUX_DISABLED) - op.add_option("--enforcing", dest="selinux", action="store_const", - const=SELINUX_ENFORCING) - op.add_option("--permissive", dest="selinux", action="store_const", - const=SELINUX_PERMISSIVE) + op = KSOptionParser(prog="selinux", description=""" + Sets the state of SELinux on the installed system. + SELinux defaults to enforcing in anaconda.""", + epilog=""" + Only one of ``--disabled``, ``--enabled`` or + ``--permissive`` must be specified!""", + version=FC3) + op.add_argument("--disabled", dest="selinux", version=FC3, + action="store_const", const=SELINUX_DISABLED, + help="If this is present, SELinux is disabled.") + op.add_argument("--enforcing", dest="selinux", version=FC3, + action="store_const", const=SELINUX_ENFORCING, + help=""" + If this is present, SELinux is set to enforcing mode. + """) + op.add_argument("--permissive", dest="selinux", version=FC3, + action="store_const", const=SELINUX_PERMISSIVE, + help=""" + If this is present, SELinux is enabled, but only logs + things that would be denied in enforcing mode.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self diff --git a/mic/3rdparty/pykickstart/commands/services.py b/mic/3rdparty/pykickstart/commands/services.py index f640822..147c76e 100644 --- a/mic/3rdparty/pykickstart/commands/services.py +++ b/mic/3rdparty/pykickstart/commands/services.py @@ -15,14 +15,14 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC6 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser, commaSplit -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC6_Services(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -39,33 +39,40 @@ class FC6_Services(KickstartCommand): retval = KickstartCommand.__str__(self) args = "" - if len(self.disabled) > 0: + if self.disabled: args += " --disabled=\"%s\"" % ",".join(self.disabled) - if len(self.enabled) > 0: + if self.enabled: args += " --enabled=\"%s\"" % ",".join(self.enabled) - if args != "": + if args: retval += "# System services\nservices%s\n" % args return retval def _getParser(self): - def services_cb (option, opt_str, value, parser): - for d in value.split(','): - parser.values.ensure_value(option.dest, []).append(d.strip()) - - op = KSOptionParser() - op.add_option("--disabled", dest="disabled", action="callback", - callback=services_cb, nargs=1, type="string") - op.add_option("--enabled", dest="enabled", action="callback", - callback=services_cb, nargs=1, type="string") + op = KSOptionParser(prog="services", description=""" + Modifies the default set of services that will run + under the default runlevel. The services listed in + the disabled list will be disabled before the + services listed in the enabled list are enabled. + """, epilog=""" + One of ``--disabled`` or ``--enabled`` must be provided. + """, version=FC6) + op.add_argument("--disabled", type=commaSplit, version=FC6, + metavar="<list>", help=""" + Disable the services given in the comma separated list. + """) + op.add_argument("--enabled", type=commaSplit, version=FC6, + metavar="<list>", help=""" + Enable the services given in the comma separated list. + """) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) - if len(self.disabled) == 0 and len(self.enabled) == 0: - raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("One of --disabled or --enabled must be provided."))) + if not (self.disabled or self.enabled): + raise KickstartParseError(_("One of --disabled or --enabled must be provided."), lineno=self.lineno) return self diff --git a/mic/3rdparty/pykickstart/commands/skipx.py b/mic/3rdparty/pykickstart/commands/skipx.py index 2067df8..b98c4d5 100644 --- a/mic/3rdparty/pykickstart/commands/skipx.py +++ b/mic/3rdparty/pykickstart/commands/skipx.py @@ -15,14 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC3 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser class FC3_SkipX(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -42,13 +39,12 @@ class FC3_SkipX(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="skipx", description=""" + If present, X is not configured on the installed + system.""", version=FC3) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if len(extra) > 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "skipx")) - + self.op.parse_args(args=args, lineno=self.lineno) self.skipx = True return self diff --git a/mic/3rdparty/pykickstart/commands/snapshot.py b/mic/3rdparty/pykickstart/commands/snapshot.py new file mode 100644 index 0000000..22d687c --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/snapshot.py @@ -0,0 +1,147 @@ +# +# Jiri Konecny <jkonecny@redhat.com> +# +# Copyright 2005, 2006, 2007, 2008, 2012, 2016, 2017 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# + +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser +from pykickstart.constants import SNAPSHOT_WHEN_POST_INSTALL, SNAPSHOT_WHEN_PRE_INSTALL +from pykickstart.version import F26 + +from pykickstart.i18n import _ + + +class F26_SnapshotData(BaseData): + removedKeywords = BaseData.removedKeywords + removedAttrs = BaseData.removedAttrs + + def __init__(self, *args, **kwargs): + BaseData.__init__(self, *args, **kwargs) + self.name = kwargs.get("name", "") + self.origin = kwargs.get("origin", "") + self.when = kwargs.get("when", None) + + def __eq__(self, y): + if not y: + return False + return (self.name == y.name and + self.origin == y.origin and + self.when == y.when) + + def __ne__(self, y): + return not self == y + + def _getArgsAsStr(self): + retval = "" + + if self.when == SNAPSHOT_WHEN_POST_INSTALL: + retval += "--when=post-install" + elif self.when == SNAPSHOT_WHEN_PRE_INSTALL: + retval += "--when=pre-install" + + return retval + + def __str__(self): + retval = BaseData.__str__(self) + retval += ("snapshot %s --name=%s %s" % (self.origin, self.name, self._getArgsAsStr())) + return retval.strip() + "\n" + + +class F26_Snapshot(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=140, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + + self.snapshotList = kwargs.get("snapshotList", []) + self.whenMap = { "post-install": SNAPSHOT_WHEN_POST_INSTALL, + "pre-install": SNAPSHOT_WHEN_PRE_INSTALL } + self.op = self._getParser() + + def __str__(self): + retval = "" + + for snapshot in self.snapshotList: + retval += snapshot.__str__() + + return retval + + def _when_cb(self, value): + if value.lower() in self.whenMap: + return self.whenMap[value.lower()] + else: + msg = _("Invalid parameter to --when= argument: %s") % value + raise KickstartParseError(msg, lineno=self.lineno) + + def _getParser(self): + op = KSOptionParser(prog="snapshot", version=F26, description=""" + Create an LVM snapshot for devices on an LVM thin pool.""") + op.add_argument("origin", metavar="<originVG/originLV>", version=F26, + help=""" + Origin of the snapshot. The origin is specified as ``<VG>/<LV>``.""") + op.add_argument("--name", metavar="<snapshot_name>", version=F26, required=True, + help=""" + Name of the newly created snapshot.""") + # Show all possible options in meta message + meta_msg = "<%s>" % ("|".join(self.whenMap.keys())) + op.add_argument("--when", metavar=meta_msg, type=self._when_cb, version=F26, + required=True, help=""" + You can specify two possible values: ``pre-install`` and ``post-install``. + When the ``pre-install`` value is used the snapshot is created before + the installation but after the ``%%pre`` section is run. + When the ``post-install`` value is used the snapshot is created after + the installation is done and after the ``%%post`` section is run.""") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + + snap_data = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, snap_data) + snap_data.lineno = self.lineno + + # Check for duplicates + if snap_data.name in [snap.name for snap in self.dataList()]: + msg = (_("Snapshot with the name %s has been already defined!") % snap_data.name) + raise KickstartParseError(msg, lineno=self.lineno) + + if snap_data.when is None: + msg = _("Snapshot \"when\" parameter must be specified!") + raise KickstartParseError(msg, lineno=self.lineno) + + groups = snap_data.origin.split('/') + if len(groups) != 2 or len(groups[0]) == 0 or len(groups[1]) == 0: + msg = (_("Snapshot origin %s must be specified by VG/LV!") % snap_data.origin) + raise KickstartParseError(msg, lineno=self.lineno) + + # Check if value in a '--when' param is valid + if snap_data.when != "" and snap_data.when not in self.whenMap.values(): + msg = (_("Snapshot when param must have one of these values %s!") % + self.whenMap.keys()) + raise KickstartParseError(msg, lineno=self.lineno) + + return snap_data + + def dataList(self): + return self.snapshotList + + @property + def dataClass(self): + return self.handler.SnapshotData diff --git a/mic/3rdparty/pykickstart/commands/sshkey.py b/mic/3rdparty/pykickstart/commands/sshkey.py new file mode 100644 index 0000000..fe6727d --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/sshkey.py @@ -0,0 +1,118 @@ +# +# Brian C. Lane <bcl@redhat.com> +# +# Copyright 2014 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import F22 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser +import warnings + +from pykickstart.i18n import _ + +class F22_SshKeyData(BaseData): + removedKeywords = BaseData.removedKeywords + removedAttrs = BaseData.removedAttrs + + def __init__(self, *args, **kwargs): + BaseData.__init__(self, *args, **kwargs) + self.username = kwargs.get("username", None) + self.key = kwargs.get("key", "") + + def __eq__(self, y): + if not y: + return False + + return self.username == y.username + + def __ne__(self, y): + return not self == y + + def __str__(self): + retval = BaseData.__str__(self) + + retval += "sshkey" + retval += self._getArgsAsStr() + '\n' + + return retval + + def _getArgsAsStr(self): + retval = "" + + retval += " --username=%s" % self.username + retval += ' "%s"' % self.key + return retval + +class F22_SshKey(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + self.sshUserList = kwargs.get("sshUserList", []) + + def __str__(self): + retval = "" + for user in self.sshUserList: + retval += user.__str__() + + return retval + + def _getParser(self): + op = KSOptionParser(prog="sshkey", description=""" + This installs a ssh key to the authorized_keys file + of the specified user on the installed system.""", + epilog=""" + Note that the key should be quoted, if it contains + spaces and the user should exist (or be root) + either via creation by a package install or the + kickstart ``user`` command.""", version=F22) + op.add_argument("--username", required=True, metavar="<user>", + version=F22, help=""" + User for which to install the specified key. This option is required.""") + op.add_argument('sshkey', metavar='"ssh key"', nargs=1, + version=F22, help=""" + The content of the ssh key to install.""") + return op + + def parse(self, args): + ud = self.dataClass() # pylint: disable=not-callable + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + assert len(ns.sshkey) == 1 + + if extra: + mapping = {"command": "sshkey", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + + self.set_to_obj(ns, ud) + ud.key = ns.sshkey[0] + ud.lineno = self.lineno + + if ud in self.dataList(): + warnings.warn(_("An ssh user with the name %s has already been defined.") % ud.username, KickstartParseWarning) + + return ud + + def dataList(self): + return self.sshUserList + + @property + def dataClass(self): + return self.handler.SshKeyData diff --git a/mic/3rdparty/pykickstart/commands/sshpw.py b/mic/3rdparty/pykickstart/commands/sshpw.py index 759dbeb..de92af3 100644 --- a/mic/3rdparty/pykickstart/commands/sshpw.py +++ b/mic/3rdparty/pykickstart/commands/sshpw.py @@ -15,14 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import F13, F24 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser +import warnings -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class F13_SshPwData(BaseData): removedKeywords = BaseData.removedKeywords @@ -36,8 +37,14 @@ class F13_SshPwData(BaseData): self.lock = kwargs.get("lock", False) def __eq__(self, y): + if not y: + return False + return self.username == y.username + def __ne__(self, y): + return not self == y + def __str__(self): retval = BaseData.__str__(self) @@ -60,6 +67,31 @@ class F13_SshPwData(BaseData): retval += " %s" % self.password return retval +class F24_SshPwData(F13_SshPwData): + removedKeywords = F13_SshPwData.removedKeywords + removedAttrs = F13_SshPwData.removedAttrs + + def __init__(self, *args, **kwargs): + F13_SshPwData.__init__(self, *args, **kwargs) + self.sshkey = kwargs.get("sshkey", False) + + def _getArgsAsStr(self): + retval = "" + + retval += " --username=%s" % self.username + if self.sshkey: + retval += ' --sshkey' + else: + if self.lock: + retval += " --lock" + if self.isCrypted: + retval += " --iscrypted" + else: + retval += " --plaintext" + + retval += " %s" % self.password + return retval + class F13_SshPw(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -78,28 +110,82 @@ class F13_SshPw(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--username", dest="username", required=True) - op.add_option("--iscrypted", dest="isCrypted", action="store_true", - default=False) - op.add_option("--plaintext", dest="isCrypted", action="store_false") - op.add_option("--lock", dest="lock", action="store_true", default=False) + op = KSOptionParser(prog="sshpw", description=""" + The installer can start up ssh to provide for + interactivity and inspection, just like it can with + telnet. The "inst.sshd" option must be specified on + the kernel command-line for Anaconda to start an ssh + daemon. The sshpw command is used to control the + accounts created in the installation environment that + may be remotely logged into. For each instance of + this command given, a user will be created. These + users will not be created on the final system - + they only exist for use while the installer is + running. + + Note that by default, root has a blank password. If + you don't want any user to be able to ssh in and + have full access to your hardware, you must specify + sshpw for username root. Also note that if Anaconda + fails to parse the kickstart file, it will allow + anyone to login as root and have full access to + your hardware.""", version=F13) + op.add_argument("--username", required=True, metavar="<name>", + version=F13, help=""" + Provides the name of the user. This option is required. + """) + op.add_argument("--iscrypted", dest="isCrypted", action="store_true", + default=False, version=F13, help=""" + If this is present, the password argument is assumed to + already be encrypted.""") + op.add_argument("--plaintext", dest="isCrypted", action="store_false", + version=F13, help=""" + If this is present, the password argument is assumed to + not be encrypted. This is the default.""") + op.add_argument("--lock", action="store_true", default=False, + version=F13, help=""" + If this is present, the new user account is locked by + default. That is, the user will not be able to login + from the console.""") + op.add_argument("password", metavar="<password>", nargs="*", + version=F13, help=""" + The password string to use.""") return op def parse(self, args): - ud = self.handler.SshPwData() - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToObj(self.op, opts, ud) - ud.lineno = self.lineno + ud = self.dataClass() # pylint: disable=not-callable + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if not ns.password: + raise KickstartParseError(_("A single argument is expected for the %s command") % "sshpw", lineno=self.lineno) + if extra: + mapping = {"command": "sshpw", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - if len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "sshpw")) - ud.password = extra[0] + self.set_to_obj(ns, ud) + ud.password = " ".join(ns.password) + ud.lineno = self.lineno if ud in self.dataList(): - warnings.warn(_("An ssh user with the name %s has already been defined.") % ud.name) + warnings.warn(_("An ssh user with the name %s has already been defined.") % ud.username, KickstartParseWarning) return ud def dataList(self): return self.sshUserList + + @property + def dataClass(self): + return self.handler.SshPwData + +class F24_SshPw(F13_SshPw): + removedKeywords = F13_SshPw.removedKeywords + removedAttrs = F13_SshPw.removedAttrs + + def _getParser(self): + op = F13_SshPw._getParser(self) + op.add_argument("--sshkey", action="store_true", default=False, + version=F24, help=""" + If this is used then the <password> string is + interpreted as an ssh key value.""") + return op diff --git a/mic/3rdparty/pykickstart/commands/syspurpose.py b/mic/3rdparty/pykickstart/commands/syspurpose.py new file mode 100644 index 0000000..b1a2beb --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/syspurpose.py @@ -0,0 +1,90 @@ +# +# Martin Kolman <mkolman@redhat.com> +# +# Copyright 2018 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# + +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser +from pykickstart.version import RHEL8 + +from pykickstart.i18n import _ + +class RHEL8_Syspurpose(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + self.role = kwargs.get("role", None) + self.sla = kwargs.get("sla", None) + self.usage = kwargs.get("usage", None) + self.addons = kwargs.get("addons", None) + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if not retval and not any([self.role, self.sla, self.usage, self.addons]): + return "" + + retval += '# Intended system purpose\nsyspurpose' + if self.role: + retval+=' --role="%s"' % self.role + if self.sla: + retval+=' --sla="%s"' % self.sla + if self.usage: + retval+=' --usage="%s"' % self.usage + if self.addons: + for addon in self.addons: + retval+=' --addon="%s"' % addon + retval+='\n' + return retval + + def _getParser(self): + op = KSOptionParser(prog="syspurpose", description=""" + The syspurpose command is used to describe + how the system is intended to be used after the installation. + + This information then can be used to apply the + correct subscription entitlement to the system.""", version=RHEL8) + op.add_argument("--role", metavar="<role_name>", version=RHEL8, required=False, + help=""" + The intended role of the system.""") + op.add_argument("--sla", metavar="<sla_name>", version=RHEL8, required=False, + help=""" + Name of the sla intended for the system.""") + op.add_argument("--usage", metavar="<usage>", version=RHEL8, required=False, + help=""" + The intended usage of the system.""") + op.add_argument("--addon", metavar="<layered product or feature>", version=RHEL8, required=False, + action="append", dest="addons", help=""" + Any additional layered products or features. To add multiple items specify + --addon multiple times, once per layered product/feature.""") + return op + + def parse(self, args): + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + + if len(extra) > 0: + msg = _("The syspurpose command does not take positional arguments!") + raise KickstartParseError(msg, lineno=self.lineno) + + self.set_to_self(ns) + return self diff --git a/mic/3rdparty/pykickstart/commands/timesource.py b/mic/3rdparty/pykickstart/commands/timesource.py new file mode 100644 index 0000000..10778b6 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/timesource.py @@ -0,0 +1,148 @@ +# +# Copyright 2020 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.errors import KickstartParseError +from pykickstart.version import F33 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ + +class F33_TimesourceData(BaseData): + removedKeywords = BaseData.removedKeywords + removedAttrs = BaseData.removedAttrs + + def __init__(self, *args, **kwargs): + BaseData.__init__(self, *args, **kwargs) + self.ntp_server = kwargs.get("ntp_server", "") + self.ntp_pool = kwargs.get("ntp_pool", "") + self.ntp_disable = kwargs.get("ntp_disable", False) + self.nts = kwargs.get("nts", False) + + def __eq__(self, y): + if not y: + return False + + if self.ntp_server: + return self.ntp_server == y.ntp_server and self.nts == y.nts + elif self.ntp_pool: + return self.ntp_pool == y.ntp_pool and self.nts == y.nts + else: + # given that one of ntp_server/ntp_pool/ntp_disable is required + # this will be --ntp_disable & such timesource invocations will + # always be the same by definition + return True + + def __ne__(self, y): + return not self == y + + def __str__(self): + retval = BaseData.__str__(self) + + args = self._getArgsAsStr() + if args: + retval += "timesource%s\n" % args + + return retval + + def _getArgsAsStr(self): + retval = "" + + if self.ntp_server: + retval += " --ntp-server=%s" % self.ntp_server + if self.ntp_pool: + retval += " --ntp-pool=%s" % self.ntp_pool + if self.nts: + retval += " --nts" + if self.ntp_disable: + retval += " --ntp-disable" + + return retval + + +class F33_Timesource(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + self.timesource_list = kwargs.get("timesource_list", []) + self.exclusive_required_options = [("ntp_server", "--ntp-server"), + ("ntp_pool", "--ntp-pool"), + ("ntp_disable", "--ntp-disable")] + + def __str__(self): + retval = "" + for timesource_command in self.timesource_list: + retval += timesource_command.__str__() + + return retval + + def _getParser(self): + op = KSOptionParser(prog="timesource", description=""" + Configures a timesource.""", + version=F33) + op.add_argument("--ntp-server", version=F33, help=""" + A single NTP server. + + ``--ntp-server``, ``--ntp-pool`` and ``--ntp-disable`` are mutually exclusive. + """) + op.add_argument("--ntp-pool", version=F33, help=""" + A single NTP pool. + + ``--ntp-pool``, ``--ntp-server`` and ``--ntp-disable`` are mutually exclusive. + """) + op.add_argument("--ntp-disable", action="store_true", + default=False, version=F33, help=""" + If specified, disable any NTP based time sync, + both on target system as well as in installation + environment. + """) + op.add_argument("--nts", dest="nts", action="store_true", + default=False, version=F33, help=""" + If specified, consider the provided hostname to be + a NTS compatible time source. Without the ``--nts`` + option it will be considered to be a plain NTP time + source without NTS support. + """) + return op + + def parse(self, args): + td = self.dataClass() # pylint: disable=not-callable + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_obj(ns, td) + td.lineno = self.lineno + + # Check that just one of exclusive required options is specified + used_options = [opt for attr, opt in self.exclusive_required_options + if getattr(ns, attr, None)] + if len(used_options) == 0: + mapping = {"options_list": ", ".join((opt for attr, opt in self.exclusive_required_options))} + raise KickstartParseError(_("One of -%(options_list)s options must be specified for timesource command.") % mapping, lineno=self.lineno) + if len(used_options) > 1: + mapping = {"options_list": ", ".join((opt for opt in used_options))} + raise KickstartParseError(_("Only one of %(options_list)s options may be specified for timesource command.") % mapping, lineno=self.lineno) + + return td + + def dataList(self): + return self.timesource_list + + @property + def dataClass(self): + return self.handler.TimesourceData diff --git a/mic/3rdparty/pykickstart/commands/timezone.py b/mic/3rdparty/pykickstart/commands/timezone.py index 06d09d6..6f6d412 100644 --- a/mic/3rdparty/pykickstart/commands/timezone.py +++ b/mic/3rdparty/pykickstart/commands/timezone.py @@ -15,14 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +import warnings +from pykickstart.version import FC3, FC6, F18 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartDeprecationWarning +from pykickstart.options import KSOptionParser, commaSplit -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_Timezone(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -38,29 +39,49 @@ class FC3_Timezone(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.timezone != "": + if self.timezone: if self.isUtc: utc = "--utc" else: utc = "" - retval += "# System timezone\ntimezone %s %s\n" %(utc, self.timezone) + retval += "# System timezone\ntimezone %s %s\n" % (utc, self.timezone) return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--utc", dest="isUtc", action="store_true", default=False) + op = KSOptionParser(prog="timezone", description=""" + This required command sets the system time zone to + which may be any of the time zones listed by + timeconfig.""", version=FC3) + op.add_argument("--utc", dest="isUtc", action="store_true", + default=False, version=FC3, help=""" + If present, the system assumes the hardware clock is set + to UTC (Greenwich Mean) time. + + *To get the list of supported timezones, you can either + run this script: + http://vpodzime.fedorapeople.org/timezones_list.py or + look at this list: + http://vpodzime.fedorapeople.org/timezones_list.txt* + """) + op.add_argument("timezone", metavar="<timezone>", nargs=1, + version=FC3, help=""" + Timezone name, e.g. Europe/Sofia.""") return op + # Caution: This method is overridden in the RHEL7_Timezone & F25_Timezone classes + # by a new implementation not calling this method. def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + assert len(ns.timezone) == 1 - if len(extra) != 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("A single argument is expected for the %s command") % "timezone")) + if extra: + mapping = {"command": "timezone", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) - self.timezone = extra[0] + self.timezone = ns.timezone[0] return self class FC6_Timezone(FC3_Timezone): @@ -70,17 +91,355 @@ class FC6_Timezone(FC3_Timezone): def __str__(self): retval = KickstartCommand.__str__(self) - if self.timezone != "": + if self.timezone: if self.isUtc: utc = "--isUtc" else: utc = "" - retval += "# System timezone\ntimezone %s %s\n" %(utc, self.timezone) + retval += "# System timezone\ntimezone %s %s\n" % (utc, self.timezone) return retval def _getParser(self): op = FC3_Timezone._getParser(self) - op.add_option("--utc", "--isUtc", dest="isUtc", action="store_true", default=False) + op.add_argument("--utc", "--isUtc", dest="isUtc", action="store_true", + default=False, version=FC6, help=""" + The ``--isUtc`` option was added.""") + return op + +class F18_Timezone(FC6_Timezone): + def __init__(self, writePriority=0, *args, **kwargs): + FC6_Timezone.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + self.nontp = kwargs.get("nontp", False) + self.ntpservers = kwargs.get("ntpservers", set()) + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.timezone: + retval += "# System timezone\n" + retval += "timezone " + self._getArgsAsStr() + "\n" + + return retval + + def _getArgsAsStr(self): + retval = self.timezone + + if self.isUtc: + retval += " --isUtc" + + if self.nontp: + retval += " --nontp" + + if self.ntpservers: + retval += " --ntpservers=" + ",".join(self.ntpservers) + + return retval + + def _getParser(self): + op = FC6_Timezone._getParser(self) + op.add_argument("--nontp", action="store_true", default=False, + version=F18, help=""" + Disable automatic starting of NTP service. + + ``--nontp`` and ``--ntpservers`` are mutually exclusive. + """) + op.add_argument("--ntpservers", dest="ntpservers", type=commaSplit, + metavar="<server1>,<server2>,...,<serverN>", + version=F18, help=""" + Specify a list of NTP servers to be used (comma-separated + list with no spaces). The chrony package is automatically + installed when this option is used. If you don't want the + package to be automatically installed then use ``-chrony`` + in package selection. For example:: + + ``timezone --ntpservers=ntp.cesnet.cz,tik.nic.cz Europe/Prague`` + """) return op + + # Caution: The parse() method is overridden in the RHEL7_Timezone & F25_Timezone classes + # by a new implementation not calling this method. + def parse(self, args): + FC6_Timezone.parse(self, args) + + # NTP servers can only be listed once in F18, so weed out the duplicates now. + self.ntpservers = list(set(self.ntpservers)) + + if self.ntpservers and self.nontp: + msg = _("Options --nontp and --ntpservers are mutually exclusive") + raise KickstartParseError(msg, lineno=self.lineno) + + return self + +class F23_Timezone(F18_Timezone): + def __init__(self, *args, **kwargs): + F18_Timezone.__init__(self, *args, **kwargs) + self.ntpservers = kwargs.get("ntpservers", list()) + + # Caution: This method is overridden in the RHEL7_Timezone & F25_Timezone classes + # by a new implementation not calling this method. + def parse(self, args): + FC6_Timezone.parse(self, args) + + if self.ntpservers and self.nontp: + msg = _("Options --nontp and --ntpservers are mutually exclusive") + raise KickstartParseError(msg, lineno=self.lineno) + + return self + +# About the RHEL7_Timezone & F25_Timezone command classes +# ======================================================= +# +# The F18_Timezone command class used in RHEL <=7.2 the F23_Timezone +# command class used in Fedora <=24 the always required a timezone +# specification to be provided. +# +# On the other hand the timezone command has also some commands that don't +# really need a timezone to be specified to work, like "--utc/--isutc". +# +# So if you for example wanted to set the hwclock to the UTC mode but still +# wanted the user to set a timezone manually in the UI (by not providing a +# timezone specification), you were out of luck - a timezone parsing error +# would be raised. +# +# To fix this we need to remove the requirement on always providing one +# argument to the timezone command. As the requirement is present +# quite deep in the class hierarchy (in the original FC3_Timezone class) +# we reimplement the parse() method in the RHEL7_Timezone and F25_Timezone +# classes and avoid calling the ancestors parse(), as it otherwise done in all +# other command child classes. + +class RHEL7_Timezone(F18_Timezone): + def __init__(self, writePriority=0, *args, **kwargs): + F18_Timezone.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + def _getParser(self): + op = KSOptionParser(prog="timezone", description=""" + This required command sets the system time zone to + which may be any of the time zones listed by + timeconfig.""", version=FC3) + op.add_argument("timezone", metavar="<timezone>", nargs="*", + version=FC3, help=""" + Timezone name, e.g. Europe/Sofia. + This is optional but at least one of the options needs + to be used if no timezone is specified. + """) + op.add_argument("--utc", "--isUtc", dest="isUtc", action="store_true", + default=False, version=FC6, help=""" + If present, the system assumes the hardware clock is set + to UTC (Greenwich Mean) time. + + *To get the list of supported timezones, you can either + run this script: + http://vpodzime.fedorapeople.org/timezones_list.py or + look at this list: + http://vpodzime.fedorapeople.org/timezones_list.txt* + """) + op.add_argument("--nontp", action="store_true", default=False, + version=F18, help=""" + Disable automatic starting of NTP service. + + ``--nontp`` and ``--ntpservers`` are mutually exclusive. + """) + op.add_argument("--ntpservers", dest="ntpservers", type=commaSplit, + metavar="<server1>,<server2>,...,<serverN>", + version=F18, help=""" + Specify a list of NTP servers to be used (comma-separated + list with no spaces). The chrony package is automatically + installed when this option is used. If you don't want the + package to be automatically installed then use ``-chrony`` + in package selection. For example:: + + ``timezone --ntpservers=ntp.cesnet.cz,tik.nic.cz Europe/Prague`` + """) + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + + # just "timezone" without any arguments and timezone specification doesn't really make sense, + # so throw an error when we see it (it might even be an indication of an incorrect machine generated kickstart) + if not args: + error_message = _("At least one option and/or an argument are expected for the %s command") % "timezone" + raise KickstartParseError(error_message, lineno=self.lineno) + + # To be able to support the timezone command being used without + # a timezone specification: + # - we don't call the parse() method of the ancestors + # -> due to the FC3 parse() method that would be eventually called, + # which throws an exception if no timezone specification is provided + # - we implement the relevant functionality of the ancestor methods here + + if len(ns.timezone) == 1: + self.timezone = ns.timezone[0] + elif len(ns.timezone) > 1: + error_message = _("One or zero arguments are expected for the %s command") % "timezone" + raise KickstartParseError(error_message, lineno=self.lineno) + + if self.ntpservers and self.nontp: + msg = _("Options --nontp and --ntpservers are mutually exclusive") + raise KickstartParseError(msg, lineno=self.lineno) + + return self + +class F25_Timezone(F23_Timezone): + def __init__(self, writePriority=0, *args, **kwargs): + F23_Timezone.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + def __str__(self): + retval = KickstartCommand.__str__(self) + args = self._getArgsAsStr() + if args: + retval += "# System timezone\n" + retval += "timezone" + args + "\n" + + return retval + + def _getArgsAsStr(self): + retval = "" + + if self.timezone: + retval += " " + self.timezone + + if self.isUtc: + retval += " --isUtc" + + if self.nontp: + retval += " --nontp" + + if self.ntpservers: + retval += " --ntpservers=" + ",".join(self.ntpservers) + + return retval + + def _getParser(self): + op = KSOptionParser(prog="timezone", description=""" + This required command sets the system time zone to + which may be any of the time zones listed by + timeconfig.""", version=FC3) + op.add_argument("timezone", metavar="<timezone>", nargs="*", + version=FC3, help=""" + Timezone name, e.g. Europe/Sofia. + This is optional but at least one of the options needs + to be used if no timezone is specified. + """) + op.add_argument("--utc", "--isUtc", dest="isUtc", action="store_true", + default=False, version=FC6, help=""" + If present, the system assumes the hardware clock is set + to UTC (Greenwich Mean) time. + + *To get the list of supported timezones, you can either + run this script: + http://vpodzime.fedorapeople.org/timezones_list.py or + look at this list: + http://vpodzime.fedorapeople.org/timezones_list.txt* + """) + op.add_argument("--nontp", action="store_true", default=False, + version=F18, help=""" + Disable automatic starting of NTP service. + + ``--nontp`` and ``--ntpservers`` are mutually exclusive. + """) + op.add_argument("--ntpservers", dest="ntpservers", type=commaSplit, + metavar="<server1>,<server2>,...,<serverN>", + version=F18, help=""" + Specify a list of NTP servers to be used (comma-separated + list with no spaces). The chrony package is automatically + installed when this option is used. If you don't want the + package to be automatically installed then use ``-chrony`` + in package selection. For example:: + + ``timezone --ntpservers=ntp.cesnet.cz,tik.nic.cz Europe/Prague`` + """) + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + + # just "timezone" without any arguments and timezone specification doesn't really make sense, + # so throw an error when we see it (it might even be an indication of an incorrect machine generated kickstart) + if not args: + error_message = _("At least one option and/or an argument are expected for the %s command") % "timezone" + raise KickstartParseError(error_message, lineno=self.lineno) + + # To be able to support the timezone command being used without + # a timezone specification: + # - we don't call the parse() method of the ancestors + # -> due to the FC3 parse() method that would be eventually called, + # which throws an exception if no timezone specification is provided + # - we implement the relevant functionality of the ancestor methods here + + if len(ns.timezone) == 1: + self.timezone = ns.timezone[0] + elif len(ns.timezone) > 1: + error_message = _("One or zero arguments are expected for the %s command") % "timezone" + raise KickstartParseError(error_message, lineno=self.lineno) + + if self.ntpservers and self.nontp: + msg = _("Options --nontp and --ntpservers are mutually exclusive") + raise KickstartParseError(msg, lineno=self.lineno) + + return self + +class F32_Timezone(F25_Timezone): + + def __init__(self, writePriority=0, *args, **kwargs): + F25_Timezone.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + def _getArgsAsStr(self): + retval = "" + + if self.timezone: + retval += " " + self.timezone + + if self.isUtc: + retval += " --utc" + + if self.nontp: + retval += " --nontp" + + if self.ntpservers: + retval += " --ntpservers=" + ",".join(self.ntpservers) + + return retval + + def parse(self, args): + F25_Timezone.parse(self, args) + + if "--isUtc" in args: + warnings.warn(_("The option --isUtc will be deprecated in future releases. Please " + "modify your kickstart file to replace this option with its preferred " + "alias --utc."), + KickstartDeprecationWarning) + + return self + + +class F33_Timezone(F32_Timezone): + + def __init__(self, writePriority=0, *args, **kwargs): + F32_Timezone.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + + def parse(self, args): + F32_Timezone.parse(self, args) + + if self.ntpservers: + warnings.warn(_("The option --ntpservers will be deprecated in future releases. Please " + "modify your kickstart file to replace this option with " + "timesource --ntp-server <server hostname> command invocation, " + "one per NTP server."), + KickstartDeprecationWarning) + if self.nontp: + warnings.warn(_("The option --nontp will be deprecated in future releases. Please " + "modify your kickstart file to replace this option with " + "timesource --ntp-disable command invocation."), + KickstartDeprecationWarning) + return self diff --git a/mic/3rdparty/pykickstart/commands/unsupported_hardware.py b/mic/3rdparty/pykickstart/commands/unsupported_hardware.py new file mode 100644 index 0000000..d646773 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/unsupported_hardware.py @@ -0,0 +1,48 @@ +# +# Brian C. Lane <bcl@redhat.com> +# +# Copyright 2012 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import RHEL6 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser + +class RHEL6_UnsupportedHardware(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + self.unsupported_hardware = kwargs.get("unsupported_hardware", False) + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.unsupported_hardware: + retval += "unsupported_hardware\n" + + return retval + + def _getParser(self): + op = KSOptionParser(prog="unsupported_hardware", description="allow installation to proceed on systems with tainted hardware", version=RHEL6) + return op + + def parse(self, args): + self.op.parse_args(args=args, lineno=self.lineno) + self.unsupported_hardware = True + return self diff --git a/mic/3rdparty/pykickstart/commands/updates.py b/mic/3rdparty/pykickstart/commands/updates.py index 6e18af9..637a7d1 100644 --- a/mic/3rdparty/pykickstart/commands/updates.py +++ b/mic/3rdparty/pykickstart/commands/updates.py @@ -15,14 +15,16 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from textwrap import dedent -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import F7, F34, versionToLongString +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ class F7_Updates(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -38,23 +40,78 @@ class F7_Updates(KickstartCommand): if self.url == "floppy": retval += "updates\n" - elif self.url != "": + elif self.url: retval += "updates %s\n" % self.url return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="updates", description=""" + Specify the location of an updates.img for use in + installation. See anaconda-release-notes.txt for a + description of how to make an updates.img.""", + version=F7) + op.add_argument("updates", metavar="[URL]", nargs="*", version=F7, + help=""" + If present, the URL for an updates image. + + If not present, anaconda will attempt to load from a + floppy disk.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + (_ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) - if len(extra) > 1: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s only takes one argument") % "updates")) - elif len(extra) == 0: + if len(_ns.updates) > 1: + raise KickstartParseError(_("Kickstart command %s only takes one argument") % "updates", lineno=self.lineno) + elif extra: + mapping = {"command": "updates", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + elif not _ns.updates: self.url = "floppy" else: - self.url = extra[0] + self.url = _ns.updates[0] + + return self + + +class F34_Updates(F7_Updates): + removedKeywords = F7_Updates.removedKeywords + removedAttrs = F7_Updates.removedAttrs + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.url: + retval += "updates %s\n" % self.url + + return retval + + def _getParser(self): + op = KSOptionParser( + prog="updates", version=F7, description=""" + Specify the location of an updates.img for use in installation. + """ + ) + url_action = op.add_argument( + "url", metavar="[URL]", version=F7, help=""" + If present, the URL for an updates image. + If not present, anaconda will attempt to load from a floppy disk. + """ + ) + url_action.help += dedent( + """ + + .. versionchanged:: %s + + The URL for an updates image is required. Anaconda no longer supports + updates on a floppy disk. + """ % versionToLongString(F34) + ) + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self diff --git a/mic/3rdparty/pykickstart/commands/upgrade.py b/mic/3rdparty/pykickstart/commands/upgrade.py index 5f44ea1..58ef7b3 100644 --- a/mic/3rdparty/pykickstart/commands/upgrade.py +++ b/mic/3rdparty/pykickstart/commands/upgrade.py @@ -15,14 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from textwrap import dedent +from pykickstart.version import versionToLongString, FC3, F11, F20, F29 +from pykickstart.base import DeprecatedCommand, KickstartCommand, RemovedCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_Upgrade(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -47,14 +48,18 @@ class FC3_Upgrade(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="install|upgrade", description=""" + Install a fresh system or upgrade an existing system. + Install is the default mode. For installation, you must + specify the type of installation from one of + cdrom, harddrive, nfs, or url (for ftp or http installations). + The install command and the installation method command + must be on separate lines.""", + version=FC3) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if len(extra) > 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")) + self.op.parse_args(args=args, lineno=self.lineno) if self.currentCmd == "upgrade": self.upgrade = True @@ -83,20 +88,22 @@ class F11_Upgrade(FC3_Upgrade): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--root-device", dest="root_device") + op = FC3_Upgrade._getParser(self) + op.add_argument("--root-device", dest="root_device", version=F11, + help=""" + On a system with multiple installs, this option specifies which + filesystem holds the installation to be upgraded. This can be + specified by device name, UUID=, or LABEL= just like the harddrive + command may be.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if len(extra) > 0: - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")) + ns = self.op.parse_args(args=args, lineno=self.lineno) - if (opts.root_device is not None) and (opts.root_device == ""): - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device"))) + if ns.root_device == "": + raise KickstartParseError(_("Kickstart command %(command)s does not accept empty parameter %(parameter)s") % {"command": "upgrade", "parameter": "--root-device"}, lineno=self.lineno) else: - self.root_device = opts.root_device + self.root_device = ns.root_device if self.currentCmd == "upgrade": self.upgrade = True @@ -104,3 +111,26 @@ class F11_Upgrade(FC3_Upgrade): self.upgrade = False return self + +class F20_Upgrade(DeprecatedCommand, F11_Upgrade): + def __init__(self): # pylint: disable=super-init-not-called + DeprecatedCommand.__init__(self) + + def _getParser(self): + op = F11_Upgrade._getParser(self) + op.description += dedent(""" + + .. deprecated:: %s + + Starting with F18, upgrades are no longer supported in + anaconda and should be done with FedUp, the Fedora update + tool. Starting with F21, the DNF system-upgrade plugin is + recommended instead. Therefore, the upgrade command + essentially does nothing.""" % versionToLongString(F20)) + return op + +class F29_Upgrade(RemovedCommand, F20_Upgrade): + def _getParser(self): + op = F20_Upgrade._getParser(self) + op.description += "\n\n.. versionremoved:: %s" % versionToLongString(F29) + return op diff --git a/mic/3rdparty/pykickstart/commands/url.py b/mic/3rdparty/pykickstart/commands/url.py new file mode 100644 index 0000000..f10cb0a --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/url.py @@ -0,0 +1,301 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2007, 2009, 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.version import FC3, F13, F14, F18, F27, F30 +from pykickstart.base import KickstartCommand +from pykickstart.errors import KickstartParseError +from pykickstart.options import KSOptionParser + +from pykickstart.i18n import _ + +class FC3_Url(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=0, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.url = kwargs.get("url", None) + + self.op = self._getParser() + + def __eq__(self, other): + if not other: + return False + + return self.url == other.url + + def __ne__(self, other): + return not self == other + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.seen: + retval += "# Use network installation\nurl --url=\"%s\"\n" % self.url + + return retval + + def _getParser(self): + op = KSOptionParser(prog="url", description=""" + Install from an installation tree on a remote server + via FTP or HTTP.""", version=FC3) + op.add_argument("--url", required=True, version=FC3, help=""" + The URL to install from. Variable substitution is done + for $releasever and $basearch in the url.""") + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + return self + +class F13_Url(FC3_Url): + removedKeywords = FC3_Url.removedKeywords + removedAttrs = FC3_Url.removedAttrs + + def __init__(self, *args, **kwargs): + FC3_Url.__init__(self, *args, **kwargs) + self.proxy = kwargs.get("proxy", "") + + def __eq__(self, other): + if not FC3_Url.__eq__(self, other): + return False + + return self.proxy == other.proxy + + def __str__(self): + retval = FC3_Url.__str__(self) + + if self.seen and self.proxy: + retval = retval.strip() + retval += " --proxy=\"%s\"\n" % self.proxy + + return retval + + def _getParser(self): + op = FC3_Url._getParser(self) + op.add_argument("--proxy", metavar="URL", version=F13, + help=""" + Specify an HTTP/HTTPS/FTP proxy to use while performing + the install. The various parts of the argument act like + you would expect. The syntax is:: + + [protocol://][username[:password]@]host[:port] + """) + return op + +class F14_Url(F13_Url): + removedKeywords = F13_Url.removedKeywords + removedAttrs = F13_Url.removedAttrs + + def __init__(self, *args, **kwargs): + F13_Url.__init__(self, *args, **kwargs) + self.noverifyssl = kwargs.get("noverifyssl", False) + + def __eq__(self, other): + if not F13_Url.__eq__(self, other): + return False + + return self.noverifyssl == other.noverifyssl + + def __str__(self): + retval = F13_Url.__str__(self) + + if self.seen and self.noverifyssl: + retval = retval.strip() + retval += " --noverifyssl\n" + + return retval + + def _getParser(self): + op = F13_Url._getParser(self) + op.add_argument("--noverifyssl", action="store_true", version=F14, + default=False, help=""" + For a tree on a HTTPS server do not check the server's + certificate with what well-known CA validate and do not + check the server's hostname matches the certificate's + domain name.""") + return op + +class RHEL6_Url(F14_Url): + pass + +class F18_Url(F14_Url): + removedKeywords = F14_Url.removedKeywords + removedAttrs = F14_Url.removedAttrs + + def __init__(self, *args, **kwargs): + F14_Url.__init__(self, *args, **kwargs) + self.mirrorlist = kwargs.get("mirrorlist", None) + self.exclusive_required_options = [("mirrorlist", "--mirrorlist"), + ("url", "--url")] + + def __eq__(self, other): + if not F14_Url.__eq__(self, other): + return False + + return self.mirrorlist == other.mirrorlist + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use network installation\n" + + if self.url: + retval += "url --url=\"%s\"" % self.url + elif self.mirrorlist: + retval += "url --mirrorlist=\"%s\"" % self.mirrorlist + + if self.proxy: + retval += " --proxy=\"%s\"" % self.proxy + + if self.noverifyssl: + retval += " --noverifyssl" + + return retval + "\n" + + def _getParser(self): + op = F14_Url._getParser(self) + op.add_argument("--url", version=F18, help=""" + Only one of the --url or --mirrorlist can be specified.""") + op.add_argument("--mirrorlist", metavar="URL", version=F18, help=""" + The mirrorlist URL to install from. Variable substitution + is done for $releasever and $basearch in the url.""") + return op + + def parse(self, args): + retval = F14_Url.parse(self, args) + + ns = self.op.parse_args(args=args, lineno=self.lineno) + # Check that just one of exclusive required options is specified + used_options = [opt for attr, opt in self.exclusive_required_options + if getattr(ns, attr, None)] + if len(used_options) == 0: + mapping = {"options_list": ", ".join((opt for attr, opt in self.exclusive_required_options))} + raise KickstartParseError(_("One of -%(options_list)s options must be specified for url command.") % mapping, lineno=self.lineno) + if len(used_options) > 1: + mapping = {"options_list": ", ".join((opt for opt in used_options))} + raise KickstartParseError(_("Only one of %(options_list)s options may be specified for url command.") % mapping, lineno=self.lineno) + + return retval + +class F27_Url(F18_Url): + removedKeywords = F18_Url.removedKeywords + removedAttrs = F18_Url.removedAttrs + + def __init__(self, *args, **kwargs): + F18_Url.__init__(self, *args, **kwargs) + self.metalink = kwargs.get("metalink", None) + self.exclusive_required_options.append(("metalink", "--metalink")) + + def __eq__(self, other): + if not F18_Url.__eq__(self, other): + return False + + return self.metalink == other.metalink + + def __str__(self): + retval = KickstartCommand.__str__(self) + if not self.seen: + return retval + + retval += "# Use network installation\n" + + if self.url: + retval += "url --url=\"%s\"" % self.url + elif self.mirrorlist: + retval += "url --mirrorlist=\"%s\"" % self.mirrorlist + elif self.metalink: + retval += "url --metalink=\"%s\"" % self.metalink + + if self.proxy: + retval += " --proxy=\"%s\"" % self.proxy + + if self.noverifyssl: + retval += " --noverifyssl" + + return retval + "\n" + + def _getParser(self): + op = F18_Url._getParser(self) + op.add_argument("--url", version=F27, help=""" + Only one of the --url, --mirrorlist or --metalink can + be specified.""") + op.add_argument("--metalink", metavar="URL", version=F27, help=""" + The metalink URL to install from. Variable substitution + is done for $releasever and $basearch in the url.""") + return op + +class F30_Url(F27_Url): + removedKeywords = F27_Url.removedKeywords + removedAttrs = F27_Url.removedAttrs + + def __init__(self, *args, **kwargs): + F27_Url.__init__(self, *args, **kwargs) + self.sslcacert = kwargs.get("sslcacert", None) + self.sslclientcert = kwargs.get("sslclientcert", None) + self.sslclientkey = kwargs.get("sslclientkey", None) + + def __str__(self): + retval = F27_Url.__str__(self) + if not self.seen: + return retval + + retval = retval[:-1] # strip '\n' + + if self.sslcacert: + retval += " --sslcacert=\"%s\"" % self.sslcacert + + if self.sslclientcert: + retval += " --sslclientcert=\"%s\"" % self.sslclientcert + + if self.sslclientkey: + retval += " --sslclientkey=\"%s\"" % self.sslclientkey + + return retval + "\n" + + def _getParser(self): + op = F27_Url._getParser(self) + op.add_argument("--sslcacert", version=F30, help=""" + Path to the file holding one or more SSL certificates + to verify the repository host with. + + **Note** Usage of this parameter is discouraged. It is + designed for a specific image building tool use and + there are plans for a replacement.""") + op.add_argument("--sslclientcert", version=F30, help=""" + Path to the SSL client certificate (PEM file) which + should be used to connect to the repository. + + **Note** Usage of this parameter is discouraged. It is + designed for a specific image building tool use and + there are plans for a replacement.""") + op.add_argument("--sslclientkey", version=F30, help=""" + Path to the private key file associated with the client + certificate given with --sslclientcert. + + **Note** Usage of this parameter is discouraged. It is + designed for a specific image building tool use and + there are plans for a replacement.""") + return op + +class RHEL8_Url(F30_Url): + pass diff --git a/mic/3rdparty/pykickstart/commands/user.py b/mic/3rdparty/pykickstart/commands/user.py index 189dc75..a20d16c 100644 --- a/mic/3rdparty/pykickstart/commands/user.py +++ b/mic/3rdparty/pykickstart/commands/user.py @@ -15,16 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.constants import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.errors import KickstartParseWarning +from pykickstart.version import FC6, F8, F12, F19, F24 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.options import KSOptionParser, commaSplit -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC6_UserData(BaseData): removedKeywords = BaseData.removedKeywords @@ -41,28 +40,37 @@ class FC6_UserData(BaseData): self.uid = kwargs.get("uid", None) def __eq__(self, y): + if not y: + return False + return self.name == y.name + def __ne__(self, y): + return not self == y + def __str__(self): retval = BaseData.__str__(self) - if self.uid != "": - retval += "user" - retval += self._getArgsAsStr() + "\n" + args = self._getArgsAsStr() + if args: + retval += "user%s\n" % args return retval def _getArgsAsStr(self): retval = "" - if len(self.groups) > 0: + if self.groups: retval += " --groups=%s" % ",".join(self.groups) if self.homedir: retval += " --homedir=%s" % self.homedir if self.name: retval += " --name=%s" % self.name if self.password: - retval += " --password=%s" % self.password + if '#' in self.password: + retval += " --password=\"%s\"" % self.password + else: + retval += " --password=%s" % self.password if self.isCrypted: retval += " --iscrypted" if self.shell: @@ -104,6 +112,23 @@ class F12_UserData(F8_UserData): return retval +class F19_UserData(F12_UserData): + removedKeywords = F12_UserData.removedKeywords + removedAttrs = F12_UserData.removedAttrs + + def __init__(self, *args, **kwargs): + F12_UserData.__init__(self, *args, **kwargs) + self.gid = kwargs.get("gid", None) + + def _getArgsAsStr(self): + retval = F12_UserData._getArgsAsStr(self) + + if self.gid: + retval += " --gid=%d" % (self.gid,) + + return retval + + class FC6_User(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords removedAttrs = KickstartCommand.removedAttrs @@ -122,45 +147,81 @@ class FC6_User(KickstartCommand): return retval def _getParser(self): - def groups_cb (option, opt_str, value, parser): - for d in value.split(','): - parser.values.ensure_value(option.dest, []).append(d) - - op = KSOptionParser() - op.add_option("--groups", dest="groups", action="callback", - callback=groups_cb, nargs=1, type="string") - op.add_option("--homedir") - op.add_option("--iscrypted", dest="isCrypted", action="store_true", - default=False) - op.add_option("--name", required=1) - op.add_option("--password") - op.add_option("--shell") - op.add_option("--uid", type="int") + op = KSOptionParser(prog="user", description=""" + Creates a new user on the system.""", + version=FC6) + op.add_argument("--groups", type=commaSplit, version=FC6, help=""" + In addition to the default group, a comma separated + list of group names the user should belong to. Any groups + that do not already exist will be created. If the group + already exists with a different GID, an error will + be raised.""", + metavar="<group1>,<group2>,...,<groupN>") + op.add_argument("--homedir", version=FC6, help=""" + The home directory for the user. If not provided, this + defaults to /home/.""") + op.add_argument("--iscrypted", dest="isCrypted", action="store_true", + default=False, version=FC6, help=""" + If specified, consider the password provided by + ``--password`` already encrypted. This is the default. + """) + op.add_argument("--name", required=True, version=FC6, help=""" + Provides the name of the user. This option is required. + """) + op.add_argument("--password", version=FC6, help=""" + The new user's password. If not provided, the account + will be locked by default. If this is present, the + password argument is assumed to already be encrypted. + ``--plaintext`` has the opposite effect - the password + argument is assumed to not be encrypted. To create an + encrypted password you can use python:: + + ``python -c 'import crypt; print(crypt.crypt("My Password", "$6$My Sault"))'`` + + This will generate sha512 crypt of your password using + your provided salt.""") + op.add_argument("--shell", version=FC6, help=""" + The user's login shell. If not provided, this defaults + to the system default.""") + op.add_argument("--uid", type=int, metavar="INT", version=FC6, help=""" + The user's UID. If not provided, this defaults to the + next available non-system UID.""") return op def parse(self, args): - ud = self.handler.UserData() - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToObj(self.op, opts, ud) + ud = self.dataClass() # pylint: disable=not-callable + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_obj(ns, ud) ud.lineno = self.lineno # Check for duplicates in the data list. if ud in self.dataList(): - warnings.warn(_("A user with the name %s has already been defined.") % ud.name) + warnings.warn(_("A user with the name %s has already been defined.") % ud.name, KickstartParseWarning) return ud def dataList(self): return self.userList + @property + def dataClass(self): + return self.handler.UserData + class F8_User(FC6_User): removedKeywords = FC6_User.removedKeywords removedAttrs = FC6_User.removedAttrs def _getParser(self): op = FC6_User._getParser(self) - op.add_option("--lock", action="store_true", default=False) - op.add_option("--plaintext", dest="isCrypted", action="store_false") + op.add_argument("--lock", action="store_true", default=False, + version=F8, help=""" + If this is present, the new user account is locked by + default. That is, the user will not be able to login + from the console.""") + op.add_argument("--plaintext", dest="isCrypted", version=F8, + action="store_false", help=""" + If specified, consider the password provided by + ``--password`` to be plain text.""") return op class F12_User(F8_User): @@ -169,5 +230,32 @@ class F12_User(F8_User): def _getParser(self): op = F8_User._getParser(self) - op.add_option("--gecos", type="string") + op.add_argument("--gecos", version=F12, help=""" + Provides the GECOS information for the user. This is a + string of various system-specific fields separated by a + comma. It is frequently used to specify the user's full + name, office number, and the like. See ``man 5 passwd`` + for more details.""") + return op + +class F19_User(F12_User): + removedKeywords = F12_User.removedKeywords + removedAttrs = F12_User.removedAttrs + + def _getParser(self): + op = F12_User._getParser(self) + op.add_argument("--gid", type=int, metavar="INT", version=F19, help=""" + The GID of the user's primary group. If not provided, + this defaults to the next available non-system GID.""") + return op + +class F24_User(F19_User): + removedKeywords = F19_User.removedKeywords + removedAttrs = F19_User.removedAttrs + + def _getParser(self): + op = F19_User._getParser(self) + op.add_argument("--groups", type=commaSplit, version=F24, help=""" + The group name can optionally be followed by a GID in + parenthesis, for example, ``newgroup(5002)``.""") return op diff --git a/mic/3rdparty/pykickstart/commands/vnc.py b/mic/3rdparty/pykickstart/commands/vnc.py index 200ccfb..cbabdff 100644 --- a/mic/3rdparty/pykickstart/commands/vnc.py +++ b/mic/3rdparty/pykickstart/commands/vnc.py @@ -15,11 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * +from pykickstart.version import FC3, FC6, F9 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser class FC3_Vnc(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -41,30 +41,42 @@ class FC3_Vnc(KickstartCommand): retval += "vnc" - if self.connect != "": + if self.connect: retval += " --connect=%s" % self.connect - if self.password != "": + if self.password: retval += " --password=%s" % self.password return retval + "\n" def _getParser(self): - op = KSOptionParser() - op.add_option("--connect") - op.add_option("--password", dest="password") + op = KSOptionParser(prog="vnc", description=""" + Allows the graphical installation to be viewed + remotely via VNC. This method is usually preferred + over text mode, as there are some size and language + limitations in text installs. With no options, this + command will start a VNC server on the machine with + no password and will print out the command that + needs to be run to connect a remote machine.""", + version=FC3) + op.add_argument("--connect", version=FC3, help=""" + Connect to a remote host instead of starting VNC server + locally.""") + op.add_argument("--password", version=FC3, help=""" + Set a password which must be provided to connect to the + VNC session. This is optional, but recommended.""") return op def parse(self, args): self.enabled = True - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self class FC6_Vnc(FC3_Vnc): removedKeywords = FC3_Vnc.removedKeywords + ["connect"] removedAttrs = FC3_Vnc.removedAttrs + ["connect"] - def __init__(self, writePriority=0, host="", port="", *args, **kwargs): + def __init__(self, writePriority=0, *args, **kwargs): FC3_Vnc.__init__(self, writePriority, *args, **kwargs) self.deleteRemovedAttrs() @@ -79,30 +91,46 @@ class FC6_Vnc(FC3_Vnc): retval += "vnc" - if self.host != "": + if self.host: retval += " --host=%s" % self.host - if self.port != "": + if self.port: retval += " --port=%s" % self.port - if self.password != "": + if self.password: retval += " --password=%s" % self.password return retval + "\n" def _getParser(self): - def connect_cb (option, opt_str, value, parser): - cargs = value.split(":") - parser.values.ensure_value("host", cargs[0]) + op = FC3_Vnc._getParser(self) + op.add_argument("--connect", dest="_connect", version=FC6, + metavar="host[:port]", help=""" + Added support for host[:port] syntax.""") + op.add_argument("--host", version=FC6, help=""" + Instead of starting a VNC server on the install machine, + connect to the VNC viewer process listening on the given + hostname.""") + op.add_argument("--port", version=FC6, help=""" + Provide a port that the remote VNC viewer process is + listening on. If not provided, anaconda will use the + VNC default.""") + return op + + def parse(self, args): + retval = FC3_Vnc.parse(self, args) + + # argparse doesn't give us a way to do something this complicated, so we + # have to set it on a throwaway value and then go back and fix it up. + if getattr(retval, "_connect", None): + cargs = retval._connect.split(":") # pylint: disable=no-member + retval.host = cargs[0] # pylint: disable=attribute-defined-outside-init if len(cargs) > 1: - parser.values.ensure_value("port", cargs[1]) + retval.port = cargs[1] # pylint: disable=attribute-defined-outside-init - op = FC3_Vnc._getParser(self) - op.add_option("--connect", action="callback", callback=connect_cb, - nargs=1, type="string") - op.add_option("--host", dest="host") - op.add_option("--port", dest="port") - return op + del(retval._connect) # pylint: disable=no-member + + return retval class F9_Vnc(FC6_Vnc): removedKeywords = FC6_Vnc.removedKeywords @@ -110,5 +138,5 @@ class F9_Vnc(FC6_Vnc): def _getParser(self): op = FC6_Vnc._getParser(self) - op.remove_option("--connect") + op.remove_argument("--connect", version=F9) return op diff --git a/mic/3rdparty/pykickstart/commands/volgroup.py b/mic/3rdparty/pykickstart/commands/volgroup.py index 255c47f..d52a503 100644 --- a/mic/3rdparty/pykickstart/commands/volgroup.py +++ b/mic/3rdparty/pykickstart/commands/volgroup.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005, 2006, 2007 Red Hat, Inc. +# Copyright 2005, 2006, 2007, 2012, 2013 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,14 +15,15 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.version import FC3, F16, F21 +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.errors import KickstartParseError, KickstartParseWarning +from pykickstart.options import KSOptionParser -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_VolGroupData(BaseData): removedKeywords = BaseData.removedKeywords @@ -37,20 +38,65 @@ class FC3_VolGroupData(BaseData): self.physvols = kwargs.get("physvols", []) def __eq__(self, y): + if not y: + return False + return self.vgname == y.vgname - def __str__(self): - retval = BaseData.__str__(self) - retval += "volgroup %s" % self.vgname + def __ne__(self, y): + return not self == y + def _getArgsAsStr(self): + retval = "" if not self.format: retval += " --noformat" - if self.pesize != 0: + if self.pesize: retval += " --pesize=%d" % self.pesize if self.preexist: retval += " --useexisting" - return retval + " " + " ".join(self.physvols) + "\n" + return retval + + def __str__(self): + retval = BaseData.__str__(self) + retval += "volgroup %s" % self.vgname + retval += self._getArgsAsStr() + + # Do not output the physical volumes list if --preexist was passed in. + # This would be invalid input according to the parse method. + if not self.preexist: + retval += " " + " ".join(self.physvols) + + return retval.strip() + "\n" + +class F16_VolGroupData(FC3_VolGroupData): + def __init__(self, *args, **kwargs): + FC3_VolGroupData.__init__(self, *args, **kwargs) + self.reserved_space = kwargs.get("reserved-space", None) or kwargs.get("reserved_space", None) + self.reserved_percent = kwargs.get("reserved-percent", None) or kwargs.get("reserved_percent", None) + + def _getArgsAsStr(self): + retval = FC3_VolGroupData._getArgsAsStr(self) + if self.reserved_space: + retval += " --reserved-space=%d" % self.reserved_space + if self.reserved_percent: + retval += " --reserved-percent=%d" % self.reserved_percent + + return retval + +class F21_VolGroupData(F16_VolGroupData): + def __init__(self, *args, **kwargs): + F16_VolGroupData.__init__(self, *args, **kwargs) + self.pesize = kwargs.get("pesize", 0) + +class RHEL7_VolGroupData(F21_VolGroupData): + pass + +class RHEL8_VolGroupData(F21_VolGroupData): + pass + +class RHEL9_VolGroupData(F21_VolGroupData): + pass class FC3_VolGroup(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -70,33 +116,129 @@ class FC3_VolGroup(KickstartCommand): return retval def _getParser(self): - # Have to be a little more complicated to set two values. - def vg_cb (option, opt_str, value, parser): - parser.values.format = False - parser.values.preexist = True - - op = KSOptionParser() - op.add_option("--noformat", action="callback", callback=vg_cb, - dest="format", default=True, nargs=0) - op.add_option("--pesize", dest="pesize", type="int", nargs=1, - default=32768) - op.add_option("--useexisting", dest="preexist", action="store_true", - default=False) + op = KSOptionParser(prog="volgroup", description=""" + Creates a Logical Volume Management (LVM) group. + """, epilog=""" + Create the partition first, create the logical + volume group, and then create the logical volume. + For example:: + + part pv.01 --size 3000 + volgroup myvg pv.01 + logvol / --vgname=myvg --size=2000 --name=rootvol + """, version=FC3) + op.add_argument("name", metavar="<name>", nargs="*", version=FC3, help=""" + Name given to the volume group. The (which denotes that + multiple partitions can be listed) lists the identifiers + to add to the volume group.""") + op.add_argument("partitions", metavar="<partitions*>", nargs="*", help=""" + Physical Volume partitions to be included in this + Volume Group""", version=FC3) + op.add_argument("--noformat", dest="format", action="store_false", + default=True, version=FC3, help=""" + Use an existing volume group. Do not specify partitions + when using this option.""") + op.add_argument("--pesize", type=int, default=32768, version=FC3, + help=""" + Set the size of the physical extents in KiB.""") + op.add_argument("--useexisting", dest="preexist", action="store_true", + default=False, version=FC3, help=""" + Use an existing volume group. Do not specify partitions + when using this option.""") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - vg = self.handler.VolGroupData() - self._setToObj(self.op, opts, vg) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + # because positional arguments with variable number of values + # don't parse very well + if not ns.partitions: + if extra: + ns.partitions = extra + extra = [] + elif ns.name: + ns.partitions = ns.name[1:] + ns.name = [ns.name[0]] + + if not ns.format: + ns.preexist = True + + vg = self.dataClass() # pylint: disable=not-callable + self.set_to_obj(ns, vg) vg.lineno = self.lineno - vg.vgname = extra[0] - vg.physvols = extra[1:] + + if not ns.name: + raise KickstartParseError(_("volgroup must be given a VG name"), lineno=self.lineno) + + if not any([ns.partitions, ns.preexist]): + raise KickstartParseError(_("volgroup must be given a list of partitions"), lineno=self.lineno) + elif ns.partitions and ns.preexist: + raise KickstartParseError(_("Members may not be specified for preexisting volgroup"), lineno=self.lineno) + vg.vgname = ns.name[0] + + if ns.partitions: + vg.physvols = ns.partitions # Check for duplicates in the data list. if vg in self.dataList(): - warnings.warn(_("A volgroup with the name %s has already been defined.") % vg.vgname) + warnings.warn(_("A volgroup with the name %s has already been defined.") % vg.vgname, KickstartParseWarning) return vg def dataList(self): return self.vgList + + @property + def dataClass(self): + return self.handler.VolGroupData + +class F16_VolGroup(FC3_VolGroup): + def _getParser(self): + op = FC3_VolGroup._getParser(self) + op.add_argument("--reserved-space", dest="reserved_space", type=int, + version=F16, help=""" + Specify an amount of space to leave unused in a volume + group, in MiB. Do not append any units. This option is + only used for new volume groups.""") + op.add_argument("--reserved-percent", dest="reserved_percent", type=int, + version=F16, help=""" + Specify a percentage of total volume group space to + leave unused (new volume groups only).""") + return op + + def parse(self, args): + # first call the overriden method + retval = FC3_VolGroup.parse(self, args) + + # Check that any reserved space options are in their valid ranges. + if retval.reserved_space is not None and retval.reserved_space < 0: + raise KickstartParseError("Volume group reserved space must be a positive integer.", lineno=self.lineno) + + if retval.reserved_percent is not None and not 0 < retval.reserved_percent < 100: + raise KickstartParseError("Volume group reserved space percentage must be between 1 and 99.", lineno=self.lineno) + + # the volgroup command can't be used together with the autopart command + # due to the hard to debug behavior their combination introduces + if self.handler.autopart.seen: + errorMsg = _("The volgroup and autopart commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + # the same applies to the 'mount' command + if hasattr(self.handler, "mount") and self.handler.mount.seen: + errorMsg = _("The volgroup and mount commands can't be used at the same time") + raise KickstartParseError(errorMsg, lineno=self.lineno) + return retval + +class F21_VolGroup(F16_VolGroup): + def _getParser(self): + op = F16_VolGroup._getParser(self) + op.add_argument("--pesize", type=int, default=0, version=F21, help=""" + Set the size of the physical extents in KiB.""") + return op + +class RHEL7_VolGroup(F21_VolGroup): + pass + +class RHEL8_VolGroup(F21_VolGroup): + pass + +class RHEL9_VolGroup(F21_VolGroup): + pass diff --git a/mic/3rdparty/pykickstart/commands/xconfig.py b/mic/3rdparty/pykickstart/commands/xconfig.py index bbde49f..528d4fc 100644 --- a/mic/3rdparty/pykickstart/commands/xconfig.py +++ b/mic/3rdparty/pykickstart/commands/xconfig.py @@ -15,14 +15,11 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.errors import * -from pykickstart.options import * - -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.version import FC3, FC6, F9, F10, F14 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser class FC3_XConfig(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -47,63 +44,68 @@ class FC3_XConfig(KickstartCommand): def __str__(self): retval = KickstartCommand.__str__(self) - if self.card != "": + if self.card: retval += " --card=%s" % self.card - if self.defaultdesktop != "": + if self.defaultdesktop: retval += " --defaultdesktop=%s" % self.defaultdesktop if self.depth != 0: retval += " --depth=%d" % self.depth - if self.hsync != "": + if self.hsync: retval += " --hsync=%s" % self.hsync - if self.monitor != "": + if self.monitor: retval += " --monitor=%s" % self.monitor if self.noProbe: retval += " --noprobe" - if self.resolution != "": + if self.resolution: retval += " --resolution=%s" % self.resolution - if self.server != "": + if self.server: retval += " --server=%s" % self.server if self.startX: retval += " --startxonboot" - if self.videoRam != "": + if self.videoRam: retval += " --videoram=%s" % self.videoRam - if self.vsync != "": + if self.vsync: retval += " --vsync=%s" % self.vsync - if retval != "": + if retval: retval = "# X Window System configuration information\nxconfig %s\n" % retval return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--card") - op.add_option("--defaultdesktop") - op.add_option("--depth", action="store", type="int", nargs=1) - op.add_option("--hsync") - op.add_option("--monitor") - op.add_option("--noprobe", dest="noProbe", action="store_true", - default=False) - op.add_option("--resolution") - op.add_option("--server") - op.add_option("--startxonboot", dest="startX", action="store_true", - default=False) - op.add_option("--videoram", dest="videoRam") - op.add_option("--vsync") + op = KSOptionParser(prog="xconfig", description=""" + Configures the X Window System. If this option is + not given, Anaconda will use X and attempt to + automatically configure. Please try this before + manually configuring your system.""", version=FC3) + op.add_argument("--card", version=FC3, help="REMOVED") + op.add_argument("--defaultdesktop", metavar="GNOME|KDE", help=""" + Specify either GNOME or KDE to set the default desktop + (assumes that GNOME Desktop Environment and/or KDE + Desktop Environment has been installed through + %%packages).""", version=FC3) + op.add_argument("--depth", type=int, version=FC3, help="REMOVED") + op.add_argument("--hsync", version=FC3, help="REMOVED") + op.add_argument("--monitor", version=FC3, help="REMOVED") + op.add_argument("--noprobe", dest="noProbe", action="store_true", + default=False, version=FC3, help="REMOVED") + op.add_argument("--resolution", version=FC3, help="REMOVED") + op.add_argument("--server", version=FC3, help="REMOVED") + op.add_argument("--startxonboot", dest="startX", action="store_true", + default=False, version=FC3, help=""" + Use a graphical login on the installed system.""") + op.add_argument("--videoram", dest="videoRam", version=FC3, help="REMOVED") + op.add_argument("--vsync", version=FC3, help="REMOVED") return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - if extra: - mapping = {"command": "xconfig", "options": extra} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)) - - self._setToSelf(self.op, opts) + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) return self class FC6_XConfig(FC3_XConfig): - removedKeywords = FC3_XConfig.removedKeywords + ["card", "hsync", "monitor", "noProbe", "vsync"] - removedAttrs = FC3_XConfig.removedAttrs + ["card", "hsync", "monitor", "noProbe", "vsync"] + removedKeywords = FC3_XConfig.removedKeywords + ["card", "hsync", "monitor", "noProbe", "server", "vsync"] + removedAttrs = FC3_XConfig.removedAttrs + ["card", "hsync", "monitor", "noProbe", "server", "vsync"] def __init__(self, writePriority=0, *args, **kwargs): FC3_XConfig.__init__(self, writePriority, *args, **kwargs) @@ -114,32 +116,33 @@ class FC6_XConfig(FC3_XConfig): def __str__(self): retval = KickstartCommand.__str__(self) - if hasattr(self, "driver") and self.driver != "": + if hasattr(self, "driver") and self.driver: retval += " --driver=%s" % self.driver - if self.defaultdesktop != "": + if self.defaultdesktop: retval += " --defaultdesktop=%s" % self.defaultdesktop if self.depth != 0: retval += " --depth=%d" % self.depth - if hasattr(self, "resolution") and self.resolution != "": + if hasattr(self, "resolution") and self.resolution: retval += " --resolution=%s" % self.resolution if self.startX: retval += " --startxonboot" - if hasattr(self, "videoRam") and self.videoRam != "": + if hasattr(self, "videoRam") and self.videoRam: retval += " --videoram=%s" % self.videoRam - if retval != "": + if retval: retval = "# X Window System configuration information\nxconfig %s\n" % retval return retval def _getParser(self): op = FC3_XConfig._getParser(self) - op.add_option("--card", deprecated=1) - op.add_option("--driver", dest="driver") - op.add_option("--hsync", deprecated=1) - op.add_option("--monitor", deprecated=1) - op.add_option("--noprobe", deprecated=1) - op.add_option("--vsync", deprecated=1) + op.add_argument("--card", deprecated=FC6) + op.add_argument("--driver", version=FC6, help="REMOVED") + op.add_argument("--hsync", deprecated=FC6) + op.add_argument("--monitor", deprecated=FC6) + op.add_argument("--noprobe", deprecated=FC6) + op.add_argument("--vsync", deprecated=FC6) + op.remove_argument("--server", version=FC6, help="") return op class F9_XConfig(FC6_XConfig): @@ -148,11 +151,11 @@ class F9_XConfig(FC6_XConfig): def _getParser(self): op = FC6_XConfig._getParser(self) - op.remove_option("--card") - op.remove_option("--hsync") - op.remove_option("--monitor") - op.remove_option("--noprobe") - op.remove_option("--vsync") + op.remove_argument("--card", version=F9) + op.remove_argument("--hsync", version=F9) + op.remove_argument("--monitor", version=F9) + op.remove_argument("--noprobe", version=F9) + op.remove_argument("--vsync", version=F9) return op class F10_XConfig(F9_XConfig): @@ -165,10 +168,10 @@ class F10_XConfig(F9_XConfig): def _getParser(self): op = F9_XConfig._getParser(self) - op.add_option("--driver", deprecated=1) - op.add_option("--depth", deprecated=1) - op.add_option("--resolution", deprecated=1) - op.add_option("--videoram", deprecated=1) + op.add_argument("--driver", deprecated=F10) + op.add_argument("--depth", deprecated=F10) + op.add_argument("--resolution", deprecated=F10) + op.add_argument("--videoram", deprecated=F10) return op class F14_XConfig(F10_XConfig): @@ -177,8 +180,8 @@ class F14_XConfig(F10_XConfig): def _getParser(self): op = F10_XConfig._getParser(self) - op.remove_option("--driver") - op.remove_option("--depth") - op.remove_option("--resolution") - op.remove_option("--videoram") + op.remove_argument("--driver", version=F14) + op.remove_argument("--depth", version=F14) + op.remove_argument("--resolution", version=F14) + op.remove_argument("--videoram", version=F14) return op diff --git a/mic/3rdparty/pykickstart/commands/zerombr.py b/mic/3rdparty/pykickstart/commands/zerombr.py index e99ea8d..029302b 100644 --- a/mic/3rdparty/pykickstart/commands/zerombr.py +++ b/mic/3rdparty/pykickstart/commands/zerombr.py @@ -15,15 +15,16 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # import warnings -from pykickstart.base import * -from pykickstart.options import * +from pykickstart.errors import KickstartDeprecationWarning +from pykickstart.version import FC3 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_ZeroMbr(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -43,14 +44,22 @@ class FC3_ZeroMbr(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog="zerombr", description=""" + If zerombr is specified, any disks whose formatting + is unrecognized are initialized. This will destroy + all of the contents of disks with invalid partition + tables or other formatting unrecognizable to the + installer. It is useful so that the installation + program does not ask if it should initialize the + disk label if installing to a brand new hard drive. + """, version=FC3) return op def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) + extra = self.op.parse_known_args(args=args, lineno=self.lineno)[1] - if len(extra) > 0: - 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) + if extra: + 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, KickstartDeprecationWarning) self.zerombr = True return self @@ -60,10 +69,6 @@ class F9_ZeroMbr(FC3_ZeroMbr): removedAttrs = FC3_ZeroMbr.removedAttrs def parse(self, args): - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - - if len(extra) > 0: - raise KickstartParseError (formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "zerombr")) - + self.op.parse_args(args=args, lineno=self.lineno) self.zerombr = True return self diff --git a/mic/3rdparty/pykickstart/commands/zfcp.py b/mic/3rdparty/pykickstart/commands/zfcp.py index 1ed2694..1779055 100644 --- a/mic/3rdparty/pykickstart/commands/zfcp.py +++ b/mic/3rdparty/pykickstart/commands/zfcp.py @@ -15,14 +15,17 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.options import * +from textwrap import dedent + +from pykickstart.errors import KickstartParseWarning, KickstartParseError +from pykickstart.version import FC3, F12, F14, F37, versionToLongString +from pykickstart.base import BaseData, KickstartCommand +from pykickstart.options import KSOptionParser -import gettext import warnings -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ class FC3_ZFCPData(BaseData): removedKeywords = BaseData.removedKeywords @@ -37,23 +40,29 @@ class FC3_ZFCPData(BaseData): self.scsilun = kwargs.get("scsilun", "") def __eq__(self, y): + if not y: + return False + return self.devnum == y.devnum and self.wwpn == y.wwpn and \ self.fcplun == y.fcplun and self.scsiid == y.scsiid and \ self.scsilun == y.scsilun + def __ne__(self, y): + return not self == y + def __str__(self): retval = BaseData.__str__(self) retval += "zfcp" - if self.devnum != "": + if self.devnum: retval += " --devnum=%s" % self.devnum - if self.wwpn != "": + if self.wwpn: retval += " --wwpn=%s" % self.wwpn - if self.fcplun != "": + if self.fcplun: retval += " --fcplun=%s" % self.fcplun - if hasattr(self, "scsiid") and self.scsiid != "": + if hasattr(self, "scsiid") and self.scsiid: retval += " --scsiid=%s" % self.scsiid - if hasattr(self, "scsilun") and self.scsilun != "": + if hasattr(self, "scsilun") and self.scsilun: retval += " --scsilun=%s" % self.scsilun return retval + "\n" @@ -66,7 +75,18 @@ class F12_ZFCPData(FC3_ZFCPData): FC3_ZFCPData.__init__(self, *args, **kwargs) self.deleteRemovedAttrs() -F14_ZFCPData = F12_ZFCPData + def __eq__(self, y): + if not y: + return False + + return self.devnum == y.devnum and self.wwpn == y.wwpn and \ + self.fcplun == y.fcplun + +class F14_ZFCPData(F12_ZFCPData): + pass + +class F37_ZFCPData(F14_ZFCPData): + pass class FC3_ZFCP(KickstartCommand): removedKeywords = KickstartCommand.removedKeywords @@ -86,29 +106,40 @@ class FC3_ZFCP(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() - op.add_option("--devnum", dest="devnum", required=1) - op.add_option("--fcplun", dest="fcplun", required=1) - op.add_option("--scsiid", dest="scsiid", required=1) - op.add_option("--scsilun", dest="scsilun", required=1) - op.add_option("--wwpn", dest="wwpn", required=1) + op = KSOptionParser(prog="zfcp", version=FC3, description=""" + Define a Fibre channel device. This option only applies + on IBM System z.""") + op.add_argument("--devnum", required=True, version=FC3, help=""" + The device number (zFCP adaptor device bus ID).""") + op.add_argument("--fcplun", required=True, version=FC3, help=""" + The device's Logical Unit Number (LUN). Takes the form + of a 16-digit number, preceded by 0x.""") + op.add_argument("--wwpn", required=True, version=FC3, help=""" + The device's World Wide Port Name (WWPN). Takes the form + of a 16-digit number, preceded by 0x.""") + op.add_argument("--scsiid", required=True, version=FC3, help="SCSI ID") + op.add_argument("--scsilun", required=True, version=FC3, help="SCSI LUN") return op def parse(self, args): - zd = self.handler.ZFCPData() - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - self._setToObj(self.op, opts, zd) + zd = self.dataClass() # pylint: disable=not-callable + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_obj(ns, zd) zd.lineno = self.lineno # Check for duplicates in the data list. if zd in self.dataList(): - warnings.warn(_("A zfcp with this information has already been defined.")) + warnings.warn(_("A zfcp with this information has already been defined."), KickstartParseWarning) return zd def dataList(self): return self.zfcp + @property + def dataClass(self): + return self.handler.ZFCPData + class F12_ZFCP(FC3_ZFCP): removedKeywords = FC3_ZFCP.removedKeywords removedAttrs = FC3_ZFCP.removedAttrs + ["scsiid", "scsilun"] @@ -119,8 +150,8 @@ class F12_ZFCP(FC3_ZFCP): def _getParser(self): op = FC3_ZFCP._getParser(self) - op.add_option("--scsiid", deprecated=1) - op.add_option("--scsilun", deprecated=1) + op.add_argument("--scsiid", deprecated=F12) + op.add_argument("--scsilun", deprecated=F12) return op class F14_ZFCP(F12_ZFCP): @@ -129,6 +160,53 @@ class F14_ZFCP(F12_ZFCP): def _getParser(self): op = F12_ZFCP._getParser(self) - op.remove_option("--scsiid") - op.remove_option("--scsilun") + op.remove_argument("--scsiid", version=F14) + op.remove_argument("--scsilun", version=F14) + return op + +class F37_ZFCP(F14_ZFCP): + removedKeywords = F14_ZFCP.removedKeywords + removedAttrs = F14_ZFCP.removedAttrs + + def _getParser(self): + op = F14_ZFCP._getParser(self) + op.description += dedent(""" + + .. versionchanged:: %s + + It is sufficient to specify an FCP device bus ID if automatic LUN scanning + is available. Otherwise all three parameters are required. + + ``zfcp --devnum=<devnum> [--wwpn=<wwpn> --fcplun=<lun>]`` + + Automatic LUN scanning is available for FCP devices operating in NPIV mode + if it is not disabled through the `zfcp.allow_lun_scan` module parameter + (enabled by default). It provides access to all SCSI devices, that is, WWPNs + and FCP LUNs, found in the storage area network attached to the FCP device + with the specified bus ID. + + """ % versionToLongString(F37)) + + op.epilog += dedent(""" + For example:: + + zfcp --devnum=0.0.6000 + zfcp --devnum=0.0.4000 --wwpn=0x5005076300C213e9 --fcplun=0x5022000000000000 + + """) + + op.add_argument("--wwpn", default="", required=False, version=F37, help=""" + The argument is optional.""") + op.add_argument("--fcplun", default="", required=False, version=F37, help=""" + The argument is optional.""") return op + + def parse(self, args): + data = F14_ZFCP.parse(self, args) + + if not ((data.devnum and not data.wwpn and not data.fcplun) + or (data.devnum and data.wwpn and data.fcplun)): + msg = _("Only --devnum or --devnum with --wwpn and --fcplun are allowed.") + raise KickstartParseError(msg, lineno=self.lineno) + + return data diff --git a/mic/3rdparty/pykickstart/commands/zipl.py b/mic/3rdparty/pykickstart/commands/zipl.py new file mode 100644 index 0000000..0afa310 --- /dev/null +++ b/mic/3rdparty/pykickstart/commands/zipl.py @@ -0,0 +1,93 @@ +# +# Copyright 2019 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +from pykickstart.constants import SECURE_BOOT_AUTO, SECURE_BOOT_ENABLED, SECURE_BOOT_DISABLED, \ + SECURE_BOOT_DEFAULT +from pykickstart.version import F32 +from pykickstart.base import KickstartCommand +from pykickstart.options import KSOptionParser + + +class F32_Zipl(KickstartCommand): + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, writePriority=10, *args, **kwargs): + KickstartCommand.__init__(self, writePriority, *args, **kwargs) + self.op = self._getParser() + self.secure_boot = kwargs.get("secure_boot", SECURE_BOOT_DEFAULT) + + def _getParser(self): + op = KSOptionParser(prog="zipl", version=F32, description=""" + This command specifies the ZIPL configuration for s390x. + """) + op.add_argument("--secure-boot", dest="secure_boot", version=F32, + action="store_const", const=SECURE_BOOT_AUTO, + help=""" + Enable Secure Boot if supported by the installing machine. + + **Note** When installed on a model newer than IBM z14, the + installed system cannot be booted from an IBM z14 and earlier + models. + """) + op.add_argument("--force-secure-boot", dest="secure_boot", version=F32, + action="store_const", const=SECURE_BOOT_ENABLED, + help=""" + Enable Secure Boot unconditionally. + + **Note** Installation will fail on IBM z14 and earlier models. + """) + op.add_argument("--no-secure-boot", dest="secure_boot", version=F32, + action="store_const", const=SECURE_BOOT_DISABLED, + help=""" + Disable Secure Boot. + + **Note** Secure Boot is not supported on IBM z14 and earlier + models, therefore choose '--no-secure-boot' if you intend to + boot the installed system on such models. + """) + return op + + def parse(self, args): + ns = self.op.parse_args(args=args, lineno=self.lineno) + self.set_to_self(ns) + return self + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.secure_boot is not SECURE_BOOT_DEFAULT: + retval += "# ZIPL configuration\nzipl" + retval += self._getArgsAsStr() + "\n" + + return retval + + def _getArgsAsStr(self): + ret = "" + + if self.secure_boot == SECURE_BOOT_AUTO: + ret += " --secure-boot" + elif self.secure_boot == SECURE_BOOT_ENABLED: + ret += " --force-secure-boot" + elif self.secure_boot == SECURE_BOOT_DISABLED: + ret += " --no-secure-boot" + + return ret + + +class RHEL8_Zipl(F32_Zipl): + pass diff --git a/mic/3rdparty/pykickstart/constants.py b/mic/3rdparty/pykickstart/constants.py index 050d124..cb1b685 100644 --- a/mic/3rdparty/pykickstart/constants.py +++ b/mic/3rdparty/pykickstart/constants.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005-2007 Red Hat, Inc. +# Copyright 2005-2016 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,11 +15,17 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # CLEARPART_TYPE_LINUX = 0 CLEARPART_TYPE_ALL = 1 CLEARPART_TYPE_NONE = 2 +CLEARPART_TYPE_LIST = 3 + +AUTOPART_TYPE_PLAIN = 0 +AUTOPART_TYPE_BTRFS = 1 +AUTOPART_TYPE_LVM = 2 +AUTOPART_TYPE_LVM_THINP = 3 DISPLAY_MODE_CMDLINE = 0 DISPLAY_MODE_GRAPHICAL = 1 @@ -32,15 +38,23 @@ FIRSTBOOT_RECONFIG = 2 KS_MISSING_PROMPT = 0 KS_MISSING_IGNORE = 1 +KS_BROKEN_REPORT = 0 +KS_BROKEN_IGNORE = 1 + SELINUX_DISABLED = 0 SELINUX_ENFORCING = 1 SELINUX_PERMISSIVE = 2 +SNAPSHOT_WHEN_POST_INSTALL = 0 +SNAPSHOT_WHEN_PRE_INSTALL = 1 + KS_SCRIPT_PRE = 0 KS_SCRIPT_POST = 1 KS_SCRIPT_TRACEBACK = 2 -KS_SCRIPT_RUN = 3 -KS_SCRIPT_UMOUNT = 4 +KS_SCRIPT_PREINSTALL = 3 +KS_SCRIPT_ONERROR = 4 +KS_SCRIPT_RUN = 5 +KS_SCRIPT_UMOUNT = 6 KS_WAIT = 0 KS_REBOOT = 1 @@ -57,3 +71,15 @@ BOOTPROTO_IBFT = "ibft" GROUP_REQUIRED = 0 GROUP_DEFAULT = 1 GROUP_ALL = 2 + +BIND_TO_MAC = "mac" + +NVDIMM_MODE_SECTOR = "sector" + +NVDIMM_ACTION_RECONFIGURE = "reconfigure" +NVDIMM_ACTION_USE = "use" + +SECURE_BOOT_DEFAULT = -1 +SECURE_BOOT_DISABLED = 0 +SECURE_BOOT_ENABLED = 1 +SECURE_BOOT_AUTO = 2 diff --git a/mic/3rdparty/pykickstart/errors.py b/mic/3rdparty/pykickstart/errors.py index a234d99..8294f59 100644 --- a/mic/3rdparty/pykickstart/errors.py +++ b/mic/3rdparty/pykickstart/errors.py @@ -15,89 +15,113 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # """ -Error handling classes and functions. +Error and warning handling classes and functions. -This module exports a single function: - - formatErrorMsg - Properly formats an error message. - -It also exports several exception classes: +This module exports several exception classes: KickstartError - A generic exception class. - KickstartParseError - An exception for errors relating to parsing. + KickstartParseError - An exception for errors occurring during parsing. - KickstartValueError - An exception for errors relating to option - processing. + KickstartValueError - No longer raised by pykickstart, but kept around for + backwards compatibility. KickstartVersionError - An exception for errors relating to unsupported syntax versions. + +And some warning classes: + + KickstartWarning - A generic warning class. + + KickstartParseWarning - A class for warnings occurring during parsing. + + KickstartDeprecationWarning - A class for warnings occurring during parsing + related to deprecated commands and options. + """ -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +import warnings +from pykickstart.i18n import _ + def formatErrorMsg(lineno, msg=""): - """Properly format the error message msg for inclusion in an exception.""" - if msg != "": - mapping = {"lineno": lineno, "msg": msg} - return _("The following problem occurred on line %(lineno)s of the kickstart file:\n\n%(msg)s\n") % mapping - else: - return _("There was a problem reading from line %s of the kickstart file") % lineno + """This function is deprecated. KickstartError formats the error message now, + so this function returns a tuple that can be formatted by KickstartError. + + You should call: + KickstartError(message, lineno=lineno) + + But the deprecated way is still supported: + KickstartError(formatErrorMsg(message, lineno=lineno)) + + """ + warnings.warn("Function formatErrorMsg is deprecated. The error messages " + "are formatted by KickstartError now.", DeprecationWarning) + + return lineno, msg + +def _format_error_message(lineno, msg=""): + """Properly format the error message msg in an exception. + This function should be called only in exceptions to format the error messages. + """ + if msg: + return _("The following problem occurred on line %(lineno)s of the kickstart file:" + "\n\n%(msg)s\n") % {"lineno": lineno, "msg": msg} + + return _("There was a problem reading from line %s of the kickstart file") % lineno class KickstartError(Exception): """A generic exception class for unspecific error conditions.""" - def __init__(self, val = ""): + + def __init__(self, msg="", lineno=None, formatting=True): """Create a new KickstartError exception instance with the descriptive - message val. val should be the return value of formatErrorMsg. + message msg. The msg will be formatted if formatting is allowed and + the line number lineno is set. """ Exception.__init__(self) - self.value = val + self.message = msg + self.lineno = lineno - def __str__ (self): + # Accept tuples from formatErrorMsg for backwards compatibility. + if isinstance(msg, tuple) and len(msg) == 2: + self.lineno, self.message = msg + + # Keep the value attribute for backwards compatibility. + self.value = self.message + + # Format the error message if it is allowed. + if formatting and self.lineno is not None: + self.value = _format_error_message(self.lineno, self.message) + + def __str__(self): return self.value class KickstartParseError(KickstartError): """An exception class for errors when processing the input file, such as unknown options, commands, or sections. """ - def __init__(self, msg): - """Create a new KickstartParseError exception instance with the - descriptive message val. val should be the return value of - formatErrorMsg. - """ - KickstartError.__init__(self, msg) - - def __str__(self): - return self.value class KickstartValueError(KickstartError): - """An exception class for errors when processing arguments to commands, - such as too many arguments, too few arguments, or missing required - arguments. + """This exception class is no longer raised by pykickstart but is kept + for backwards compatibility. """ - def __init__(self, msg): - """Create a new KickstartValueError exception instance with the - descriptive message val. val should be the return value of - formatErrorMsg. - """ - KickstartError.__init__(self, msg) - - def __str__ (self): - return self.value class KickstartVersionError(KickstartError): """An exception class for errors related to using an incorrect version of kickstart syntax. """ - def __init__(self, msg): - """Create a new KickstartVersionError exception instance with the - descriptive message val. val should be the return value of - formatErrorMsg. - """ - KickstartError.__init__(self, msg) - def __str__ (self): - return self.value +class KickstartWarning(Warning): + """A generic warning class for unspecific conditions.""" + +class KickstartParseWarning(KickstartWarning, UserWarning): + """A class for warnings occurring during parsing an input file, such as + defining duplicate entries and setting removed keywords. + """ + +class KickstartDeprecationWarning(KickstartParseWarning, DeprecationWarning): + """A class for warnings occurring during parsing related to using deprecated + commands and options. + """ diff --git a/mic/3rdparty/pykickstart/handlers/control.py b/mic/3rdparty/pykickstart/handlers/control.py index 119e32f..27717fc 100644 --- a/mic/3rdparty/pykickstart/handlers/control.py +++ b/mic/3rdparty/pykickstart/handlers/control.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. +# Copyright 2007-2014 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,1296 +15,36 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.version import * -from pykickstart.commands import * -from mic.kickstart.custom_commands.micrepo import * +__all__ = ["commandMap", "dataMap"] -# This map is keyed on kickstart syntax version as provided by -# pykickstart.version. Within each sub-dict is a mapping from command name -# to the class that handles it. This is an onto mapping - that is, multiple -# command names can map to the same class. However, the Handler will ensure -# that only one instance of each class ever exists. -commandMap = { - FC3: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.FC3_Bootloader, - "cdrom": method.FC3_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "driverdisk": driverdisk.FC3_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC3_Reboot, - "harddrive": method.FC3_Method, - "ignoredisk": ignoredisk.FC3_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "langsupport": langsupport.FC3_LangSupport, - "lilo": bootloader.FC3_Bootloader, - "lilocheck": lilocheck.FC3_LiloCheck, - "logvol": logvol.FC3_LogVol, - "monitor": monitor.FC3_Monitor, - "mouse": mouse.FC3_Mouse, - "network": network.FC3_Network, - "nfs": method.FC3_Method, - "part": partition.FC3_Partition, - "partition": partition.FC3_Partition, - "poweroff": reboot.FC3_Reboot, - "raid": raid.FC3_Raid, - "reboot": reboot.FC3_Reboot, - "rootpw": rootpw.FC3_RootPw, - "selinux": selinux.FC3_SELinux, - "shutdown": reboot.FC3_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC3_Timezone, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC3_Method, - "vnc": vnc.FC3_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC3_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, +import os +import sys +import importlib - # based on fc3 - FC4: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.FC4_Bootloader, - "cdrom": method.FC3_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC3_Reboot, - "harddrive": method.FC3_Method, - "ignoredisk": ignoredisk.FC3_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "langsupport": langsupport.FC3_LangSupport, - "logvol": logvol.FC4_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.FC3_Monitor, - "mouse": mouse.FC3_Mouse, - "network": network.FC4_Network, - "nfs": method.FC3_Method, - "part": partition.FC4_Partition, - "partition": partition.FC4_Partition, - "poweroff": reboot.FC3_Reboot, - "raid": raid.FC4_Raid, - "reboot": reboot.FC3_Reboot, - "rootpw": rootpw.FC3_RootPw, - "selinux": selinux.FC3_SELinux, - "shutdown": reboot.FC3_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC3_Timezone, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC3_Method, - "vnc": vnc.FC3_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC3_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, +commandMap = {} +dataMap = {} - # based on fc4 - FC5: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.FC4_Bootloader, - "cdrom": method.FC3_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC3_Reboot, - "harddrive": method.FC3_Method, - "ignoredisk": ignoredisk.FC3_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "langsupport": langsupport.FC5_LangSupport, - "logvol": logvol.FC4_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.FC3_Monitor, - "mouse": mouse.FC3_Mouse, - "network": network.FC4_Network, - "nfs": method.FC3_Method, - "part": partition.FC4_Partition, - "partition": partition.FC4_Partition, - "poweroff": reboot.FC3_Reboot, - "raid": raid.FC5_Raid, - "reboot": reboot.FC3_Reboot, - "rootpw": rootpw.FC3_RootPw, - "selinux": selinux.FC3_SELinux, - "shutdown": reboot.FC3_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC3_Timezone, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC3_Method, - "vnc": vnc.FC3_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC3_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, +if not commandMap: + _path = os.path.dirname(__file__) + if not _path in sys.path: + sys.path.append(_path) - # based on fc5 - FC6: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.FC4_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.FC3_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.FC6_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "langsupport": langsupport.FC5_LangSupport, - "logging": logging.FC6_Logging, - "logvol": logvol.FC4_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.FC6_Monitor, - "mouse": mouse.FC3_Mouse, - "multipath": multipath.FC6_MultiPath, - "network": network.FC6_Network, - "nfs": method.FC6_Method, - "part": partition.FC4_Partition, - "partition": partition.FC4_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.FC5_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.FC6_Repo, - "tpk_repo": Mic_Tpk_Repo, - "rootpw": rootpw.FC3_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "upgrade": upgrade.FC3_Upgrade, - "user": user.FC6_User, - "url": method.FC6_Method, - "vnc": vnc.FC6_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC6_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, + for name in os.listdir(os.path.dirname(__file__)): + if not (name.startswith("fc") or name.startswith("f") or name.startswith("rhel")): + continue - # based on fc6 - F7: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.FC4_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.FC3_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.FC6_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.FC4_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.FC6_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.FC6_Network, - "nfs": method.FC6_Method, - "part": partition.FC4_Partition, - "partition": partition.FC4_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F7_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.FC6_Repo, - "rootpw": rootpw.FC3_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC6_Method, - "user": user.FC6_User, - "vnc": vnc.FC6_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC6_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, + if not name.endswith(".py"): + continue - # based on f7 - F8: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F8_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.FC6_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.FC4_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.FC6_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F8_Network, - "nfs": method.FC6_Method, - "part": partition.FC4_Partition, - "partition": partition.FC4_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F7_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F8_Repo, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC6_Method, - "user": user.F8_User, - "vnc": vnc.FC6_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC6_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, + obj = importlib.import_module(name.replace(".py", "")) + if not obj.__all__ or not obj.__all__[0].endswith("Handler"): + continue - # based on f8 - F9: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F9_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F8_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.F9_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.FC6_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F9_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.FC6_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F9_Network, - "nfs": method.FC6_Method, - "part": partition.F9_Partition, - "partition": partition.F9_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F9_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F8_Repo, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC6_Method, - "user": user.F8_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F9_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, - - # based on f9 - F10: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F9_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F8_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.F10_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F9_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F9_Network, - "nfs": method.FC6_Method, - "part": partition.F9_Partition, - "partition": partition.F9_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F9_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F8_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC6_Method, - "user": user.F8_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F10_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, - - # based on f10 - F11: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F9_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F8_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.F10_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.F11_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F9_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F9_Network, - "nfs": method.FC6_Method, - "part": partition.F11_Partition, - "partition": partition.F11_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F9_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F11_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.F11_Upgrade, - "url": method.FC6_Method, - "user": user.F8_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F10_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, - - # based on f11 - F12: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F12_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F12_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.F12_DriverDisk, - "fcoe": fcoe.F12_Fcoe, - "firewall": firewall.F10_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "group": group.F12_Group, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.F11_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F12_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F9_Network, - "nfs": method.FC6_Method, - "part": partition.F12_Partition, - "partition": partition.F12_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F12_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F11_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.F11_Upgrade, - "url": method.FC6_Method, - "user": user.F12_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F10_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.F12_ZFCP, - }, - - # based on f12 - F13: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F12_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F12_Bootloader, - "cdrom": method.F13_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.F12_DriverDisk, - "fcoe": fcoe.F13_Fcoe, - "firewall": firewall.F10_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "group": group.F12_Group, - "halt": reboot.FC6_Reboot, - "harddrive": method.F13_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.F11_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F12_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F9_Network, - "nfs": method.F13_Method, - "part": partition.F12_Partition, - "partition": partition.F12_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F13_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F13_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "sshpw": sshpw.F13_SshPw, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.F11_Upgrade, - "url": method.F13_Method, - "user": user.F12_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F10_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.F12_ZFCP, - }, - - # based on f13 - F14: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F12_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F14_Bootloader, - "cdrom": method.F14_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.F14_DriverDisk, - "fcoe": fcoe.F13_Fcoe, - "firewall": firewall.F14_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "group": group.F12_Group, - "halt": reboot.FC6_Reboot, - "harddrive": method.F14_Method, - "ignoredisk": ignoredisk.F14_IgnoreDisk, - "install": upgrade.F11_Upgrade, - "interactive": interactive.F14_Interactive, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F14_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F9_Network, - "nfs": method.F14_Method, - "part": partition.F14_Partition, - "partition": partition.F14_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F14_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F14_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "sshpw": sshpw.F13_SshPw, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.F11_Upgrade, - "url": method.F14_Method, - "user": user.F12_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F14_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.F14_ZFCP, - }, - - # based on f14 - F15: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F12_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F15_Bootloader, - "cdrom": method.F14_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.F14_DriverDisk, - "fcoe": fcoe.F13_Fcoe, - "firewall": firewall.F14_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "group": group.F12_Group, - "halt": reboot.FC6_Reboot, - "harddrive": method.F14_Method, - "ignoredisk": ignoredisk.F14_IgnoreDisk, - "install": upgrade.F11_Upgrade, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F15_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F9_Network, - "nfs": method.F14_Method, - "part": partition.F14_Partition, - "partition": partition.F14_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F15_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F15_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "sshpw": sshpw.F13_SshPw, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.F11_Upgrade, - "url": method.F14_Method, - "user": user.F12_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F14_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.F14_ZFCP, - }, - - # based on f15 - F16: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F12_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.F15_Bootloader, - "cdrom": method.F14_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.F14_DriverDisk, - "fcoe": fcoe.F13_Fcoe, - "firewall": firewall.F14_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "group": group.F12_Group, - "halt": reboot.FC6_Reboot, - "harddrive": method.F14_Method, - "ignoredisk": ignoredisk.F14_IgnoreDisk, - "install": upgrade.F11_Upgrade, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F15_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.F16_Network, - "nfs": method.F14_Method, - "part": partition.F14_Partition, - "partition": partition.F14_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F15_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.F15_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "sshpw": sshpw.F13_SshPw, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.F11_Upgrade, - "url": method.F14_Method, - "user": user.F12_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F14_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.F14_ZFCP, - }, - - # based on fc1 - RHEL3: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.FC3_Bootloader, - "cdrom": method.FC3_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "driverdisk": driverdisk.FC3_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC3_Reboot, - "harddrive": method.FC3_Method, - "ignoredisk": ignoredisk.FC3_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "langsupport": langsupport.FC3_LangSupport, - "lilo": bootloader.FC3_Bootloader, - "lilocheck": lilocheck.FC3_LiloCheck, - "logvol": logvol.FC3_LogVol, - "monitor": monitor.FC3_Monitor, - "mouse": mouse.RHEL3_Mouse, - "network": network.FC3_Network, - "nfs": method.FC3_Method, - "part": partition.FC3_Partition, - "partition": partition.FC3_Partition, - "poweroff": reboot.FC3_Reboot, - "raid": raid.FC3_Raid, - "reboot": reboot.FC3_Reboot, - "rootpw": rootpw.FC3_RootPw, - "shutdown": reboot.FC3_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC3_Timezone, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC3_Method, - "vnc": vnc.FC3_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC3_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - }, - - # based on fc3 - RHEL4: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.FC3_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.FC3_Bootloader, - "cdrom": method.FC3_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "driverdisk": driverdisk.FC4_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC3_Reboot, - "harddrive": method.FC3_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "langsupport": langsupport.FC3_LangSupport, - "lilo": bootloader.FC3_Bootloader, - "lilocheck": lilocheck.FC3_LiloCheck, - "logvol": logvol.FC3_LogVol, - "monitor": monitor.FC3_Monitor, - "mouse": mouse.FC3_Mouse, - "network": network.RHEL4_Network, - "nfs": method.FC3_Method, - "part": partition.FC3_Partition, - "partition": partition.FC3_Partition, - "poweroff": reboot.FC3_Reboot, - "raid": raid.FC3_Raid, - "reboot": reboot.FC3_Reboot, - "rootpw": rootpw.FC3_RootPw, - "selinux": selinux.FC3_SELinux, - "shutdown": reboot.FC3_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC3_Timezone, - "upgrade": upgrade.FC3_Upgrade, - "url": method.FC3_Method, - "vnc": vnc.FC3_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC3_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, - - # based on fc6 - RHEL5: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F9_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.RHEL5_Bootloader, - "cdrom": method.FC6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.FC3_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.F12_DriverDisk, - "firewall": firewall.FC3_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "halt": reboot.FC6_Reboot, - "harddrive": method.FC6_Method, - "ignoredisk": ignoredisk.F8_IgnoreDisk, - "install": upgrade.FC3_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.FC6_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "key": key.RHEL5_Key, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "langsupport": langsupport.FC5_LangSupport, - "logging": logging.FC6_Logging, - "logvol": logvol.RHEL5_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.FC6_Monitor, - "mouse": mouse.FC3_Mouse, - "multipath": multipath.FC6_MultiPath, - "network": network.RHEL5_Network, - "nfs": method.FC6_Method, - "part": partition.RHEL5_Partition, - "partition": partition.RHEL5_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.RHEL5_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.FC6_Repo, - "rootpw": rootpw.FC3_RootPw, - "services": services.FC6_Services, - "selinux": selinux.FC3_SELinux, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "upgrade": upgrade.FC3_Upgrade, - "user": user.FC6_User, - "url": method.FC6_Method, - "vnc": vnc.FC6_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.FC6_XConfig, - "zerombr": zerombr.FC3_ZeroMbr, - "zfcp": zfcp.FC3_ZFCP, - }, - - # based on f13ish - RHEL6: { - "auth": authconfig.FC3_Authconfig, - "authconfig": authconfig.FC3_Authconfig, - "autopart": autopart.F12_AutoPart, - "autostep": autostep.FC3_AutoStep, - "bootloader": bootloader.RHEL6_Bootloader, - "cdrom": method.RHEL6_Method, - "clearpart": clearpart.FC3_ClearPart, - "cmdline": displaymode.FC3_DisplayMode, - "device": device.F8_Device, - "deviceprobe": deviceprobe.FC3_DeviceProbe, - "dmraid": dmraid.FC6_DmRaid, - "driverdisk": driverdisk.F12_DriverDisk, - "fcoe": fcoe.F13_Fcoe, - "firewall": firewall.F10_Firewall, - "firstboot": firstboot.FC3_Firstboot, - "graphical": displaymode.FC3_DisplayMode, - "group": group.F12_Group, - "halt": reboot.FC6_Reboot, - "harddrive": method.RHEL6_Method, - "ignoredisk": ignoredisk.RHEL6_IgnoreDisk, - "install": upgrade.F11_Upgrade, - "interactive": interactive.FC3_Interactive, - "iscsi": iscsi.F10_Iscsi, - "iscsiname": iscsiname.FC6_IscsiName, - "keyboard": keyboard.FC3_Keyboard, - "lang": lang.FC3_Lang, - "logging": logging.FC6_Logging, - "logvol": logvol.F12_LogVol, - "mediacheck": mediacheck.FC4_MediaCheck, - "monitor": monitor.F10_Monitor, - "multipath": multipath.FC6_MultiPath, - "network": network.RHEL6_Network, - "nfs": method.RHEL6_Method, - "part": partition.F12_Partition, - "partition": partition.F12_Partition, - "poweroff": reboot.FC6_Reboot, - "raid": raid.F13_Raid, - "reboot": reboot.FC6_Reboot, - "repo": repo.RHEL6_Repo, - "rescue": rescue.F10_Rescue, - "rootpw": rootpw.F8_RootPw, - "selinux": selinux.FC3_SELinux, - "services": services.FC6_Services, - "shutdown": reboot.FC6_Reboot, - "skipx": skipx.FC3_SkipX, - "sshpw": sshpw.F13_SshPw, - "text": displaymode.FC3_DisplayMode, - "timezone": timezone.FC6_Timezone, - "updates": updates.F7_Updates, - "upgrade": upgrade.F11_Upgrade, - "url": method.RHEL6_Method, - "user": user.F12_User, - "vnc": vnc.F9_Vnc, - "volgroup": volgroup.FC3_VolGroup, - "xconfig": xconfig.F10_XConfig, - "zerombr": zerombr.F9_ZeroMbr, - "zfcp": zfcp.F12_ZFCP, - } -} - -# This map is keyed on kickstart syntax version as provided by -# pykickstart.version. Within each sub-dict is a mapping from a data object -# name to the class that provides it. This is a bijective mapping - that is, -# each name maps to exactly one data class and all data classes have a name. -# More than one instance of each class is allowed to exist, however. -dataMap = { - FC3: { - "DriverDiskData": driverdisk.FC3_DriverDiskData, - "LogVolData": logvol.FC3_LogVolData, - "NetworkData": network.FC3_NetworkData, - "PartData": partition.FC3_PartData, - "RaidData": raid.FC3_RaidData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - FC4: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "LogVolData": logvol.FC4_LogVolData, - "NetworkData": network.FC4_NetworkData, - "PartData": partition.FC4_PartData, - "RaidData": raid.FC4_RaidData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - FC5: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "LogVolData": logvol.FC4_LogVolData, - "NetworkData": network.FC4_NetworkData, - "PartData": partition.FC4_PartData, - "RaidData": raid.FC5_RaidData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - FC6: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "DmRaidData": dmraid.FC6_DmRaidData, - "IscsiData": iscsi.FC6_IscsiData, - "LogVolData": logvol.FC4_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.FC6_NetworkData, - "PartData": partition.FC4_PartData, - "RaidData": raid.FC5_RaidData, - "RepoData": repo.FC6_RepoData, - "TpkRepoData": Mic_Tpk_RepoData, - "UserData": user.FC6_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - F7: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "DmRaidData": dmraid.FC6_DmRaidData, - "IscsiData": iscsi.FC6_IscsiData, - "LogVolData": logvol.FC4_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.FC6_NetworkData, - "PartData": partition.FC4_PartData, - "RaidData": raid.F7_RaidData, - "RepoData": repo.FC6_RepoData, - "UserData": user.FC6_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - F8: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "IscsiData": iscsi.FC6_IscsiData, - "LogVolData": logvol.FC4_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.FC4_PartData, - "RaidData": raid.F7_RaidData, - "RepoData": repo.F8_RepoData, - "UserData": user.F8_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - F9: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "IscsiData": iscsi.FC6_IscsiData, - "LogVolData": logvol.F9_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.F9_PartData, - "RaidData": raid.F9_RaidData, - "RepoData": repo.F8_RepoData, - "UserData": user.F8_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - F10: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F9_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.F9_PartData, - "RaidData": raid.F9_RaidData, - "RepoData": repo.F8_RepoData, - "UserData": user.F8_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - F11: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F9_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.F11_PartData, - "RaidData": raid.F9_RaidData, - "RepoData": repo.F11_RepoData, - "UserData": user.F8_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - F12: { - "DriverDiskData": driverdisk.F12_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "FcoeData": fcoe.F12_FcoeData, - "GroupData": group.F12_GroupData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F12_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.F12_PartData, - "RaidData": raid.F12_RaidData, - "RepoData": repo.F11_RepoData, - "UserData": user.F12_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.F12_ZFCPData, - }, - F13: { - "DriverDiskData": driverdisk.F12_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "FcoeData": fcoe.F13_FcoeData, - "GroupData": group.F12_GroupData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F12_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.F12_PartData, - "RaidData": raid.F13_RaidData, - "RepoData": repo.F13_RepoData, - "SshPwData": sshpw.F13_SshPwData, - "UserData": user.F12_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.F12_ZFCPData, - }, - F14: { - "DriverDiskData": driverdisk.F14_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "FcoeData": fcoe.F13_FcoeData, - "GroupData": group.F12_GroupData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F14_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.F14_PartData, - "RaidData": raid.F14_RaidData, - "RepoData": repo.F14_RepoData, - "SshPwData": sshpw.F13_SshPwData, - "UserData": user.F12_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.F14_ZFCPData, - }, - F15: { - "DriverDiskData": driverdisk.F14_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "FcoeData": fcoe.F13_FcoeData, - "GroupData": group.F12_GroupData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F15_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F8_NetworkData, - "PartData": partition.F14_PartData, - "RaidData": raid.F15_RaidData, - "RepoData": repo.F15_RepoData, - "SshPwData": sshpw.F13_SshPwData, - "UserData": user.F12_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.F14_ZFCPData, - }, - F16: { - "DriverDiskData": driverdisk.F14_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "FcoeData": fcoe.F13_FcoeData, - "GroupData": group.F12_GroupData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F15_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.F16_NetworkData, - "PartData": partition.F14_PartData, - "RaidData": raid.F15_RaidData, - "RepoData": repo.F15_RepoData, - "SshPwData": sshpw.F13_SshPwData, - "UserData": user.F12_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.F14_ZFCPData, - }, - RHEL3: { - "DriverDiskData": driverdisk.FC3_DriverDiskData, - "LogVolData": logvol.FC3_LogVolData, - "NetworkData": network.RHEL4_NetworkData, - "PartData": partition.FC3_PartData, - "RaidData": raid.FC3_RaidData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - RHEL4: { - "DriverDiskData": driverdisk.FC4_DriverDiskData, - "LogVolData": logvol.FC3_LogVolData, - "NetworkData": network.RHEL4_NetworkData, - "PartData": partition.FC3_PartData, - "RaidData": raid.FC3_RaidData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - RHEL5: { - "DriverDiskData": driverdisk.F12_DriverDiskData, - "DmRaidData": dmraid.FC6_DmRaidData, - "IscsiData": iscsi.FC6_IscsiData, - "LogVolData": logvol.RHEL5_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.FC6_NetworkData, - "PartData": partition.RHEL5_PartData, - "RaidData": raid.RHEL5_RaidData, - "RepoData": repo.FC6_RepoData, - "UserData": user.FC6_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.FC3_ZFCPData, - }, - RHEL6: { - "DriverDiskData": driverdisk.F12_DriverDiskData, - "DeviceData": device.F8_DeviceData, - "DmRaidData": dmraid.FC6_DmRaidData, - "FcoeData": fcoe.F13_FcoeData, - "GroupData": group.F12_GroupData, - "IscsiData": iscsi.F10_IscsiData, - "LogVolData": logvol.F12_LogVolData, - "MultiPathData": multipath.FC6_MultiPathData, - "NetworkData": network.RHEL6_NetworkData, - "PartData": partition.F12_PartData, - "RaidData": raid.F13_RaidData, - "RepoData": repo.RHEL6_RepoData, - "SshPwData": sshpw.F13_SshPwData, - "UserData": user.F12_UserData, - "VolGroupData": volgroup.FC3_VolGroupData, - "ZFCPData": zfcp.F12_ZFCPData, - } -} + # Now we've got a WhateverHandler module in obj. This module should + # export one class named WhateverHandler, which we can get at indirectly + # through __all__, like so: + handler = obj.__dict__[obj.__all__[0]] + commandMap[handler.version] = handler.commandMap + dataMap[handler.version] = handler.dataMap diff --git a/mic/3rdparty/pykickstart/handlers/f10.py b/mic/3rdparty/pykickstart/handlers/f10.py index 17c8211..e93ffaf 100644 --- a/mic/3rdparty/pykickstart/handlers/f10.py +++ b/mic/3rdparty/pykickstart/handlers/f10.py @@ -15,10 +15,87 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F10Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F10 class F10Handler(BaseHandler): version = F10 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F9_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F8_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.F10_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.F10_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F9_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F9_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F9_Partition, + "partition": commands.partition.F9_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F9_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F8_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "user": commands.user.F8_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.F10_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "IscsiData": commands.iscsi.F10_IscsiData, + "LogVolData": commands.logvol.F9_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.F9_PartData, + "RaidData": commands.raid.F9_RaidData, + "RepoData": commands.repo.F8_RepoData, + "UserData": commands.user.F8_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f11.py b/mic/3rdparty/pykickstart/handlers/f11.py index d21aee3..6e7b6bf 100644 --- a/mic/3rdparty/pykickstart/handlers/f11.py +++ b/mic/3rdparty/pykickstart/handlers/f11.py @@ -15,10 +15,87 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F11Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F11 class F11Handler(BaseHandler): version = F11 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F9_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F8_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.F10_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.F10_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F9_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F9_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F11_Partition, + "partition": commands.partition.F11_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F9_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F11_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.FC3_Url, + "user": commands.user.F8_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.F10_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "IscsiData": commands.iscsi.F10_IscsiData, + "LogVolData": commands.logvol.F9_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.F11_PartData, + "RaidData": commands.raid.F9_RaidData, + "RepoData": commands.repo.F11_RepoData, + "UserData": commands.user.F8_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f12.py b/mic/3rdparty/pykickstart/handlers/f12.py index cea3ece..145de1f 100644 --- a/mic/3rdparty/pykickstart/handlers/f12.py +++ b/mic/3rdparty/pykickstart/handlers/f12.py @@ -15,10 +15,91 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F12Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F12 class F12Handler(BaseHandler): version = F12 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F12_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F12_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F12_DriverDisk, + "fcoe": commands.fcoe.F12_Fcoe, + "firewall": commands.firewall.F10_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.F10_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F12_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F9_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F12_Partition, + "partition": commands.partition.F12_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F12_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F11_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.FC3_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.F10_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F12_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.F12_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F12_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F10_IscsiData, + "LogVolData": commands.logvol.F12_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.F12_PartData, + "RaidData": commands.raid.F12_RaidData, + "RepoData": commands.repo.F11_RepoData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.F12_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f13.py b/mic/3rdparty/pykickstart/handlers/f13.py index b94c738..3832d60 100644 --- a/mic/3rdparty/pykickstart/handlers/f13.py +++ b/mic/3rdparty/pykickstart/handlers/f13.py @@ -15,10 +15,93 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F13Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F13 class F13Handler(BaseHandler): version = F13 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F12_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F12_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F12_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F10_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.F10_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F12_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F13_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F9_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F12_Partition, + "partition": commands.partition.F12_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F13_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F13_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.F13_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.F10_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F12_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.F12_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F10_IscsiData, + "LogVolData": commands.logvol.F12_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.F12_PartData, + "RaidData": commands.raid.F13_RaidData, + "RepoData": commands.repo.F13_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.F12_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f14.py b/mic/3rdparty/pykickstart/handlers/f14.py index 478f75d..cede798 100644 --- a/mic/3rdparty/pykickstart/handlers/f14.py +++ b/mic/3rdparty/pykickstart/handlers/f14.py @@ -15,10 +15,93 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F14Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F14 class F14Handler(BaseHandler): version = F14 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F12_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F14_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F14_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "interactive": commands.interactive.F14_Interactive, + "iscsi": commands.iscsi.F10_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F14_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F14_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F9_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F14_Partition, + "partition": commands.partition.F14_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F14_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F14_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.F14_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F10_IscsiData, + "LogVolData": commands.logvol.F14_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.F14_PartData, + "RaidData": commands.raid.F14_RaidData, + "RepoData": commands.repo.F14_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f15.py b/mic/3rdparty/pykickstart/handlers/f15.py index 12aecb4..194806c 100644 --- a/mic/3rdparty/pykickstart/handlers/f15.py +++ b/mic/3rdparty/pykickstart/handlers/f15.py @@ -15,10 +15,93 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F15Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F15 class F15Handler(BaseHandler): version = F15 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F12_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F15_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F14_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "interactive": commands.interactive.F15_Interactive, # RemovedCommand + "iscsi": commands.iscsi.F10_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F15_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F14_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F9_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F14_Partition, + "partition": commands.partition.F14_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F15_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F15_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.F14_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F10_IscsiData, + "LogVolData": commands.logvol.F15_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.F14_PartData, + "RaidData": commands.raid.F15_RaidData, + "RepoData": commands.repo.F15_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f16.py b/mic/3rdparty/pykickstart/handlers/f16.py index 3c52f8d..d7b74f6 100644 --- a/mic/3rdparty/pykickstart/handlers/f16.py +++ b/mic/3rdparty/pykickstart/handlers/f16.py @@ -15,10 +15,92 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F16Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F16 class F16Handler(BaseHandler): version = F16 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F16_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F15_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F14_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "iscsi": commands.iscsi.F10_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F15_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F14_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F16_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F14_Partition, + "partition": commands.partition.F14_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F15_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F15_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.F14_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F16_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F10_IscsiData, + "LogVolData": commands.logvol.F17_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F16_NetworkData, + "PartData": commands.partition.F17_PartData, + "RaidData": commands.raid.F15_RaidData, + "RepoData": commands.repo.F15_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.F16_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f17.py b/mic/3rdparty/pykickstart/handlers/f17.py new file mode 100644 index 0000000..ea28516 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f17.py @@ -0,0 +1,108 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2011 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F17Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F17 + +class F17Handler(BaseHandler): + version = F17 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F17_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F17_Bootloader, + "btrfs": commands.btrfs.F17_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F17_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F14_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F17_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F14_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F16_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F17_Partition, + "partition": commands.partition.F17_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F15_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F15_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.F14_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F16_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F17_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F17_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F16_NetworkData, + "PartData": commands.partition.F17_PartData, + "RaidData": commands.raid.F15_RaidData, + "RepoData": commands.repo.F15_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.F16_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f18.py b/mic/3rdparty/pykickstart/handlers/f18.py new file mode 100644 index 0000000..128d752 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f18.py @@ -0,0 +1,108 @@ +# +# Vratislav Podzimek <vpodzime@redhat.com> +# +# Copyright 2012 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F18Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F18 + +class F18Handler(BaseHandler): + version = F18 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F18_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F18_Bootloader, + "btrfs": commands.btrfs.F17_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F17_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F14_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F18_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F18_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F18_Method, + "monitor": commands.monitor.F18_Monitor, # RemovedCommand + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F18_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F18_Partition, + "partition": commands.partition.F18_Partition, + "poweroff": commands.reboot.F18_Reboot, + "raid": commands.raid.F18_Raid, + "reboot": commands.reboot.F18_Reboot, + "repo": commands.repo.F15_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F18_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F18_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F16_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F17_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.RHEL7_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F18_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F16_NetworkData, + "PartData": commands.partition.F18_PartData, + "RaidData": commands.raid.F18_RaidData, + "RepoData": commands.repo.F15_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.F16_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f19.py b/mic/3rdparty/pykickstart/handlers/f19.py new file mode 100644 index 0000000..d55a9e2 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f19.py @@ -0,0 +1,109 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F19Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F19 + +class F19Handler(BaseHandler): + version = F19 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F18_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F19_Bootloader, + "btrfs": commands.btrfs.F17_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F17_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F14_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F18_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F18_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F19_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F18_Partition, + "partition": commands.partition.F18_Partition, + "poweroff": commands.reboot.F18_Reboot, + "raid": commands.raid.F19_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F18_Reboot, + "repo": commands.repo.F15_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F18_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F18_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F19_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F16_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F17_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F20_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F19_NetworkData, + "PartData": commands.partition.F18_PartData, + "RaidData": commands.raid.F18_RaidData, + "RepoData": commands.repo.F15_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F16_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f20.py b/mic/3rdparty/pykickstart/handlers/f20.py new file mode 100644 index 0000000..2ac73c6 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f20.py @@ -0,0 +1,110 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2013 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F20Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F20 + +class F20Handler(BaseHandler): + version = F20 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F20_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F19_Bootloader, + "btrfs": commands.btrfs.F17_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F17_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F18_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F20_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F20_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F20_Partition, + "partition": commands.partition.F20_Partition, + "poweroff": commands.reboot.F18_Reboot, + "raid": commands.raid.F20_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F18_Reboot, + "repo": commands.repo.F15_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F18_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F18_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F19_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F16_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F17_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F20_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F20_NetworkData, + "PartData": commands.partition.F18_PartData, + "RaidData": commands.raid.F18_RaidData, + "RepoData": commands.repo.F15_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F16_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f21.py b/mic/3rdparty/pykickstart/handlers/f21.py new file mode 100644 index 0000000..28f4e6b --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f21.py @@ -0,0 +1,111 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2014 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F21Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F21 + +class F21Handler(BaseHandler): + version = F21 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F21_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F17_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F21_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F18_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F21_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F21_Network, + "nfs": commands.nfs.FC6_NFS, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F20_Partition, + "partition": commands.partition.F20_Partition, + "poweroff": commands.reboot.F18_Reboot, + "raid": commands.raid.F20_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F18_Reboot, + "repo": commands.repo.F21_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F18_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F18_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F19_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F17_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F21_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F21_NetworkData, + "PartData": commands.partition.F18_PartData, + "RaidData": commands.raid.F18_RaidData, + "RepoData": commands.repo.F21_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f22.py b/mic/3rdparty/pykickstart/handlers/f22.py new file mode 100644 index 0000000..1cd96a1 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f22.py @@ -0,0 +1,113 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2014 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F22Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F22 + +class F22Handler(BaseHandler): + version = F22 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F21_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F17_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F21_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F18_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F21_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F22_Network, + "nfs": commands.nfs.FC6_NFS, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F20_Partition, + "partition": commands.partition.F20_Partition, + "poweroff": commands.reboot.F18_Reboot, + "raid": commands.raid.F20_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F18_Reboot, + "repo": commands.repo.F21_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F18_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F18_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F19_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F17_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F21_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F22_NetworkData, + "PartData": commands.partition.F18_PartData, + "RaidData": commands.raid.F18_RaidData, + "RepoData": commands.repo.F21_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f23.py b/mic/3rdparty/pykickstart/handlers/f23.py new file mode 100644 index 0000000..daa888a --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f23.py @@ -0,0 +1,114 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F23Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F23 + +class F23Handler(BaseHandler): + version = F23 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F23_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F21_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F23_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F22_Network, + "nfs": commands.nfs.FC6_NFS, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F23_Partition, + "partition": commands.partition.F23_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F23_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F21_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F23_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F19_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F23_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F22_NetworkData, + "PartData": commands.partition.F23_PartData, + "RaidData": commands.raid.F23_RaidData, + "RepoData": commands.repo.F21_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f24.py b/mic/3rdparty/pykickstart/handlers/f24.py new file mode 100644 index 0000000..f888c54 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f24.py @@ -0,0 +1,114 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F24Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F24 + +class F24Handler(BaseHandler): + version = F24 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F23_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F21_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F23_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F24_Network, + "nfs": commands.nfs.FC6_NFS, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F23_Partition, + "partition": commands.partition.F23_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F23_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F21_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F23_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F23_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F22_NetworkData, + "PartData": commands.partition.F23_PartData, + "RaidData": commands.raid.F23_RaidData, + "RepoData": commands.repo.F21_RepoData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f25.py b/mic/3rdparty/pykickstart/handlers/f25.py new file mode 100644 index 0000000..5ff744f --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f25.py @@ -0,0 +1,114 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F25Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F25 + +class F25Handler(BaseHandler): + version = F25 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F23_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F25_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F25_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F23_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F25_Network, + "nfs": commands.nfs.FC6_NFS, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F23_Partition, + "partition": commands.partition.F23_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F25_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F21_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F23_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F25_NetworkData, + "PartData": commands.partition.F23_PartData, + "RaidData": commands.raid.F25_RaidData, + "RepoData": commands.repo.F21_RepoData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f26.py b/mic/3rdparty/pykickstart/handlers/f26.py new file mode 100644 index 0000000..0bfa9ba --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f26.py @@ -0,0 +1,116 @@ +# +# Jiri Konecny <jkonecny@redhat.com> +# +# Copyright 2016 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F26Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F26 + +class F26Handler(BaseHandler): + version = F26 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F26_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F25_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F25_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F23_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F25_Network, + "nfs": commands.nfs.FC6_NFS, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F23_Partition, + "partition": commands.partition.F23_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F25_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F21_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F23_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F25_NetworkData, + "PartData": commands.partition.F23_PartData, + "RaidData": commands.raid.F25_RaidData, + "RepoData": commands.repo.F21_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f27.py b/mic/3rdparty/pykickstart/handlers/f27.py new file mode 100644 index 0000000..465fd8d --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f27.py @@ -0,0 +1,118 @@ +# +# Radek Vykydal <rvykydal@redhat.com> +# +# Copyright 2017 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F27Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F27 + +class F27Handler(BaseHandler): + version = F27 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F26_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F25_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F25_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F23_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F19_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F23_Partition, + "partition": commands.partition.F23_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F25_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F27_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F27_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F23_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "PartData": commands.partition.F23_PartData, + "RaidData": commands.raid.F25_RaidData, + "RepoData": commands.repo.F27_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f28.py b/mic/3rdparty/pykickstart/handlers/f28.py new file mode 100644 index 0000000..e972dc1 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f28.py @@ -0,0 +1,122 @@ +# +# Vendula Poncova <vponcova@redhat.com> +# +# Copyright 2017 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F28Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F28 + +class F28Handler(BaseHandler): + version = F28 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F26_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F21_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "hmc" : commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F25_IgnoreDisk, + "install": commands.install.F20_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F23_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F28_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F23_Partition, + "partition": commands.partition.F23_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F25_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F27_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F27_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F23_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F23_PartData, + "RaidData": commands.raid.F25_RaidData, + "RepoData": commands.repo.F27_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f29.py b/mic/3rdparty/pykickstart/handlers/f29.py new file mode 100644 index 0000000..93fdf60 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f29.py @@ -0,0 +1,124 @@ +# +# Vendula Poncova <vponcova@redhat.com> +# +# Copyright 2018 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F29Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F29 + +class F29Handler(BaseHandler): + version = F29 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F29_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.F29_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module" : commands.module.F29_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "hmc" : commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F29_IgnoreDisk, + "install": commands.install.F29_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F28_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F29_Partition, + "partition": commands.partition.F29_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F27_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F29_Upgrade, # RemovedCommand + "url": commands.url.F27_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData" : commands.module.F29_ModuleData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F27_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f30.py b/mic/3rdparty/pykickstart/handlers/f30.py new file mode 100644 index 0000000..17b0476 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f30.py @@ -0,0 +1,123 @@ +# +# Lars Karlitski <lars@karlitski.net> +# +# Copyright 2019 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F30Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F30 + +class F30Handler(BaseHandler): + version = F30 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F29_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.F29_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module" : commands.module.F29_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "hmc" : commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F29_IgnoreDisk, + "install": commands.install.F29_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F28_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F29_Partition, + "partition": commands.partition.F29_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F30_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData" : commands.module.F29_ModuleData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f31.py b/mic/3rdparty/pykickstart/handlers/f31.py new file mode 100644 index 0000000..7d0eb4a --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f31.py @@ -0,0 +1,123 @@ +# +# Martin Kolman <mkolman@redhat.com> +# +# Copyright 2019 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F31Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F31 + +class F31Handler(BaseHandler): + version = F31 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F29_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.F29_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module" : commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "hmc" : commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F29_IgnoreDisk, + "install": commands.install.F29_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F28_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F29_Partition, + "partition": commands.partition.F29_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F30_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData" : commands.module.F31_ModuleData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f32.py b/mic/3rdparty/pykickstart/handlers/f32.py new file mode 100644 index 0000000..4eea36f --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f32.py @@ -0,0 +1,122 @@ +# +# Copyright 2019 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F32Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F32 + +class F32Handler(BaseHandler): + version = F32 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F29_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.F29_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module": commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "hmc": commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F29_IgnoreDisk, + "install": commands.install.F29_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F28_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F29_Partition, + "partition": commands.partition.F29_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F30_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F32_Timezone, + "updates": commands.updates.F7_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + "zipl": commands.zipl.F32_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData": commands.module.F31_ModuleData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f33.py b/mic/3rdparty/pykickstart/handlers/f33.py new file mode 100644 index 0000000..114d583 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f33.py @@ -0,0 +1,124 @@ +# +# Copyright 2020 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F33Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F33 + +class F33Handler(BaseHandler): + version = F33 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F29_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.F29_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module": commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.F33_HardDrive, + "hmc": commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F29_IgnoreDisk, + "install": commands.install.F29_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F28_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "timesource": commands.timesource.F33_Timesource, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F29_Partition, + "partition": commands.partition.F29_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F33_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F33_Timezone, + "updates": commands.updates.F7_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + "zipl": commands.zipl.F32_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData": commands.module.F31_ModuleData, + "TimesourceData": commands.timesource.F33_TimesourceData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f34.py b/mic/3rdparty/pykickstart/handlers/f34.py new file mode 100644 index 0000000..dc2f7ec --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f34.py @@ -0,0 +1,124 @@ +# +# Copyright 2020 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F34Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F34 + +class F34Handler(BaseHandler): + version = F34 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.F34_AutoStep, + "bootloader": commands.bootloader.F34_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F34_Device, + "deviceprobe": commands.deviceprobe.F34_DeviceProbe, + "dmraid": commands.dmraid.F34_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module": commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.F33_HardDrive, + "hmc": commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F34_IgnoreDisk, + "install": commands.install.F34_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.F34_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F34_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F34_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "timesource": commands.timesource.F33_Timesource, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F34_Partition, + "partition": commands.partition.F34_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F33_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F33_Timezone, + "updates": commands.updates.F34_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + "zipl": commands.zipl.F32_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData": commands.module.F31_ModuleData, + "TimesourceData": commands.timesource.F33_TimesourceData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f35.py b/mic/3rdparty/pykickstart/handlers/f35.py new file mode 100644 index 0000000..be5a81e --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f35.py @@ -0,0 +1,124 @@ +# +# Copyright 2021 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F35Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F35 + +class F35Handler(BaseHandler): + version = F35 + + commandMap = { + "auth": commands.authconfig.F35_Authconfig, # RemovedCommand + "authconfig": commands.authconfig.F35_Authconfig, # RemovedCommand + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.F34_AutoStep, + "bootloader": commands.bootloader.F34_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F34_Device, + "deviceprobe": commands.deviceprobe.F34_DeviceProbe, + "dmraid": commands.dmraid.F34_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module": commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.F33_HardDrive, + "hmc": commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F34_IgnoreDisk, + "install": commands.install.F34_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.F34_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F34_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F34_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "timesource": commands.timesource.F33_Timesource, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F34_Partition, + "partition": commands.partition.F34_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F33_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F33_Timezone, + "updates": commands.updates.F34_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + "zipl": commands.zipl.F32_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData": commands.module.F31_ModuleData, + "TimesourceData": commands.timesource.F33_TimesourceData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f36.py b/mic/3rdparty/pykickstart/handlers/f36.py new file mode 100644 index 0000000..8241d1a --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f36.py @@ -0,0 +1,124 @@ +# +# Copyright 2021 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F36Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F36 + +class F36Handler(BaseHandler): + version = F36 + + commandMap = { + "auth": commands.authconfig.F35_Authconfig, # RemovedCommand + "authconfig": commands.authconfig.F35_Authconfig, # RemovedCommand + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.F34_AutoStep, + "bootloader": commands.bootloader.F34_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F34_Device, + "deviceprobe": commands.deviceprobe.F34_DeviceProbe, + "dmraid": commands.dmraid.F34_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module": commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.F33_HardDrive, + "hmc": commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F34_IgnoreDisk, + "install": commands.install.F34_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.F34_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F34_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F34_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "timesource": commands.timesource.F33_Timesource, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F34_Partition, + "partition": commands.partition.F34_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F33_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F33_Timezone, + "updates": commands.updates.F34_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + "zipl": commands.zipl.F32_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData": commands.module.F31_ModuleData, + "TimesourceData": commands.timesource.F33_TimesourceData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f37.py b/mic/3rdparty/pykickstart/handlers/f37.py new file mode 100644 index 0000000..c393bb8 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/f37.py @@ -0,0 +1,124 @@ +# +# Copyright 2021 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["F37Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F37 + +class F37Handler(BaseHandler): + version = F37 + + commandMap = { + "auth": commands.authconfig.F35_Authconfig, # RemovedCommand + "authconfig": commands.authconfig.F35_Authconfig, # RemovedCommand + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.F29_AutoPart, + "autostep": commands.autostep.F34_AutoStep, + "bootloader": commands.bootloader.F34_Bootloader, + "btrfs": commands.btrfs.F23_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F34_Device, + "deviceprobe": commands.deviceprobe.F34_DeviceProbe, + "dmraid": commands.dmraid.F34_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module": commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.F28_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.F33_HardDrive, + "hmc": commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F34_IgnoreDisk, + "install": commands.install.F34_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.F34_Logging, + "logvol": commands.logvol.F29_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F34_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F34_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "timesource": commands.timesource.F33_Timesource, + "ostreesetup": commands.ostreesetup.F21_OSTreeSetup, + "part": commands.partition.F34_Partition, + "partition": commands.partition.F34_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.F29_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F33_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F37_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F33_Timezone, + "updates": commands.updates.F34_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F21_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F37_ZFCP, + "zipl": commands.zipl.F32_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData": commands.module.F31_ModuleData, + "TimesourceData": commands.timesource.F33_TimesourceData, + "FcoeData": commands.fcoe.F28_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.F21_VolGroupData, + "ZFCPData": commands.zfcp.F37_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f7.py b/mic/3rdparty/pykickstart/handlers/f7.py index 5e856ea..3abe0df 100644 --- a/mic/3rdparty/pykickstart/handlers/f7.py +++ b/mic/3rdparty/pykickstart/handlers/f7.py @@ -15,10 +15,87 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F7Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F7 class F7Handler(BaseHandler): version = F7 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.FC4_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.FC3_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.FC6_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.F7_LangSupport, # RemovedCommand + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.FC4_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.FC6_Monitor, + "mouse": commands.mouse.F7_Mouse, # RemovedCommand + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.FC6_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.FC4_Partition, + "partition": commands.partition.FC4_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F7_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.FC6_Repo, + "rootpw": commands.rootpw.FC3_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "user": commands.user.FC6_User, + "vnc": commands.vnc.FC6_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC6_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "IscsiData": commands.iscsi.FC6_IscsiData, + "LogVolData": commands.logvol.FC4_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.FC6_NetworkData, + "PartData": commands.partition.FC4_PartData, + "RaidData": commands.raid.F7_RaidData, + "RepoData": commands.repo.FC6_RepoData, + "UserData": commands.user.FC6_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f8.py b/mic/3rdparty/pykickstart/handlers/f8.py index 1a97881..8f82b03 100644 --- a/mic/3rdparty/pykickstart/handlers/f8.py +++ b/mic/3rdparty/pykickstart/handlers/f8.py @@ -15,10 +15,86 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F8Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F8 class F8Handler(BaseHandler): version = F8 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F8_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.FC6_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.FC4_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.FC6_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F8_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.FC4_Partition, + "partition": commands.partition.FC4_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F7_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F8_Repo, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "user": commands.user.F8_User, + "vnc": commands.vnc.FC6_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC6_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "IscsiData": commands.iscsi.FC6_IscsiData, + "LogVolData": commands.logvol.FC4_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.FC4_PartData, + "RaidData": commands.raid.F7_RaidData, + "RepoData": commands.repo.F8_RepoData, + "UserData": commands.user.F8_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/f9.py b/mic/3rdparty/pykickstart/handlers/f9.py index 116f1b5..85f9d6d 100644 --- a/mic/3rdparty/pykickstart/handlers/f9.py +++ b/mic/3rdparty/pykickstart/handlers/f9.py @@ -15,10 +15,86 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["F9Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import F9 class F9Handler(BaseHandler): version = F9 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F9_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.F8_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.F9_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.FC6_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.F9_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.FC6_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.F9_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.F9_Partition, + "partition": commands.partition.F9_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.F9_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.F8_Repo, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "user": commands.user.F8_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.F9_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "IscsiData": commands.iscsi.FC6_IscsiData, + "LogVolData": commands.logvol.F9_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F8_NetworkData, + "PartData": commands.partition.F9_PartData, + "RaidData": commands.raid.F9_RaidData, + "RepoData": commands.repo.F8_RepoData, + "UserData": commands.user.F8_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/fc3.py b/mic/3rdparty/pykickstart/handlers/fc3.py index a115dc2..101b5bb 100644 --- a/mic/3rdparty/pykickstart/handlers/fc3.py +++ b/mic/3rdparty/pykickstart/handlers/fc3.py @@ -15,10 +15,74 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["FC3Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import FC3 class FC3Handler(BaseHandler): version = FC3 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.FC3_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "driverdisk": commands.driverdisk.FC3_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC3_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.FC3_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.FC3_LangSupport, + "lilo": commands.bootloader.FC3_Lilo, + "lilocheck": commands.lilocheck.FC3_LiloCheck, + "logvol": commands.logvol.FC3_LogVol, + "method": commands.method.FC3_Method, + "monitor": commands.monitor.FC3_Monitor, + "mouse": commands.mouse.FC3_Mouse, + "network": commands.network.FC3_Network, + "nfs": commands.nfs.FC3_NFS, + "part": commands.partition.FC3_Partition, + "partition": commands.partition.FC3_Partition, + "poweroff": commands.reboot.FC3_Reboot, + "raid": commands.raid.FC3_Raid, + "reboot": commands.reboot.FC3_Reboot, + "rootpw": commands.rootpw.FC3_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "shutdown": commands.reboot.FC3_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC3_Timezone, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "vnc": commands.vnc.FC3_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC3_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC3_DriverDiskData, + "LogVolData": commands.logvol.FC3_LogVolData, + "NetworkData": commands.network.FC3_NetworkData, + "PartData": commands.partition.FC3_PartData, + "RaidData": commands.raid.FC3_RaidData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/fc4.py b/mic/3rdparty/pykickstart/handlers/fc4.py index fd47b73..91c3d99 100644 --- a/mic/3rdparty/pykickstart/handlers/fc4.py +++ b/mic/3rdparty/pykickstart/handlers/fc4.py @@ -15,10 +15,75 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["FC4Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import FC4 class FC4Handler(BaseHandler): version = FC4 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.FC4_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC3_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.FC3_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.FC3_LangSupport, + "lilo": commands.bootloader.FC4_Lilo, # RemovedCommand + "lilocheck": commands.lilocheck.FC4_LiloCheck, # RemovedCommand + "logvol": commands.logvol.FC4_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC3_Method, + "monitor": commands.monitor.FC3_Monitor, + "mouse": commands.mouse.FC3_Mouse, + "network": commands.network.FC4_Network, + "nfs": commands.nfs.FC3_NFS, + "part": commands.partition.FC4_Partition, + "partition": commands.partition.FC4_Partition, + "poweroff": commands.reboot.FC3_Reboot, + "raid": commands.raid.FC4_Raid, + "reboot": commands.reboot.FC3_Reboot, + "rootpw": commands.rootpw.FC3_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "shutdown": commands.reboot.FC3_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC3_Timezone, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "vnc": commands.vnc.FC3_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC3_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "LogVolData": commands.logvol.FC4_LogVolData, + "NetworkData": commands.network.FC4_NetworkData, + "PartData": commands.partition.FC4_PartData, + "RaidData": commands.raid.FC4_RaidData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/fc5.py b/mic/3rdparty/pykickstart/handlers/fc5.py index bcdc29d..74ec5e9 100644 --- a/mic/3rdparty/pykickstart/handlers/fc5.py +++ b/mic/3rdparty/pykickstart/handlers/fc5.py @@ -15,10 +15,73 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["FC5Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import FC5 class FC5Handler(BaseHandler): version = FC5 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.FC4_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC3_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.FC3_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.FC5_LangSupport, + "logvol": commands.logvol.FC4_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC3_Method, + "monitor": commands.monitor.FC3_Monitor, + "mouse": commands.mouse.FC3_Mouse, + "network": commands.network.FC4_Network, + "nfs": commands.nfs.FC3_NFS, + "part": commands.partition.FC4_Partition, + "partition": commands.partition.FC4_Partition, + "poweroff": commands.reboot.FC3_Reboot, + "raid": commands.raid.FC5_Raid, + "reboot": commands.reboot.FC3_Reboot, + "rootpw": commands.rootpw.FC3_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "shutdown": commands.reboot.FC3_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC3_Timezone, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "vnc": commands.vnc.FC3_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC3_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "LogVolData": commands.logvol.FC4_LogVolData, + "NetworkData": commands.network.FC4_NetworkData, + "PartData": commands.partition.FC4_PartData, + "RaidData": commands.raid.FC5_RaidData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/fc6.py b/mic/3rdparty/pykickstart/handlers/fc6.py index c83a929..392a85d 100644 --- a/mic/3rdparty/pykickstart/handlers/fc6.py +++ b/mic/3rdparty/pykickstart/handlers/fc6.py @@ -17,8 +17,87 @@ # subject to the GNU General Public License and may only be used or replicated # with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["FC6Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import FC6 +from mic.kickstart.custom_commands.micrepo import * class FC6Handler(BaseHandler): version = FC6 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.FC4_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.FC3_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.FC6_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.FC5_LangSupport, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.FC4_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.FC6_Monitor, + "mouse": commands.mouse.FC3_Mouse, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.FC6_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.FC4_Partition, + "partition": commands.partition.FC4_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.FC5_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.FC6_Repo, + "tpk_repo": Mic_Tpk_Repo, + "rootpw": commands.rootpw.FC3_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "upgrade": commands.upgrade.FC3_Upgrade, + "user": commands.user.FC6_User, + "url": commands.url.FC3_Url, + "vnc": commands.vnc.FC6_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC6_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "IscsiData": commands.iscsi.FC6_IscsiData, + "LogVolData": commands.logvol.FC4_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.FC6_NetworkData, + "PartData": commands.partition.FC4_PartData, + "RaidData": commands.raid.FC5_RaidData, + "TpkRepoData": Mic_Tpk_RepoData, + "RepoData": commands.repo.FC6_RepoData, + "UserData": commands.user.FC6_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/rhel3.py b/mic/3rdparty/pykickstart/handlers/rhel3.py index 131763c..7eb3f22 100644 --- a/mic/3rdparty/pykickstart/handlers/rhel3.py +++ b/mic/3rdparty/pykickstart/handlers/rhel3.py @@ -15,10 +15,72 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["RHEL3Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import RHEL3 class RHEL3Handler(BaseHandler): version = RHEL3 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.FC3_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "driverdisk": commands.driverdisk.FC3_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC3_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.FC3_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.FC3_LangSupport, + "lilo": commands.bootloader.FC3_Lilo, + "lilocheck": commands.lilocheck.FC3_LiloCheck, + "logvol": commands.logvol.FC3_LogVol, + "method": commands.method.FC3_Method, + "monitor": commands.monitor.FC3_Monitor, + "mouse": commands.mouse.RHEL3_Mouse, + "network": commands.network.FC3_Network, + "nfs": commands.nfs.FC3_NFS, + "part": commands.partition.FC3_Partition, + "partition": commands.partition.FC3_Partition, + "poweroff": commands.reboot.FC3_Reboot, + "raid": commands.raid.FC3_Raid, + "reboot": commands.reboot.FC3_Reboot, + "rootpw": commands.rootpw.FC3_RootPw, + "shutdown": commands.reboot.FC3_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC3_Timezone, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "vnc": commands.vnc.FC3_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC3_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC3_DriverDiskData, + "LogVolData": commands.logvol.FC3_LogVolData, + "NetworkData": commands.network.RHEL4_NetworkData, + "PartData": commands.partition.FC3_PartData, + "RaidData": commands.raid.FC3_RaidData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/rhel4.py b/mic/3rdparty/pykickstart/handlers/rhel4.py index 3496c43..d5d00f6 100644 --- a/mic/3rdparty/pykickstart/handlers/rhel4.py +++ b/mic/3rdparty/pykickstart/handlers/rhel4.py @@ -15,10 +15,74 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["RHEL4Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import RHEL4 class RHEL4Handler(BaseHandler): version = RHEL4 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.FC3_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.FC3_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "driverdisk": commands.driverdisk.FC4_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC3_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.FC3_LangSupport, + "lilo": commands.bootloader.FC3_Lilo, + "lilocheck": commands.lilocheck.FC3_LiloCheck, + "logvol": commands.logvol.FC3_LogVol, + "method": commands.method.FC3_Method, + "monitor": commands.monitor.FC3_Monitor, + "mouse": commands.mouse.FC3_Mouse, + "network": commands.network.RHEL4_Network, + "nfs": commands.nfs.FC3_NFS, + "part": commands.partition.FC3_Partition, + "partition": commands.partition.FC3_Partition, + "poweroff": commands.reboot.FC3_Reboot, + "raid": commands.raid.FC3_Raid, + "reboot": commands.reboot.FC3_Reboot, + "rootpw": commands.rootpw.FC3_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "shutdown": commands.reboot.FC3_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC3_Timezone, + "upgrade": commands.upgrade.FC3_Upgrade, + "url": commands.url.FC3_Url, + "vnc": commands.vnc.FC3_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC3_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.FC4_DriverDiskData, + "LogVolData": commands.logvol.FC3_LogVolData, + "NetworkData": commands.network.RHEL4_NetworkData, + "PartData": commands.partition.FC3_PartData, + "RaidData": commands.raid.FC3_RaidData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/rhel5.py b/mic/3rdparty/pykickstart/handlers/rhel5.py index abb7a8d..14c5366 100644 --- a/mic/3rdparty/pykickstart/handlers/rhel5.py +++ b/mic/3rdparty/pykickstart/handlers/rhel5.py @@ -15,10 +15,87 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["RHEL5Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import RHEL5 class RHEL5Handler(BaseHandler): version = RHEL5 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.F9_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.RHEL5_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.FC3_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F12_DriverDisk, + "firewall": commands.firewall.FC3_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.F8_IgnoreDisk, + "install": commands.upgrade.FC3_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.FC6_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "key": commands.key.RHEL5_Key, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "langsupport": commands.langsupport.FC5_LangSupport, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.RHEL5_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.FC6_Method, + "monitor": commands.monitor.FC6_Monitor, + "mouse": commands.mouse.FC3_Mouse, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.RHEL5_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.RHEL5_Partition, + "partition": commands.partition.RHEL5_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.RHEL5_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.FC6_Repo, + "rootpw": commands.rootpw.FC3_RootPw, + "services": commands.services.FC6_Services, + "selinux": commands.selinux.FC3_SELinux, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "upgrade": commands.upgrade.FC3_Upgrade, + "user": commands.user.FC6_User, + "url": commands.url.FC3_Url, + "vnc": commands.vnc.FC6_Vnc, + "volgroup": commands.volgroup.FC3_VolGroup, + "xconfig": commands.xconfig.FC6_XConfig, + "zerombr": commands.zerombr.FC3_ZeroMbr, + "zfcp": commands.zfcp.FC3_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.F12_DriverDiskData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "IscsiData": commands.iscsi.FC6_IscsiData, + "LogVolData": commands.logvol.RHEL5_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.FC6_NetworkData, + "PartData": commands.partition.RHEL5_PartData, + "RaidData": commands.raid.RHEL5_RaidData, + "RepoData": commands.repo.FC6_RepoData, + "UserData": commands.user.FC6_UserData, + "VolGroupData": commands.volgroup.FC3_VolGroupData, + "ZFCPData": commands.zfcp.FC3_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/rhel6.py b/mic/3rdparty/pykickstart/handlers/rhel6.py index 7202419..6753448 100644 --- a/mic/3rdparty/pykickstart/handlers/rhel6.py +++ b/mic/3rdparty/pykickstart/handlers/rhel6.py @@ -15,10 +15,95 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # -from pykickstart.base import * -from pykickstart.version import * +__all__ = ["RHEL6Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import RHEL6 class RHEL6Handler(BaseHandler): version = RHEL6 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.RHEL6_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.RHEL6_Bootloader, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.FC3_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F12_DriverDisk, + "fcoe": commands.fcoe.F13_Fcoe, + "firewall": commands.firewall.F10_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.FC6_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "ignoredisk": commands.ignoredisk.RHEL6_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "interactive": commands.interactive.FC3_Interactive, + "iscsi": commands.iscsi.RHEL6_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "key": commands.key.RHEL5_Key, + "keyboard": commands.keyboard.FC3_Keyboard, + "lang": commands.lang.FC3_Lang, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.RHEL6_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.RHEL6_Method, + "monitor": commands.monitor.F10_Monitor, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.RHEL6_Network, + "nfs": commands.nfs.FC6_NFS, + "part": commands.partition.RHEL6_Partition, + "partition": commands.partition.RHEL6_Partition, + "poweroff": commands.reboot.FC6_Reboot, + "raid": commands.raid.RHEL6_Raid, + "reboot": commands.reboot.FC6_Reboot, + "repo": commands.repo.RHEL6_Repo, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F8_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.FC6_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.FC6_Timezone, + "unsupported_hardware": commands.unsupported_hardware.RHEL6_UnsupportedHardware, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F11_Upgrade, + "url": commands.url.RHEL6_Url, + "user": commands.user.F12_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.F16_VolGroup, + "xconfig": commands.xconfig.F10_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F12_ZFCP, + } + + dataMap = { + "DriverDiskData": commands.driverdisk.F12_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.F13_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.RHEL6_IscsiData, + "LogVolData": commands.logvol.RHEL6_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.RHEL6_NetworkData, + "PartData": commands.partition.RHEL6_PartData, + "RaidData": commands.raid.RHEL6_RaidData, + "RepoData": commands.repo.RHEL6_RepoData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F12_UserData, + "VolGroupData": commands.volgroup.F16_VolGroupData, + "ZFCPData": commands.zfcp.F12_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/rhel7.py b/mic/3rdparty/pykickstart/handlers/rhel7.py new file mode 100644 index 0000000..52f5642 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/rhel7.py @@ -0,0 +1,118 @@ +# +# Chris Lumens <clumens@redhat.com> +# +# Copyright 2012, 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["RHEL7Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import RHEL7 + +class RHEL7Handler(BaseHandler): + version = RHEL7 + + commandMap = { + "auth": commands.authconfig.FC3_Authconfig, + "authconfig": commands.authconfig.FC3_Authconfig, + "autopart": commands.autopart.RHEL7_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.RHEL7_Bootloader, + "btrfs": commands.btrfs.RHEL7_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.RHEL7_ClearPart, + "cmdline": commands.displaymode.FC3_DisplayMode, + "device": commands.device.F8_Device, + "deviceprobe": commands.deviceprobe.FC3_DeviceProbe, + "dmraid": commands.dmraid.FC6_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.RHEL7_Fcoe, + "firewall": commands.firewall.F20_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.FC3_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F18_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "hmc": commands.hmc.RHEL7_Hmc, + "ignoredisk": commands.ignoredisk.F14_IgnoreDisk, + "install": commands.upgrade.F11_Upgrade, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.RHEL7_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.RHEL7_Method, + "multipath": commands.multipath.FC6_MultiPath, + "network": commands.network.RHEL7_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "ostreesetup": commands.ostreesetup.RHEL7_OSTreeSetup, + "part": commands.partition.RHEL7_Partition, + "partition": commands.partition.RHEL7_Partition, + "poweroff": commands.reboot.F18_Reboot, + "raid": commands.raid.RHEL7_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F18_Reboot, + "repo": commands.repo.RHEL7_Repo, + "reqpart": commands.reqpart.RHEL7_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F18_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F13_SshPw, + "text": commands.displaymode.FC3_DisplayMode, + "timezone": commands.timezone.RHEL7_Timezone, + "unsupported_hardware": commands.unsupported_hardware.RHEL6_UnsupportedHardware, + "updates": commands.updates.F7_Updates, + "upgrade": commands.upgrade.F20_Upgrade, + "url": commands.url.F18_Url, + "user": commands.user.F19_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.RHEL7_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + } + + dataMap = { + "BTRFSData": commands.btrfs.RHEL7_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "FcoeData": commands.fcoe.RHEL7_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.RHEL7_LogVolData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.RHEL7_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.RHEL7_PartData, + "RaidData": commands.raid.RHEL7_RaidData, + "RepoData": commands.repo.RHEL7_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F13_SshPwData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.RHEL7_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/rhel8.py b/mic/3rdparty/pykickstart/handlers/rhel8.py new file mode 100644 index 0000000..d6a1e66 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/rhel8.py @@ -0,0 +1,126 @@ +# +# Radek Vykydal <rvykydal@redhat.com> +# +# Copyright 2018 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["RHEL8Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import RHEL8 + +class RHEL8Handler(BaseHandler): + version = RHEL8 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.RHEL8_AutoPart, + "autostep": commands.autostep.FC3_AutoStep, + "bootloader": commands.bootloader.RHEL8_Bootloader, + "btrfs": commands.btrfs.RHEL8_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F24_Device, + "deviceprobe": commands.deviceprobe.F29_DeviceProbe, + "dmraid": commands.dmraid.F24_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module" : commands.module.RHEL8_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.RHEL8_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.FC3_HardDrive, + "hmc" : commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F29_IgnoreDisk, + "install": commands.install.F29_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.FC6_Logging, + "logvol": commands.logvol.RHEL8_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F28_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F24_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "ostreesetup": commands.ostreesetup.RHEL8_OSTreeSetup, + "part": commands.partition.RHEL8_Partition, + "partition": commands.partition.RHEL8_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.RHEL8_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.RHEL8_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rhsm": commands.rhsm.RHEL8_RHSM, + "rootpw": commands.rootpw.F18_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "syspurpose" : commands.syspurpose.RHEL8_Syspurpose, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F25_Timezone, + "updates": commands.updates.F7_Updates, + "url": commands.url.RHEL8_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.RHEL8_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + "zipl": commands.zipl.RHEL8_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData" : commands.module.RHEL8_ModuleData, + "FcoeData": commands.fcoe.RHEL8_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.RHEL8_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.RHEL8_PartData, + "RaidData": commands.raid.RHEL8_RaidData, + "RepoData": commands.repo.RHEL8_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.RHEL8_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/handlers/rhel9.py b/mic/3rdparty/pykickstart/handlers/rhel9.py new file mode 100644 index 0000000..3c11575 --- /dev/null +++ b/mic/3rdparty/pykickstart/handlers/rhel9.py @@ -0,0 +1,128 @@ +# +# Martin Kolman <mkolman@redhat.com> +# +# Copyright 2021 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +__all__ = ["RHEL9Handler"] + +from pykickstart import commands +from pykickstart.base import BaseHandler +from pykickstart.version import RHEL9 + +class RHEL9Handler(BaseHandler): + version = RHEL9 + + commandMap = { + "auth": commands.authconfig.F28_Authconfig, + "authconfig": commands.authconfig.F28_Authconfig, + "authselect": commands.authselect.F28_Authselect, + "autopart": commands.autopart.RHEL9_AutoPart, + "autostep": commands.autostep.F34_AutoStep, + "bootloader": commands.bootloader.RHEL9_Bootloader, + "btrfs": commands.btrfs.RHEL9_BTRFS, + "cdrom": commands.cdrom.FC3_Cdrom, + "clearpart": commands.clearpart.F28_ClearPart, + "cmdline": commands.displaymode.F26_DisplayMode, + "device": commands.device.F34_Device, + "deviceprobe": commands.deviceprobe.F34_DeviceProbe, + "dmraid": commands.dmraid.F34_DmRaid, + "driverdisk": commands.driverdisk.F14_DriverDisk, + "module": commands.module.F31_Module, + "eula": commands.eula.F20_Eula, + "fcoe": commands.fcoe.RHEL9_Fcoe, + "firewall": commands.firewall.F28_Firewall, + "firstboot": commands.firstboot.FC3_Firstboot, + "graphical": commands.displaymode.F26_DisplayMode, + "group": commands.group.F12_Group, + "halt": commands.reboot.F23_Reboot, + "harddrive": commands.harddrive.F33_HardDrive, + "hmc": commands.hmc.F28_Hmc, + "ignoredisk": commands.ignoredisk.F34_IgnoreDisk, + "install": commands.install.F34_Install, + "iscsi": commands.iscsi.F17_Iscsi, + "iscsiname": commands.iscsiname.FC6_IscsiName, + "keyboard": commands.keyboard.F18_Keyboard, + "lang": commands.lang.F19_Lang, + "liveimg": commands.liveimg.F19_Liveimg, + "logging": commands.logging.F34_Logging, + "logvol": commands.logvol.RHEL9_LogVol, + "mediacheck": commands.mediacheck.FC4_MediaCheck, + "method": commands.method.F34_Method, + "mount": commands.mount.F27_Mount, + "multipath": commands.multipath.F34_MultiPath, + "network": commands.network.F27_Network, + "nfs": commands.nfs.FC6_NFS, + "nvdimm": commands.nvdimm.F28_Nvdimm, + "timesource": commands.timesource.F33_Timesource, + "ostreesetup": commands.ostreesetup.RHEL9_OSTreeSetup, + "part": commands.partition.RHEL9_Partition, + "partition": commands.partition.RHEL9_Partition, + "poweroff": commands.reboot.F23_Reboot, + "raid": commands.raid.RHEL9_Raid, + "realm": commands.realm.F19_Realm, + "reboot": commands.reboot.F23_Reboot, + "repo": commands.repo.F33_Repo, + "reqpart": commands.reqpart.F23_ReqPart, + "rescue": commands.rescue.F10_Rescue, + "rhsm": commands.rhsm.RHEL8_RHSM, + "rootpw": commands.rootpw.F37_RootPw, + "selinux": commands.selinux.FC3_SELinux, + "services": commands.services.FC6_Services, + "shutdown": commands.reboot.F23_Reboot, + "skipx": commands.skipx.FC3_SkipX, + "snapshot": commands.snapshot.F26_Snapshot, + "sshpw": commands.sshpw.F24_SshPw, + "sshkey": commands.sshkey.F22_SshKey, + "syspurpose" : commands.syspurpose.RHEL8_Syspurpose, + "text": commands.displaymode.F26_DisplayMode, + "timezone": commands.timezone.F33_Timezone, + "updates": commands.updates.F34_Updates, + "url": commands.url.F30_Url, + "user": commands.user.F24_User, + "vnc": commands.vnc.F9_Vnc, + "volgroup": commands.volgroup.RHEL9_VolGroup, + "xconfig": commands.xconfig.F14_XConfig, + "zerombr": commands.zerombr.F9_ZeroMbr, + "zfcp": commands.zfcp.F14_ZFCP, + "zipl": commands.zipl.F32_Zipl, + } + + dataMap = { + "BTRFSData": commands.btrfs.F23_BTRFSData, + "DriverDiskData": commands.driverdisk.F14_DriverDiskData, + "DeviceData": commands.device.F8_DeviceData, + "DmRaidData": commands.dmraid.FC6_DmRaidData, + "ModuleData": commands.module.F31_ModuleData, + "TimesourceData": commands.timesource.F33_TimesourceData, + "FcoeData": commands.fcoe.RHEL9_FcoeData, + "GroupData": commands.group.F12_GroupData, + "IscsiData": commands.iscsi.F17_IscsiData, + "LogVolData": commands.logvol.F29_LogVolData, + "MountData": commands.mount.F27_MountData, + "MultiPathData": commands.multipath.FC6_MultiPathData, + "NetworkData": commands.network.F27_NetworkData, + "NvdimmData": commands.nvdimm.F28_NvdimmData, + "PartData": commands.partition.F29_PartData, + "RaidData": commands.raid.F29_RaidData, + "RepoData": commands.repo.F30_RepoData, + "SnapshotData": commands.snapshot.F26_SnapshotData, + "SshPwData": commands.sshpw.F24_SshPwData, + "SshKeyData": commands.sshkey.F22_SshKeyData, + "UserData": commands.user.F19_UserData, + "VolGroupData": commands.volgroup.RHEL9_VolGroupData, + "ZFCPData": commands.zfcp.F14_ZFCPData, + } diff --git a/mic/3rdparty/pykickstart/i18n.py b/mic/3rdparty/pykickstart/i18n.py new file mode 100644 index 0000000..0fcbd12 --- /dev/null +++ b/mic/3rdparty/pykickstart/i18n.py @@ -0,0 +1,30 @@ +# +# Tomas Radej <tradej@redhat.com> +# +# Copyright 2015-2020 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +import gettext +import os + +def _find_locale_files(): + module_path = os.path.abspath(__file__) + locale_path = os.path.join(os.path.dirname(module_path), 'locale') + + gettext.bindtextdomain("pykickstart", locale_path) +_find_locale_files() + +_ = lambda x: gettext.translation("pykickstart", fallback=True).gettext(x) if x != "" else "" diff --git a/mic/3rdparty/pykickstart/ko.py b/mic/3rdparty/pykickstart/ko.py index 1350d19..7cef824 100644 --- a/mic/3rdparty/pykickstart/ko.py +++ b/mic/3rdparty/pykickstart/ko.py @@ -15,7 +15,7 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # """ Base classes for internal pykickstart use. @@ -31,7 +31,6 @@ class KickstartObject(object): """Create a new KickstartObject instance. All other classes in pykickstart should be derived from this one. Instance attributes: """ - pass def __str__(self): return "" diff --git a/mic/3rdparty/pykickstart/load.py b/mic/3rdparty/pykickstart/load.py new file mode 100644 index 0000000..eb76b65 --- /dev/null +++ b/mic/3rdparty/pykickstart/load.py @@ -0,0 +1,104 @@ +# +# Tomas Radej <tradej@redhat.com> +# +# Copyright 2015 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, modify, +# copy, or redistribute it subject to the terms and conditions of the GNU +# General Public License v.2. This program is distributed in the hope that it +# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the +# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat +# trademarks that are incorporated in the source code or documentation are not +# subject to the GNU General Public License and may only be used or replicated +# with the express permission of Red Hat, Inc. +# +import requests +import shutil + +from pykickstart.errors import KickstartError +from pykickstart.i18n import _ +from requests.exceptions import SSLError, RequestException + +is_url = lambda location: '://' in location # RFC 3986 + +SSL_VERIFY = True + +def load_to_str(location): + '''Load a destination URL or file into a string. + Type of input is inferred automatically. + + Arguments: + location -- URL or file name to load + + Returns: string with contents + Raises: KickstartError on error reading''' + + if is_url(location): + return _load_url(location) + else: + return _load_file(location) + +def load_to_file(location, destination): + '''Load a destination URL or file into a file name. + Type of input is inferred automatically. + + Arguments: + location -- URL or file name to load + destination -- destination file name to write to + + Returns: file name with contents + Raises: KickstartError on error reading or writing''' + + if is_url(location): + contents = _load_url(location) + + # Write to file + try: + with open(destination, 'w') as fh: + fh.write(contents) + except IOError as e: + raise KickstartError(_('Error writing file "%s":') % location + ': {e}'.format(e=str(e))) + + return destination + else: + _copy_file(location, destination) + return destination + +def _load_url(location): + '''Load a location (URL or filename) and return contents as string''' + + try: + request = requests.get(location, verify=SSL_VERIFY) + except SSLError as e: + raise KickstartError(_('Error securely accessing URL "%s"') % location + ': {e}'.format(e=str(e))) + except RequestException as e: + raise KickstartError(_('Error accessing URL "%s"') % location + ': {e}'.format(e=str(e))) + + if request.status_code != requests.codes.ok: # pylint: disable=no-member + raise KickstartError(_('Error accessing URL "%s"') % location + ': {c}'.format(c=str(request.status_code))) + + return request.text + +def _load_file(filename): + '''Load a file's contents and return them as a string''' + + try: + with open(filename, 'rb') as fh: + contents = fh.read().decode("utf-8") + except IOError as e: + raise KickstartError(_('Error opening file: %s') % str(e)) + + return contents + +def _copy_file(filename, destination): + '''Copy file to destination''' + + try: + shutil.copyfile(filename, destination) + except (OSError, IOError) as e: + raise KickstartError(_('Error copying file: %s') % str(e)) diff --git a/mic/3rdparty/pykickstart/options.py b/mic/3rdparty/pykickstart/options.py index d07fcf6..f3bcbef 100755..100644 --- a/mic/3rdparty/pykickstart/options.py +++ b/mic/3rdparty/pykickstart/options.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005, 2006, 2007 Red Hat, Inc. +# Copyright 2005-2016 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,190 +15,268 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # """ Specialized option handling. -This module exports two classes: +This module exports three classes: - KSOptionParser - A specialized subclass of OptionParser to be used + ExtendAction - A subclass of Action that appends a list of values to an + already existing list. In this way, it's like the existing + "append" action except for lists instead of single values. + + ExtendConstAction - A subclass of Action that appends a list of constants + to an already existing list. In this way, it's like the + existing "append_const" action except for lists instead + of single values. + + KSOptionParser - A specialized subclass of ArgumentParser to be used in BaseHandler subclasses. - KSOption - A specialized subclass of Option. +And it exports two functions: + + commaSplit - A function to be used as the type= argument to any arguments + that take a single string that may be split on commas, resulting + in a list of strings. + + ksboolean - A function to be used as the type= argument to any arguments + that can take a boolean. """ +import os import warnings -from copy import copy -from optparse import * +import textwrap +from argparse import RawTextHelpFormatter, SUPPRESS +from argparse import Action, ArgumentParser, ArgumentTypeError -from constants import * -from errors import * -from version import * +from pykickstart.errors import KickstartParseError, KickstartDeprecationWarning +from pykickstart.version import versionToLongString -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ -class KSOptionParser(OptionParser): - """A specialized subclass of optparse.OptionParser to handle extra option - attribute checking, work error reporting into the KickstartParseError - framework, and to turn off the default help. - """ - def exit(self, status=0, msg=None): - pass +def commaSplit(value): + return list([_f for _f in [v.strip() for v in value.split(',')] if _f]) - def error(self, msg): - if self.lineno != None: - raise KickstartParseError ( formatErrorMsg(self.lineno, msg=msg)) +def ksboolean(value): + try: + if value.lower() in ("on", "yes", "true", "1"): + return True + elif value.lower() in ("off", "no", "false", "0"): + return False else: - raise KickstartParseError ( msg) + raise ArgumentTypeError(_("invalid boolean value: %r") % value) + except AttributeError: + raise ArgumentTypeError(_("invalid boolean value: %r") % value) - def keys(self): - retval = [] +def mountpoint(value): + if value.startswith("/"): + return os.path.normpath(value) - for opt in self.option_list: - if opt not in retval: - retval.append(opt.dest) + return value - return retval +class KSHelpFormatter(RawTextHelpFormatter): + """ + Used in generating documentation + """ - def _init_parsing_state (self): - OptionParser._init_parsing_state(self) - self.option_seen = {} + def _format_usage(self, usage, actions, groups, prefix): + return "::\n\n %s" % super(KSHelpFormatter, + self)._format_usage(usage, + actions, + groups, + "").strip() + + def _format_action(self, action): + text = super(KSHelpFormatter, self)._format_action(action) + parts = text.strip().split('\n') + new_parts = [] + new_parts.append("\n``%s``\n" % parts[0].strip()) + for p in parts[1:]: + if p: + new_parts.append(" %s" % p.lstrip()) + return self._join_parts(new_parts) + + def _join_parts(self, part_strings): + return '\n'.join([part.rstrip(' ') + for part in part_strings + if part and part is not SUPPRESS]) + + +class ExtendAction(Action): + def __call__(self, parser, namespace, values, option_string=None): + if getattr(namespace, self.dest, None) is not None: + setattr(namespace, self.dest, getattr(namespace, self.dest) + values) + else: + setattr(namespace, self.dest, values) - def check_values (self, values, args): - def seen(self, option): - return self.option_seen.has_key(option) +class ExtendConstAction(Action): + def __call__(self, parser, namespace, values, option_string=None): + if getattr(namespace, self.dest, None) is not None: + setattr(namespace, self.dest, self.const + values) + else: + setattr(namespace, self.dest, self.const) - def usedTooNew(self, option): - return option.introduced and option.introduced > self.version +class KSOptionParser(ArgumentParser): + """A specialized subclass of argparse.ArgumentParser to handle extra option + attribute checking, work error reporting into the KickstartParseError + framework, and to turn off the default help. + """ + def __init__(self, *args, **kwargs): + """Create a new KSOptionParser instance. Each KickstartCommand + subclass should create one instance of KSOptionParser, providing + at least the lineno attribute. version is not required. - def usedDeprecated(self, option): - return option.deprecated + Instance attributes: - def usedRemoved(self, option): - return option.removed and option.removed <= self.version + version -- The version when the kickstart command was introduced. - for option in filter(lambda o: isinstance(o, Option), self.option_list): - if option.required and not seen(self, option): - raise KickstartValueError (formatErrorMsg(self.lineno, _("Option %s is required") % option)) - elif seen(self, option) and usedTooNew(self, option): - mapping = {"option": option, "intro": versionToString(option.introduced), - "version": versionToString(self.version)} - self.error(_("The %(option)s option was introduced in version %(intro)s, but you are using kickstart syntax version %(version)s.") % mapping) - elif seen(self, option) and usedRemoved(self, option): - mapping = {"option": option, "removed": versionToString(option.removed), - "version": versionToString(self.version)} + """ + # Overridden to allow for the version kwargs, to skip help option generation, + # and to resolve conflicts instead of override earlier options. + int_version = kwargs.pop("version") # fail fast if no version is specified + version = versionToLongString(int_version) + + # always document the version + if "addVersion" in kwargs: + warnings.warn("The option 'addVersion' will be removed in a future release.", + PendingDeprecationWarning) + + addVersion = kwargs.pop('addVersion', True) + + # remove leading spaced from description and epilog. + # fail fast if we forgot to add description + kwargs['description'] = textwrap.dedent(kwargs.pop("description")) + if addVersion: + kwargs['description'] = "\n.. versionadded:: %s\n\n%s" % (version, + kwargs['description']) + kwargs['epilog'] = textwrap.dedent(kwargs.pop("epilog", "")) + + # fail fast if we forgot to add prog + kwargs['prog'] = kwargs.pop("prog") + + # remove leading spaced from description and epilog. + # fail fast if we forgot to add description + kwargs['description'] = textwrap.dedent(kwargs.pop("description")) + kwargs['epilog'] = textwrap.dedent(kwargs.pop("epilog", "")) + + # fail fast if we forgot to add prog + kwargs['prog'] = kwargs.pop("prog") + + ArgumentParser.__init__(self, add_help=False, conflict_handler="resolve", + formatter_class=KSHelpFormatter, *args, **kwargs) + # NOTE: On Python 2.7 ArgumentParser has a deprecated version parameter + # which always defaults to self.version = None which breaks deprecation + # warnings in pykickstart. That's why we always set this value after + # ArgumentParser.__init__ has been executed + self.version = int_version + self.lineno = None - if option.removed == self.version: - self.error(_("The %(option)s option is no longer supported.") % mapping) - else: - self.error(_("The %(option)s option was removed in version %(removed)s, but you are using kickstart syntax version %(version)s.") % mapping) - elif seen(self, option) and usedDeprecated(self, option): - mapping = {"lineno": self.lineno, "option": option} - 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) + def _parse_optional(self, arg_string): + option_tuple = ArgumentParser._parse_optional(self, arg_string) + if option_tuple is None or option_tuple[0] is None: + return option_tuple - return (values, args) + action = option_tuple[0] + option = action.option_strings[0] - def parse_args(self, *args, **kwargs): - if kwargs.has_key("lineno"): - self.lineno = kwargs.pop("lineno") + if action.deprecated: + 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.") + % {"lineno": self.lineno, "option": option}, KickstartDeprecationWarning) - return OptionParser.parse_args(self, **kwargs) + return option_tuple - def __init__(self, mapping=None, version=None): - """Create a new KSOptionParser instance. Each KickstartCommand - subclass should create one instance of KSOptionParser, providing - at least the lineno attribute. mapping and version are not required. - Instance attributes: + def add_argument(self, *args, **kwargs): + if "introduced" in kwargs: + warnings.warn("The option 'introduced' will be removed in a future release. " + "Use 'version' instead.", PendingDeprecationWarning) - mapping -- A mapping from option strings to different values. - version -- The version of the kickstart syntax we are checking - against. - """ - OptionParser.__init__(self, option_class=KSOption, - add_help_option=False, - conflict_handler="resolve") - if mapping is None: - self.map = {} - else: - self.map = mapping + if "removed" in kwargs: + warnings.warn("The option 'removed' will be removed in a future release. " + "Use 'remove_argument' instead.", PendingDeprecationWarning) - self.lineno = None - self.option_seen = {} - self.version = version - -def _check_ksboolean(option, opt, value): - if value.lower() in ("on", "yes", "true", "1"): - return True - elif value.lower() in ("off", "no", "false", "0"): - return False - else: - mapping = {"opt": opt, "value": value} - raise OptionValueError(_("Option %(opt)s: invalid boolean value: %(value)r") % mapping) - -def _check_string(option, opt, value): - #if len(value) > 2 and value.startswith("--"): - #mapping = {"opt": opt, "value": value} - #raise OptionValueError(_("Option %(opt)s: invalid string value: %(value)r") % mapping) - # else: - return value + introduced = kwargs.pop("introduced", None) + deprecated = kwargs.pop("deprecated", False) -# Creates a new Option class that supports several new attributes: -# - required: any option with this attribute must be supplied or an exception -# is thrown -# - introduced: the kickstart syntax version that this option first appeared -# in - an exception will be raised if the option is used and -# the specified syntax version is less than the value of this -# attribute -# - deprecated: the kickstart syntax version that this option was deprecated -# in - a DeprecationWarning will be thrown if the option is -# used and the specified syntax version is greater than the -# value of this attribute -# - removed: the kickstart syntax version that this option was removed in - an -# exception will be raised if the option is used and the specified -# syntax version is greated than the value of this attribute -# Also creates a new type: -# - ksboolean: support various kinds of boolean values on an option -# And two new actions: -# - map : allows you to define an opt -> val mapping such that dest gets val -# when opt is seen -# - map_extend: allows you to define an opt -> [val1, ... valn] mapping such -# that dest gets a list of vals built up when opt is seen -class KSOption (Option): - ATTRS = Option.ATTRS + ['introduced', 'deprecated', 'removed', 'required'] - ACTIONS = Option.ACTIONS + ("map", "map_extend",) - STORE_ACTIONS = Option.STORE_ACTIONS + ("map", "map_extend",) - - TYPES = Option.TYPES + ("ksboolean", "string") - TYPE_CHECKER = copy(Option.TYPE_CHECKER) - TYPE_CHECKER["ksboolean"] = _check_ksboolean - TYPE_CHECKER["string"] = _check_string - - def _check_required(self): - if self.required and not self.takes_value(): - raise OptionError(_("Required flag set for option that doesn't take a value"), self) - - # Make sure _check_required() is called from the constructor! - CHECK_METHODS = Option.CHECK_METHODS + [_check_required] - - def process (self, opt, value, values, parser): - Option.process(self, opt, value, values, parser) - parser.option_seen[self] = 1 - - # Override default take_action method to handle our custom actions. - def take_action(self, action, dest, opt, value, values, parser): - if action == "map": - values.ensure_value(dest, parser.map[opt.lstrip('-')]) - elif action == "map_extend": - values.ensure_value(dest, []).extend(parser.map[opt.lstrip('-')]) + if deprecated: + version = versionToLongString(deprecated) else: - Option.take_action(self, action, dest, opt, value, values, parser) + # fail fast if version is missing + version = versionToLongString(introduced or kwargs.pop("version")) + + candidate = None + for action in self._actions: + for arg in args: + if arg in action.option_strings: + candidate = action + break + + if candidate: + if deprecated: + _help = candidate.help or "" + _help += "\n\n .. deprecated:: %s" % version + kwargs["help"] = _help + else: + # this is a modified argument, which is already present + _help = candidate.help or "" + _help += "\n\n .. versionchanged:: %s\n\n%s" % (version, kwargs.pop("help")) + kwargs["help"] = _help + else: + # this is a new argument which is added for the first time + _help = kwargs.pop("help") + _help += "\n\n .. versionadded:: %s" % version + # there are some argumets which are deprecated on first declaration + if deprecated: + _help += "\n\n .. deprecated:: %s" % version + kwargs["help"] = _help + + notest = kwargs.pop("notest", False) + removed = kwargs.pop("removed", None) + + action = ArgumentParser.add_argument(self, *args, **kwargs) + action.deprecated = deprecated + action.introduced = introduced + action.notest = notest + action.removed = removed + return action + + def remove_argument(self, arg, **kwargs): + candidate = None + + for action in self._actions: + if arg in action.option_strings: + candidate = action + break + + if candidate: + if not candidate.help: + candidate.help = "" + candidate.help += "\n\n .. versionremoved:: %s" % versionToLongString(kwargs.pop("version")) + self._remove_action(candidate) + self._option_string_actions.pop(arg) + + def error(self, message): + # Overridden to turn errors into KickstartParseErrors. + if self.lineno is not None: + raise KickstartParseError(message, lineno=self.lineno) + else: + raise KickstartParseError(message) - def takes_value(self): - # Deprecated options don't take a value. - return Option.takes_value(self) and not self.deprecated + def exit(self, status=0, message=None): + # Overridden because this is a library, and libraries shouldn't just + # exit. That's what raising exceptions is for. + pass - def __init__(self, *args, **kwargs): - self.deprecated = False - self.required = False - Option.__init__(self, *args, **kwargs) + def parse_args(self, *args, **kwargs): # pylint: disable=arguments-differ,signature-differs + if "lineno" in kwargs: + self.lineno = kwargs.pop("lineno") + + return ArgumentParser.parse_args(self, *args, **kwargs) + + def parse_known_args(self, *args, **kwargs): # pylint: disable=arguments-differ,signature-differs + if "lineno" in kwargs: + self.lineno = kwargs.pop("lineno") + + return ArgumentParser.parse_known_args(self, *args, **kwargs) diff --git a/mic/3rdparty/pykickstart/parser.py b/mic/3rdparty/pykickstart/parser.py index a485dfe..142fc81 100644 --- a/mic/3rdparty/pykickstart/parser.py +++ b/mic/3rdparty/pykickstart/parser.py @@ -3,7 +3,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2005, 2006, 2007, 2008, 2011 Red Hat, Inc. +# Copyright 2005-2016 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -17,54 +17,50 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # """ Main kickstart file processing module. This module exports several important classes: - Script - Representation of a single %pre, %post, or %traceback script. + Script - Representation of a single %pre, %pre-install, %post, or %traceback script. Packages - Representation of the %packages section. KickstartParser - The kickstart file parser state machine. """ -from collections import Iterator +from collections.abc import Iterator + import os import shlex import sys -import tempfile -from copy import copy -from optparse import * -from urlgrabber import urlread -import urlgrabber.grabber as grabber +import warnings -import constants -from errors import KickstartError, KickstartParseError, KickstartValueError, formatErrorMsg -from ko import KickstartObject -from sections import * -import version +from pykickstart import constants, version +from pykickstart.errors import KickstartError, KickstartParseError, KickstartParseWarning +from pykickstart.ko import KickstartObject +from pykickstart.load import load_to_str +from pykickstart.options import KSOptionParser +from pykickstart.sections import PackageSection, PreScriptSection, PreInstallScriptSection, \ + PostScriptSection, TracebackScriptSection, OnErrorScriptSection, \ + NullSection, RunScriptSection, PostUmountScriptSection, TpkPackageSection -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ STATE_END = "end" STATE_COMMANDS = "commands" -ver = version.DEVEL - -def _preprocessStateMachine (lineIter): +def _preprocessStateMachine(lineIter): l = None lineno = 0 + retval = "" - # Now open an output kickstart file that we are going to write to one - # line at a time. - (outF, outName) = tempfile.mkstemp("-ks.cfg", "", "/tmp") + retval = retval.encode(sys.getdefaultencoding()) while True: try: - l = lineIter.next() + l = next(lineIter) except StopIteration: break @@ -73,68 +69,87 @@ def _preprocessStateMachine (lineIter): break lineno += 1 - url = None + ksurl = None ll = l.strip() if not ll.startswith("%ksappend"): - os.write(outF, l) + retval += l.encode(sys.getdefaultencoding()) continue # Try to pull down the remote file. try: ksurl = ll.split(' ')[1] except: - raise KickstartParseError (formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll)) + raise KickstartParseError(_("Illegal url for %%ksappend: %s") % ll, lineno=lineno) try: - url = grabber.urlopen(ksurl) - except grabber.URLGrabError as e: - raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror)) - else: - # Sanity check result. Sometimes FTP doesn't catch a file - # is missing. - try: - if url.size < 1: - raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))) - except: - raise KickstartError (formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))) + contents = load_to_str(ksurl) + except KickstartError as e: + raise KickstartError(_("Unable to open %%ksappend file: %s") % str(e), lineno=lineno) # If that worked, write the remote file to the output kickstart - # file in one burst. Then close everything up to get ready to - # read ahead in the input file. This allows multiple %ksappend - # lines to exist. - if url is not None: - os.write(outF, url.read()) - url.close() - - # All done - close the temp file and return its location. - os.close(outF) - return outName - -def preprocessFromString (s): - """Preprocess the kickstart file, provided as the string str. This - method is currently only useful for handling %ksappend lines, - which need to be fetched before the real kickstart parser can be - run. Returns the location of the complete kickstart file. + # file in one burst. This allows multiple %ksappend lines to + # exist. + if contents is not None: + retval += contents.encode(sys.getdefaultencoding()) + + return retval + +def preprocessFromStringToString(s): + """Preprocess the kickstart file, provided as the string s. This + method is currently only useful for handling %ksappend lines, which + need to be fetched before the real kickstart parser can be run. + Returns the complete kickstart file as a string. """ i = iter(s.splitlines(True) + [""]) - rc = _preprocessStateMachine (i.next) - return rc - -def preprocessKickstart (f): - """Preprocess the kickstart file, given by the filename file. This - method is currently only useful for handling %ksappend lines, - which need to be fetched before the real kickstart parser can be - run. Returns the location of the complete kickstart file. + return _preprocessStateMachine(i) + +def preprocessKickstartToString(f): + """Preprocess the kickstart file, given by the filename f. This + method is currently only useful for handling %ksappend lines, + which need to be fetched before the real kickstart parser can be + run. Returns the complete kickstart file as a string. """ try: - fh = urlopen(f) - except grabber.URLGrabError as e: - raise KickstartError (formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)) + contents = load_to_str(f) + except KickstartError as e: + raise KickstartError(_("Unable to open input kickstart file: %s") % str(e), lineno=0) + + return _preprocessStateMachine(iter(contents.splitlines(True))) + +def preprocessFromString(s): + """Preprocess the kickstart file, provided as the string s. This + method is currently only useful for handling %ksappend lines, + which need to be fetched before the real kickstart parser can be + run. Returns the location of the complete kickstart file. + """ + s = preprocessFromStringToString(s) + if s.strip(): + import tempfile + (outF, outName) = tempfile.mkstemp(suffix="-ks.cfg") + + os.write(outF, s) + os.close(outF) + return outName + + return None + +def preprocessKickstart(f): + """Preprocess the kickstart file, given by the filename f. This + method is currently only useful for handling %ksappend lines, + which need to be fetched before the real kickstart parser can be + run. Returns the location of the complete kickstart file. + """ + s = preprocessKickstartToString(f) + if s.strip(): + import tempfile + (outF, outName) = tempfile.mkstemp(suffix="-ks.cfg") - rc = _preprocessStateMachine (iter(fh.readlines())) - fh.close() - return rc + os.write(outF, s) + os.close(outF) + return outName + + return None class PutBackIterator(Iterator): def __init__(self, iterable): @@ -153,33 +168,44 @@ class PutBackIterator(Iterator): self._buf = None return retval else: - return self._iterable.next() + return next(self._iterable) + + def __next__(self): + return self.next() # pylint: disable=not-callable ### ### SCRIPT HANDLING ### class Script(KickstartObject): + _ver = version.DEVEL + """A class representing a single kickstart script. If functionality beyond just a data representation is needed (for example, a run method in anaconda), Script may be subclassed. Although a run method is not provided, most of the attributes of Script have to do with running the script. Instances of Script are held in a list by the Version object. """ - def __init__(self, script, *args , **kwargs): + def __init__(self, script, *args, **kwargs): """Create a new Script instance. Instance attributes: - errorOnFail -- If execution of the script fails, should anaconda - stop, display an error, and then reboot without - running any other scripts? - inChroot -- Does the script execute in anaconda's chroot - environment or not? - interp -- The program that should be used to interpret this - script. - lineno -- The line number this script starts on. - logfile -- Where all messages from the script should be logged. - script -- A string containing all the lines of the script. - type -- The type of the script, which can be KS_SCRIPT_* from - pykickstart.constants. + :keyword errorOnFail: If execution of the script fails, should anaconda + stop, display an error, and then reboot without + running any other scripts? + + :keyword inChroot: Does the script execute in anaconda's chroot + environment or not? + + :keyword interp: The program that should be used to interpret this + script. + + :keyword lineno: The line number this script starts on. + + :keyword logfile: Where all messages from the script should be logged. + + :keyword script: A string containing all the lines of the script. + + :keyword type: The type of the script, which can be KS_SCRIPT_* from + :mod:`pykickstart.constants`. """ KickstartObject.__init__(self, *args, **kwargs) self.script = "".join(script) @@ -201,36 +227,39 @@ class Script(KickstartObject): retval += '\n%post' elif self.type == constants.KS_SCRIPT_TRACEBACK: retval += '\n%traceback' + elif self.type == constants.KS_SCRIPT_PREINSTALL: + retval += '\n%pre-install' + elif self.type == constants.KS_SCRIPT_ONERROR: + retval += '\n%onerror' elif self.type == constants.KS_SCRIPT_RUN: retval += '\n%runscript' elif self.type == constants.KS_SCRIPT_UMOUNT: retval += '\n%post-umount' - if self.interp != "/bin/sh" and self.interp != "": + if self.interp != "/bin/sh" and self.interp: retval += " --interpreter=%s" % self.interp if self.type == constants.KS_SCRIPT_POST and not self.inChroot: retval += " --nochroot" - if self.logfile != None: - retval += " --logfile %s" % self.logfile + if self.logfile is not None: + retval += " --logfile=%s" % self.logfile if self.errorOnFail: retval += " --erroronfail" if self.script.endswith("\n"): - if ver >= version.F8: + if self._ver >= version.F8: return retval + "\n%s%%end\n" % self.script else: - return retval + "\n%s\n" % self.script + return retval + "\n%s" % self.script else: - if ver >= version.F8: + if self._ver >= version.F8: return retval + "\n%s\n%%end\n" % self.script else: return retval + "\n%s\n" % self.script - ## ## PACKAGE HANDLING ## -class Group: +class Group(KickstartObject): """A class representing a single group in the %packages section.""" def __init__(self, name="", include=constants.GROUP_DEFAULT): """Create a new Group instance. Instance attributes: @@ -239,6 +268,7 @@ class Group: include -- The level of how much of the group should be included. Values can be GROUP_* from pykickstart.constants. """ + KickstartObject.__init__(self) self.name = name self.include = include @@ -251,21 +281,41 @@ class Group: else: return "@%s" % self.name - def __cmp__(self, other): - if self.name < other.name: - return -1 - elif self.name > other.name: - return 1 - return 0 + def __lt__(self, other): + return self.name < other.name + + def __le__(self, other): + return self.name <= other.name + + def __eq__(self, other): + return self.name == other.name + + def __ne__(self, other): + return self.name != other.name + + def __gt__(self, other): + return self.name > other.name + + def __ge__(self, other): + return self.name >= other.name + + __hash__ = KickstartObject.__hash__ class Packages(KickstartObject): + _ver = version.DEVEL + """A class representing the %packages section of the kickstart file.""" def __init__(self, *args, **kwargs): """Create a new Packages instance. Instance attributes: addBase -- Should the Base group be installed even if it is not specified? + nocore -- Should the Core group be skipped? This results in + a %packages section that basically only installs the + packages you list, and may not be a usable system. default -- Should the default package set be selected? + environment -- What base environment should be selected? Only one + may be chosen at a time. excludedList -- A list of all the packages marked for exclusion in the %packages section, without the leading minus symbol. @@ -280,52 +330,47 @@ class Packages(KickstartObject): handleMissing -- If unknown packages are specified in the %packages section, should it be ignored or not? Values can be KS_MISSING_* from pykickstart.constants. + handleBroken -- If packages with conflicts are specified in the + %packages section, should it be ignored or not? + Values can be KS_BROKEN_* from pykickstart.constants. packageList -- A list of all the packages specified in the %packages section. instLangs -- A list of languages to install. + multiLib -- Whether to use yum's "all" multilib policy. + excludeWeakdeps -- Whether to exclude weak dependencies. + timeout -- Number of seconds to wait for a connection before + yum's or dnf's timing out or None. + retries -- Number of times yum's or dnf's attempt to retrieve + a file should retry before returning an error. + seen -- If %packages was ever used in the kickstart file, + this attribute will be set to True. + """ KickstartObject.__init__(self, *args, **kwargs) self.addBase = True + self.nocore = False self.default = False + self.environment = None self.excludedList = [] self.excludedGroupList = [] self.excludeDocs = False self.groupList = [] self.handleMissing = constants.KS_MISSING_PROMPT + self.handleBroken = constants.KS_BROKEN_REPORT self.packageList = [] self.tpk_packageList = [] self.instLangs = None + self.multiLib = False + self.excludeWeakdeps = False + self.timeout = None + self.retries = None + self.seen = False def __str__(self): """Return a string formatted for output to a kickstart file.""" - pkgs = "" - - if not self.default: - grps = self.groupList - grps.sort() - for grp in grps: - pkgs += "%s\n" % grp.__str__() - - p = self.packageList - p.sort() - for pkg in p: - pkgs += "%s\n" % pkg - - grps = self.excludedGroupList - grps.sort() - for grp in grps: - pkgs += "-%s\n" % grp.__str__() - - p = self.excludedList - p.sort() - for pkg in p: - pkgs += "-%s\n" % pkg - - if pkgs == "": - return "" - - retval = "\n%packages" + pkgs = self._processPackagesContent() + retval = "" if self.default: retval += " --default" @@ -333,38 +378,87 @@ class Packages(KickstartObject): retval += " --excludedocs" if not self.addBase: retval += " --nobase" + if self.nocore: + retval += " --nocore" if self.handleMissing == constants.KS_MISSING_IGNORE: retval += " --ignoremissing" - if self.instLangs: - retval += " --instLangs=%s" % self.instLangs - - if ver >= version.F8: - return retval + "\n" + pkgs + "\n%end\n" + if self.handleBroken == constants.KS_BROKEN_IGNORE: + retval += " --ignorebroken" + if self.instLangs is not None: + retval += " --inst-langs=%s" % self.instLangs + if self.multiLib: + retval += " --multilib" + if self.excludeWeakdeps: + retval += " --exclude-weakdeps" + if self.timeout is not None: + retval += " --timeout=%d" % self.timeout + if self.retries is not None: + retval += " --retries=%d" % self.retries + + if retval == "" and pkgs == "" and not self.seen: + return "" + + if self._ver >= version.F8: + return "\n%packages" + retval + "\n" + pkgs + "\n%end\n" else: - return retval + "\n" + pkgs + "\n" + return "\n%packages" + retval + "\n" + pkgs + "\n" + + def _processPackagesContent(self): + pkgs = "" + + if not self.default: + if self.environment: + pkgs += "@^%s\n" % self.environment + + grps = self.groupList + grps.sort() + for grp in grps: + pkgs += "%s\n" % grp.__str__() + + p = self.packageList + p.sort() + for pkg in p: + pkgs += "%s\n" % pkg + + grps = self.excludedGroupList + grps.sort() + for grp in grps: + pkgs += "-%s\n" % grp.__str__() - def _processGroup (self, line): - op = OptionParser() - op.add_option("--nodefaults", action="store_true", default=False) - op.add_option("--optional", action="store_true", default=False) + p = self.excludedList + p.sort() + for pkg in p: + pkgs += "-%s\n" % pkg - (opts, extra) = op.parse_args(args=line.split()) + return pkgs - if opts.nodefaults and opts.optional: - raise KickstartValueError (_("Group cannot specify both --nodefaults and --optional")) + def _processGroup(self, line): + op = KSOptionParser(prog="", description="", version=version.DEVEL) + op.add_argument("--nodefaults", action="store_true", default=False, + help="", version=version.DEVEL) + op.add_argument("--optional", action="store_true", default=False, + help="", version=version.DEVEL) + + (ns, extra) = op.parse_known_args(args=line.split()) + + if ns.nodefaults and ns.optional: + raise KickstartParseError(_("Group cannot specify both --nodefaults and --optional")) # If the group name has spaces in it, we have to put it back together # now. grp = " ".join(extra) - if opts.nodefaults: + if grp in [g.name for g in self.groupList]: + return + + if ns.nodefaults: self.groupList.append(Group(name=grp, include=constants.GROUP_REQUIRED)) - elif opts.optional: + elif ns.optional: self.groupList.append(Group(name=grp, include=constants.GROUP_ALL)) else: self.groupList.append(Group(name=grp, include=constants.GROUP_DEFAULT)) - def add (self, pkgList): + def add(self, pkgList): """Given a list of lines from the input file, strip off any leading symbols and add the result to the appropriate list. """ @@ -378,10 +472,14 @@ class Packages(KickstartObject): for pkg in pkgList: stripped = pkg.strip() - if stripped[0] == "@": + if stripped[0:2] == "@^": + self.environment = stripped[2:] + elif stripped[0] == "@": self._processGroup(stripped[1:]) elif stripped[0] == "-": - if stripped[1] == "@": + if stripped[1:3] == "@^" and self.environment == stripped[3:]: + self.environment = None + elif stripped[1] == "@": excludedGroupList.append(Group(name=stripped[2:])) else: newExcludedSet.add(stripped[1:]) @@ -390,12 +488,12 @@ class Packages(KickstartObject): # Groups have to be excluded in two different ways (note: can't use # sets here because we have to store objects): - excludedGroupNames = map(lambda g: g.name, excludedGroupList) + excludedGroupNames = [g.name for g in excludedGroupList] # First, an excluded group may be cancelling out a previously given # one. This is often the case when using %include. So there we should # just remove the group from the list. - self.groupList = filter(lambda g: g.name not in excludedGroupNames, self.groupList) + self.groupList = [g for g in self.groupList if g.name not in excludedGroupNames] # Second, the package list could have included globs which are not # processed by pykickstart. In that case we need to preserve a list of @@ -406,8 +504,9 @@ class Packages(KickstartObject): existingPackageSet = (existingPackageSet - newExcludedSet) | newPackageSet existingExcludedSet = (existingExcludedSet - existingPackageSet) | newExcludedSet - self.packageList = list(existingPackageSet) - self.excludedList = list(existingExcludedSet) + # FIXME: figure these types out + self.packageList = sorted(existingPackageSet) + self.excludedList = sorted(existingExcludedSet) class TpkPackages(KickstartObject): """A class representing the %tpk_packages section of the kickstart file.""" @@ -431,15 +530,15 @@ class TpkPackages(KickstartObject): ### ### PARSER ### -class KickstartParser: +class KickstartParser(object): """The kickstart file parser class as represented by a basic state machine. To create a specialized parser, make a subclass and override any of the methods you care about. Methods that don't need to do anything may just pass. However, _stateMachine should never be overridden. """ - def __init__ (self, handler, followIncludes=True, errorsAreFatal=True, - missingIncludeIsFatal=True): + def __init__(self, handler, followIncludes=True, errorsAreFatal=True, + missingIncludeIsFatal=True, unknownSectionIsFatal=True): """Create a new KickstartParser instance. Instance attributes: errorsAreFatal -- Should errors cause processing to halt, or @@ -455,21 +554,26 @@ class KickstartParser: will be executed. missingIncludeIsFatal -- Should missing include files be fatal, even if errorsAreFatal is False? + unknownSectionIsFatal -- Should an unknown %section be fatal? Not all + sections are handled by pykickstart. Some are + user-defined, so there should be a way to have + pykickstart ignore them. """ self.errorsAreFatal = errorsAreFatal + self.errorsCount = 0 self.followIncludes = followIncludes self.handler = handler self.currentdir = {} self.missingIncludeIsFatal = missingIncludeIsFatal + self.unknownSectionIsFatal = unknownSectionIsFatal self._state = STATE_COMMANDS self._includeDepth = 0 self._line = "" self.version = self.handler.version - - global ver - ver = self.version + Script._ver = self.version + Packages._ver = self.version self._sections = {} self.setupSections() @@ -485,17 +589,15 @@ class KickstartParser: """ return self._sections[s] - def handleCommand (self, lineno, args): + def handleCommand(self, lineno, args): """Given the list of command and arguments, call the Version's dispatcher method to handle the command. Returns the command or data object returned by the dispatcher. This method may be overridden in a subclass if necessary. """ if self.handler: - self.handler.currentCmd = args[0] self.handler.currentLine = self._line retval = self.handler.dispatcher(args, lineno) - return retval def registerSection(self, obj): @@ -505,10 +607,10 @@ class KickstartParser: handle it. """ if not obj.sectionOpen: - raise TypeError ("no sectionOpen given for section %s" % obj) + raise TypeError("no sectionOpen given for section %s" % obj) if not obj.sectionOpen.startswith("%"): - raise TypeError ("section %s tag does not start with a %%" % obj.sectionOpen) + raise TypeError("section %s tag does not start with a %%" % obj.sectionOpen) self._sections[obj.sectionOpen] = obj @@ -527,18 +629,18 @@ class KickstartParser: # Save the platform for s-c-kickstart. if line[:10] == "#platform=": - self.handler.platform = self._line[11:] + self.handler.platform = self._line[10:].strip() def _readSection(self, lineIter, lineno): obj = self._sections[self._state] while True: try: - line = lineIter.next() - if line == "": + line = next(lineIter) + if line == "" and self._includeDepth == 0: # This section ends at the end of the file. if self.version >= version.F8: - raise KickstartParseError (formatErrorMsg(lineno, msg=_("Section does not end with %%end."))) + raise KickstartParseError(_("Section %s does not end with %%end.") % obj.sectionOpen, lineno=lineno) self._finalize(obj) except StopIteration: @@ -551,19 +653,35 @@ class KickstartParser: if self._isBlankOrComment(line) and not obj.allLines: continue - if line.startswith("%"): + if line.lstrip().startswith("%"): + # If we're in a script, the line may begin with "%something" + # that's not the start of any section we recognize, but still + # valid for that script. So, don't do the split below unless + # we're sure. + possibleSectionStart = line.split()[0] + if not self._validState(possibleSectionStart) \ + and possibleSectionStart not in ("%end", "%include"): + obj.handleLine(line) + continue + args = shlex.split(line) if args and args[0] == "%end": # This is a properly terminated section. self._finalize(obj) break + elif args and args[0] == "%include": + if len(args) == 1 or not args[1]: + raise KickstartParseError(lineno=lineno) + + self._handleInclude(args[1]) + continue elif args and args[0] == "%ksappend": continue - elif args and (self._validState(args[0]) or args[0] in ["%include", "%ksappend"]): + elif args and self._validState(args[0]): # This is an unterminated section. if self.version >= version.F8: - raise KickstartParseError (formatErrorMsg(lineno, msg=_("Section does not end with %%end."))) + raise KickstartParseError(_("Section %s does not end with %%end.") % obj.sectionOpen, lineno=lineno) # Finish up. We do not process the header here because # kicking back out to STATE_COMMANDS will ensure that happens. @@ -580,7 +698,7 @@ class KickstartParser: def _validState(self, st): """Is the given section tag one that has been registered with the parser?""" - return st in self._sections.keys() + return st in list(self._sections.keys()) def _tryFunc(self, fn): """Call the provided function (which doesn't take any arguments) and @@ -589,15 +707,34 @@ class KickstartParser: """ try: fn() - except Exception as msg: + except Exception as msg: # pylint: disable=broad-except + self.errorsCount += 1 if self.errorsAreFatal: raise else: - print (msg) + print(msg, file=sys.stderr) def _isBlankOrComment(self, line): return line.isspace() or line == "" or line.lstrip()[0] == '#' + def _handleInclude(self, f): + # This case comes up primarily in ksvalidator. + if not self.followIncludes: + return + + self._includeDepth += 1 + + try: + self.readKickstart(f, reset=False) + except KickstartError: + # Handle the include file being provided over the + # network in a %pre script. This case comes up in the + # early parsing in anaconda. + if self.missingIncludeIsFatal: + raise + + self._includeDepth -= 1 + def _stateMachine(self, lineIter): # For error reporting. lineno = 0 @@ -605,7 +742,7 @@ class KickstartParser: while True: # Get the next line out of the file, quitting if this is the last line. try: - self._line = lineIter.next() + self._line = next(lineIter) if self._line == "": break except StopIteration: @@ -618,32 +755,14 @@ class KickstartParser: self._handleSpecialComments(self._line) continue - # Remove any end-of-line comments. - sanitized = self._line.split("#")[0] - - # Then split the line. - args = shlex.split(sanitized.rstrip()) + # Split the line, discarding comments. + args = shlex.split(self._line, comments=True) if args[0] == "%include": - # This case comes up primarily in ksvalidator. - if not self.followIncludes: - continue - if len(args) == 1 or not args[1]: - raise KickstartParseError (formatErrorMsg(lineno)) - - self._includeDepth += 1 - - try: - self.readKickstart(args[1], reset=False) - except KickstartError: - # Handle the include file being provided over the - # network in a %pre script. This case comes up in the - # early parsing in anaconda. - if self.missingIncludeIsFatal: - raise + raise KickstartParseError(lineno=lineno) - self._includeDepth -= 1 + self._handleInclude(args[1]) continue # Now on to the main event. @@ -656,7 +775,15 @@ class KickstartParser: # here. newSection = args[0] if not self._validState(newSection): - raise KickstartParseError (formatErrorMsg(lineno, msg=_("Unknown kickstart section: %s" % newSection))) + if self.unknownSectionIsFatal: + raise KickstartParseError(_("Unknown kickstart section: %s") % newSection, lineno=lineno) + else: + # If we are ignoring unknown section errors, just create a new + # NullSection for the header we just saw. Then nothing else + # needs to change. You can turn this warning into an error via + # ksvalidator, or the warnings module. + warnings.warn(_("Potentially unknown section seen at line %(lineno)s: %(sectionName)s") % {"lineno": lineno, "sectionName": newSection}, KickstartParseWarning) + self.registerSection(NullSection(self.handler, sectionOpen=newSection)) self._state = newSection obj = self._sections[self._state] @@ -671,8 +798,12 @@ class KickstartParser: self._tryFunc(lambda: self.handleCommand(lineno, args)) elif self._state == STATE_END: break + elif self._includeDepth > 0: + lineIter.put(self._line) + lineno -= 1 + lineno = self._readSection(lineIter, lineno) - def readKickstartFromString (self, s, reset=True): + def readKickstartFromString(self, s, reset=True): """Process a kickstart file, provided as the string str.""" if reset: self._reset() @@ -681,7 +812,7 @@ class KickstartParser: # file reader and we only get StopIteration when we're after the final # line of input. i = PutBackIterator(s.splitlines(True) + [""]) - self._stateMachine (i) + self._stateMachine(i) def readKickstart(self, f, reset=True): """Process a kickstart file, given by the filename f.""" @@ -694,7 +825,7 @@ class KickstartParser: # the reading "smart" by keeping track of what the path is at each # include depth. if not os.path.exists(f): - if self.currentdir.has_key(self._includeDepth - 1): + if self._includeDepth - 1 in self.currentdir: if os.path.exists(os.path.join(self.currentdir[self._includeDepth - 1], f)): f = os.path.join(self.currentdir[self._includeDepth - 1], f) @@ -704,9 +835,9 @@ class KickstartParser: self.currentdir[self._includeDepth] = cd try: - s = urlread(f) - except grabber.URLGrabError as e: - raise KickstartError (formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)) + s = load_to_str(f) + except KickstartError as e: + raise KickstartError(_("Unable to open input kickstart file: %s") % str(e), lineno=0) self.readKickstartFromString(s, reset=False) @@ -719,10 +850,16 @@ class KickstartParser: # Install the sections all kickstart files support. self.registerSection(PreScriptSection(self.handler, dataObj=Script)) + self.registerSection(PreInstallScriptSection(self.handler, dataObj=Script)) self.registerSection(PostScriptSection(self.handler, dataObj=Script)) + self.registerSection(OnErrorScriptSection(self.handler, dataObj=Script)) self.registerSection(TracebackScriptSection(self.handler, dataObj=Script)) self.registerSection(RunScriptSection(self.handler, dataObj=Script)) self.registerSection(PostUmountScriptSection(self.handler, dataObj=Script)) self.registerSection(PackageSection(self.handler)) self.registerSection(TpkPackageSection(self.handler)) + # Whitelist well-known sections that pykickstart does not understand, + # but shouldn't error on. + self.registerSection(NullSection(self.handler, sectionOpen="%addon")) + self.registerSection(NullSection(self.handler, sectionOpen="%anaconda")) diff --git a/mic/3rdparty/pykickstart/sections.py b/mic/3rdparty/pykickstart/sections.py index c360a90..a452a90 100644 --- a/mic/3rdparty/pykickstart/sections.py +++ b/mic/3rdparty/pykickstart/sections.py @@ -3,7 +3,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2011 Red Hat, Inc. +# Copyright 2011-2016 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -17,7 +17,7 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # """ This module exports the classes that define a section of a kickstart file. A @@ -29,10 +29,16 @@ treated just the same as a predefined one by the kickstart parser. All that is necessary is to create a new subclass of Section and call parser.registerSection with an instance of your new class. """ -from constants import * -from errors import * -from options import KSOptionParser -from version import * +import warnings +from pykickstart.constants import KS_SCRIPT_PRE, KS_SCRIPT_POST, KS_SCRIPT_TRACEBACK, \ + KS_SCRIPT_PREINSTALL, KS_SCRIPT_ONERROR, \ + KS_MISSING_IGNORE, KS_MISSING_PROMPT, \ + KS_BROKEN_IGNORE, KS_BROKEN_REPORT, KS_SCRIPT_RUN, KS_SCRIPT_UMOUNT +from pykickstart.errors import KickstartError, KickstartParseError, KickstartDeprecationWarning +from pykickstart.options import KSOptionParser +from pykickstart.version import FC4, F7, F9, F18, F21, F22, F24, F32, F34, RHEL6, RHEL7, RHEL9, \ + isRHEL +from pykickstart.i18n import _ class Section(object): """The base class for defining kickstart sections. You are free to @@ -59,10 +65,10 @@ class Section(object): Valid kwargs: - dataObj -- + dataObj -- A class that should be populated by this Section. It almost + always should be Script, or some subclass of it. """ self.handler = handler - self.version = self.handler.version self.dataObj = kwargs.get("dataObj", None) @@ -71,7 +77,6 @@ class Section(object): """This method is called when the %end tag for a section is seen. It is not required to be provided. """ - pass def handleLine(self, line): """This method is called for every line of a section. Take whatever @@ -82,8 +87,8 @@ class Section(object): line -- The complete line, with any trailing newline. """ - pass + # pylint: disable=unused-argument def handleHeader(self, lineno, args): """This method is called when the opening tag for a section is seen. Not all sections will need this method, though all provided with @@ -95,6 +100,14 @@ class Section(object): opening tag. """ self.timesSeen += 1 + # pylint: enable=unused-argument + + @property + def seen(self): + """This property is given for consistency with KickstartCommand objects + only. It simply returns whether timesSeen is non-zero. + """ + return self.timesSeen > 0 class NullSection(Section): """This defines a section that pykickstart will recognize but do nothing @@ -102,6 +115,8 @@ class NullSection(Section): it will raise an error. Sometimes, you may want to simply ignore those sections instead. This class is useful for that purpose. """ + allLines = True + def __init__(self, *args, **kwargs): """Create a new NullSection instance. You must pass a sectionOpen parameter (including a leading '%') for the section you wish to @@ -109,9 +124,32 @@ class NullSection(Section): """ Section.__init__(self, *args, **kwargs) self.sectionOpen = kwargs.get("sectionOpen") + self._args = [] + self._body = [] + + def handleHeader(self, lineno, args): + self._args = args + + def handleLine(self, line): + self._body.append(line) + + def finalize(self): + body = "\n".join(self._body) + if body: + s = "%s\n%s\n%%end" % (" ".join(self._args), body) + else: + s = "%s\n%%end" % " ".join(self._args) + + self.handler._null_section_strings.append(s) + + self._args = [] + self._body = [] class ScriptSection(Section): allLines = True + _description = "" + _epilog = "" + _title = "" def __init__(self, *args, **kwargs): Section.__init__(self, *args, **kwargs) @@ -119,11 +157,27 @@ class ScriptSection(Section): self._resetScript() def _getParser(self): - op = KSOptionParser(self.version) - op.add_option("--erroronfail", dest="errorOnFail", action="store_true", - default=False) - op.add_option("--interpreter", dest="interpreter", default="/bin/sh") - op.add_option("--log", "--logfile", dest="log") + op = KSOptionParser(prog=self.sectionOpen, + description=self._description, + epilog=self._epilog, + version=FC4) + + op.add_argument("--erroronfail", dest="errorOnFail", action="store_true", + default=False, help=""" + If the error script fails, this option will cause an + error dialog to be displayed and will halt installation. + The error message will direct you to where the cause of + the failure is logged.""", version=FC4) + op.add_argument("--interpreter", dest="interpreter", default="/bin/sh", + version=FC4, metavar="/usr/bin/python", help=""" + Allows you to specify a different scripting language, + such as Python. Replace /usr/bin/python with the + scripting language of your choice. + """) + op.add_argument("--log", "--logfile", dest="log", version=FC4, + help=""" + Log all messages from the script to the given log file. + """) return op def _resetScript(self): @@ -144,10 +198,9 @@ class ScriptSection(Section): "errorOnFail": self._script["errorOnFail"], "type": self._script["type"]} - s = self.dataObj (self._script["body"], **kwargs) - self._resetScript() - - if self.handler: + if self.dataObj is not None: + s = self.dataObj(self._script["body"], **kwargs) + self._resetScript() self.handler.scripts.append(s) def handleHeader(self, lineno, args): @@ -158,29 +211,168 @@ class ScriptSection(Section): Section.handleHeader(self, lineno, args) op = self._getParser() - (opts, extra) = op.parse_args(args=args[1:], lineno=lineno) + ns = op.parse_args(args=args[1:], lineno=lineno) - self._script["interp"] = opts.interpreter + self._script["interp"] = ns.interpreter self._script["lineno"] = lineno - self._script["log"] = opts.log - self._script["errorOnFail"] = opts.errorOnFail - if hasattr(opts, "nochroot"): - self._script["chroot"] = not opts.nochroot + self._script["log"] = ns.log + self._script["errorOnFail"] = ns.errorOnFail + if hasattr(ns, "nochroot"): + self._script["chroot"] = not ns.nochroot class PreScriptSection(ScriptSection): sectionOpen = "%pre" + _title = "Pre-installation script" + _description = """ + You can add commands to run on the system immediately after the ks.cfg + has been parsed and the lang, keyboard, and url options have been + processed. This section must be at the end of the kickstart file (after + the commands) and must start with the %pre command. You can access the + network in the %pre section; however, name service has not been + configured at this point, so only IP addresses will work. + + Preinstallation scripts are required to be closed with %end. + + If your script spawns a daemon process, you must make sure to close + ``stdout`` and ``stderr``. Doing so is standard procedure for creating + daemons. If you do not close these file descriptors, the installation + will appear hung as anaconda waits for an EOF from the script. + + .. note:: + + The pre-installation script is not run in the chroot environment. + """ + _epilog = """ + Example + ------- + + Here is an example %pre section:: + + %pre + #!/bin/bash + hds="" + mymedia="" + + for file in /sys/block/sd*; do + hds="$hds $(basename $file)" + done + + set $hds + numhd=$(echo $#) + + drive1=$(echo $hds | cut -d' ' -f1) + drive2=$(echo $hds | cut -d' ' -f2) + + + if [ $numhd == "2" ] ; then + echo "#partitioning scheme generated in %pre for 2 drives" > /tmp/part-include + echo "clearpart --all" >> /tmp/part-include + echo "part /boot --fstype ext4 --size 512 --ondisk sda" >> /tmp/part-include + echo "part / --fstype ext4 --size 10000 --grow --ondisk sda" >> /tmp/part-include + echo "part swap --recommended --ondisk $drive1" >> /tmp/part-include + echo "part /home --fstype ext4 --size 10000 --grow --ondisk sdb" >> /tmp/part-include + else + echo "#partitioning scheme generated in %pre for 1 drive" > /tmp/part-include + echo "clearpart --all" >> /tmp/part-include + echo "part /boot --fstype ext4 --size 521" >> /tmp/part-include + echo "part swap --recommended" >> /tmp/part-include + echo "part / --fstype ext4 --size 2048" >> /tmp/part-include + echo "part /home --fstype ext4 --size 2048 --grow" >> /tmp/part-include + fi + %end + + This script determines the number of hard drives in the system and + writes a text file with a different partitioning scheme depending on + whether it has one or two drives. Instead of having a set of + partitioning commands in the kickstart file, include the line: + + ``%include /tmp/part-include`` + + The partitioning commands selected in the script will be used. + """ def _resetScript(self): ScriptSection._resetScript(self) self._script["type"] = KS_SCRIPT_PRE +class PreInstallScriptSection(ScriptSection): + sectionOpen = "%pre-install" + _title = "Pre-install Script" + _description=""" + You can use the %pre-install section to run commands after the system has been + partitioned, filesystems created, and everything is mounted under /mnt/sysimage + Like %pre these scripts do not run in the chrooted environment. + + Each %pre-install section is required to be closed with a corresponding %end. + """ + + def _resetScript(self): + ScriptSection._resetScript(self) + self._script["type"] = KS_SCRIPT_PREINSTALL + class PostScriptSection(ScriptSection): sectionOpen = "%post" + _title = "Post-installation Script" + _description=""" + You have the option of adding commands to run on the system once the + installation is complete. This section must be at the end of the + kickstart file and must start with the %post command. This section is + useful for functions such as installing additional software and + configuring an additional nameserver. + + You may have more than one %post section, which can be useful for cases + where some post-installation scripts need to be run in the chroot and + others that need access outside the chroot. + + Each %post section is required to be closed with a corresponding %end. + + If you configured the network with static IP information, including a + nameserver, you can access the network and resolve IP addresses in the %post + section. If you configured the network for DHCP, the /etc/resolv.conf file + has not been completed when the installation executes the %post section. You + can access the network, but you can not resolve IP addresses. Thus, if you + are using DHCP, you must specify IP addresses in the %post section. + + If your script spawns a daemon process, you must make sure to close stdout + and stderr. Doing so is standard procedure for creating daemons. If you do + not close these file descriptors, the installation will appear hung as + anaconda waits for an EOF from the script. + + The post-install script is run in a chroot environment; therefore, performing + tasks such as copying scripts or RPMs from the installation media will not + work. + """ + + _epilog=""" + Examples + -------- + + Run a script named ``runme`` from an NFS share:: + + %post + mkdir /mnt/temp + mount 10.10.0.2:/usr/new-machines /mnt/temp + open -s -w -- /mnt/temp/runme + umount /mnt/temp + %end + + Copy the file /etc/resolv.conf to the file system that was just + installed:: + + %post --nochroot + cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf + %end + + **If your kickstart is being interpreted by the livecd-creator tool, you should + replace /mnt/sysimage above with $INSTALL_ROOT.** + """ def _getParser(self): op = ScriptSection._getParser(self) - op.add_option("--nochroot", dest="nochroot", action="store_true", - default=False) + op.add_argument("--nochroot", dest="nochroot", action="store_true", + default=False, version=FC4, help=""" + Allows you to specify commands that you would like to + run outside of the chroot environment.""") return op def _resetScript(self): @@ -188,16 +380,76 @@ class PostScriptSection(ScriptSection): self._script["chroot"] = True self._script["type"] = KS_SCRIPT_POST -class TracebackScriptSection(ScriptSection): - sectionOpen = "%traceback" +class OnErrorScriptSection(ScriptSection): + sectionOpen = "%onerror" + _title = "Handling Errors" + _description=""" + These scripts run when the installer hits a fatal error, but not necessarily + a bug in the installer. Some examples of these situations include errors in + packages that have been requested to be installed, failures when starting VNC + when requested, and error when scanning storage. When these situations happen, + installation cannot continue. The installer will run all %onerror scripts in + the order they are provided in the kickstart file. + + In addition, %onerror scripts will be run on a traceback as well. To be exact, + all %onerror scripts will be run and then all %traceback scripts will be run + afterwards. + + Each %onerror script is required to be closed with a corresponding %end. + + .. note:: + + These scripts could potentially run at + any stage in installation - early on, between making filesystems and installing + packages, before the bootloader is installed, when attempting to reboot, and + so on. For this reason, these scripts cannot be run in the chroot environment + and you should not trust anything in the installed system. These scripts are + primarily for testing and error reporting purposes. + """ def _resetScript(self): ScriptSection._resetScript(self) + self._script["type"] = KS_SCRIPT_ONERROR + +class TracebackScriptSection(OnErrorScriptSection): + sectionOpen = "%traceback" + _title = "Handling Tracebacks" + _description=""" + These scripts run when the installer hits an internal error (a traceback, as + they are called in Python) and cannot continue. When this situation happens, + the installer will display an error dialog to the screen that prompts the user + to file a bug or reboot. At the same time, it will run all %traceback scripts + in the order they are provided in the kickstart file. + + Each %traceback script is required to be closed with a corresponding %end. + + .. note:: + + These scripts could potentially run at + any stage in installation - early on, between making filesystems and installing + packages, before the bootloader is installed, when attempting to reboot, and + so on. For this reason, these scripts cannot be run in the chroot environment + and you should not trust anything in the installed system. These scripts are + primarily for testing and error reporting purposes. + """ + + def _resetScript(self): + OnErrorScriptSection._resetScript(self) self._script["type"] = KS_SCRIPT_TRACEBACK + def handleHeader(self, lineno, args): + super().handleHeader(lineno, args) + + if self.version < F34: + return + + warnings.warn("The %traceback section has been deprecated. It may be removed in the " + "future, which will result in a fatal error from kickstart. Please modify " + "your kickstart file to use the %onerror section instead.", + KickstartDeprecationWarning) + class RunScriptSection(ScriptSection): sectionOpen = "%runscript" - def _resetScript(self): ScriptSection._resetScript(self) self._script["type"] = KS_SCRIPT_RUN @@ -227,51 +479,356 @@ class PostUmountScriptSection(ScriptSection): class PackageSection(Section): sectionOpen = "%packages" + _title = "Package Selection" def handleLine(self, line): - if not self.handler: - return - - (h, s, t) = line.partition('#') + h = line.partition('#')[0] line = h.rstrip() self.handler.packages.add([line]) + def _getParser(self): + op = KSOptionParser(prog=self.sectionOpen, description=""" + Use the %packages command to begin a kickstart file + section that lists the packages you would like to + install. + + Packages can be specified by group or by individual + package name. The installation program defines + several groups that contain related packages. Refer + to the repodata/\\*comps\\*.xml file on the + installation media or in installation repository + for a list of groups. Each group has an id, user + visibility value, name, description, and package + list. In the package list, the packages marked as + mandatory are always installed if the group is + selected, the packages marked default are selected + by default if the group is selected, and the packages + marked optional must be specifically selected even + if the group is selected to be installed. + + In most cases, it is only necessary to list the + desired groups and not individual packages. Note + that the Core group is always selected by default, + so it is not necessary to specify it in the + %packages section. + + The %packages section is required to be closed with + %end. Also, multiple %packages sections may be given. + This may be handy if the kickstart file is used as a + template and pulls in various other files with the + %include mechanism. + + Here is an example %packages selection:: + + %packages + @X Window System + @GNOME Desktop Environment + @Graphical Internet + @Sound and Video + dhcp + %end + + As you can see, groups are specified, one to a line, + starting with an ``@`` symbol followed by the full + group name as given in the comps.xml file. Groups + can also be specified using the id for the group, + such as gnome-desktop. Specify individual packages + with no additional characters (the dhcp line in the + example above is an individual package). + + The ``@`` prefix is also used to request installation + of module streams in the following format:: + + @<module name>:<stream name>/<profile name> + + Profile name is optional and multiple profiles can be + installed by using multiple lines, one per profile. + Stream name is only optional only if the given module + has a default stream. + + If there are a module and a group named the same, + and no stream name and profile are specified, + module will be selected instead of a group. + + Requesting one module more than once with different + streams or not specifying a stream name for a module + without a default stream will result in an error. + + Here is an example %packages selection with modules:: + + %packages + @^Fedora Server Edition + @nodejs:10 + @django:1.6 + @postgresql:9.6/server + @mariadb:10.1/server + @mysql:5.7/default + @scala:2.10/default + @gimp:2.10/devel + vim + %end + + You can also specify environments using the ``@^`` + prefix followed by full environment name as given in + the comps.xml file. If multiple environments are + specified, only the last one specified will be used. + Environments can be mixed with both group + specifications (even if the given group is not part + of the specified environment) and package + specifications. + + Here is an example of requesting the GNOME Desktop + environment to be selected for installation:: + + %packages + @^gnome-desktop-environment + %end + + Additionally, individual packages may be specified + using globs. For instance:: + + %packages + vim* + kde-i18n-* + %end + + This would install all packages whose names start + with "vim" or "kde-i18n-". + + You can also specify which packages or groups not to + install from the default package list:: + + %packages + -autofs + -@Sound and Video + %end + """, epilog=""" + Group-level options + ------------------- + + In addition, group lines in the %packages section + can take the following options: + + ``--nodefaults`` + + Only install the group's mandatory packages, not + the default selections. + + ``--optional`` + + In addition to the mandatory and default packages, + also install the optional packages. This means all + packages in the group will be installed. + """, version=FC4) + + op.add_argument("--excludedocs", action="store_true", default=False, + help=""" + Do not install any of the documentation from any packages. + For the most part, this means files in /usr/share/doc* + will not get installed though it could mean other files + as well, depending on how the package was built.""", + version=FC4) + op.add_argument("--ignoremissing", action="store_true", default=False, + help=""" + Ignore any packages, groups or module streams specified in the + packages section that are not found in any configured repository. + The default behavior is to halt the installation and ask + the user if the installation should be aborted or + continued. This option allows fully automated + installation even in the error case.""", + version=FC4) + op.add_argument("--ignoredeps", dest="resolveDeps", action="store_false", + deprecated=FC4, help="") + op.add_argument("--resolvedeps", dest="resolveDeps", action="store_true", + deprecated=FC4, help="") + + if self.version < F7: + return op + + op.add_argument("--default", dest="defaultPackages", action="store_true", + default=False, version=F7, help=""" + Install the default environment. This corresponds to the + package set that would be installed if no other + selections were made on the package customization screen + during an interactive install.""") + + if self.version < F9: + return op + + op.remove_argument("--ignoredeps", version=F9) + op.remove_argument("--resolvedeps", version=F9) + op.add_argument("--instLangs", default=None, version=F9, help=""" + Specify the list of languages that should be installed. + This is different from the package group level + selections, though. This option does not specify what + package groups should be installed. Instead, it controls + which translation files from individual packages should + be installed by setting RPM macros.""") + + if self.version < RHEL6: + return op + + op.add_argument("--nobase", action="store_true", default=False, + version=RHEL6, help=""" + Do not install the @base group (installed by default, + otherwise).""") + + if self.version < F18: + return op + + op.add_argument("--nobase", action="store_true", default=False, + deprecated=F18) + op.add_argument("--multilib", dest="multiLib", action="store_true", + default=False, version=F18, help=""" + Enable yum's "all" multilib_policy as opposed to the + default of "best".""") + + if self.version < F21: + return op + + op.add_argument("--nocore", action="store_true", default=False, + version=F21, help=""" + Do not install the @core group (installed by default, + otherwise). + + **Omitting the core group can produce a system that is + not bootable or that cannot finish the install. Use + with caution.**""") + + if self.version < RHEL7: + return op + + op.add_argument("--timeout", dest="timeout", type=int, + default=None, version=RHEL7, help=""" + Set up yum's or dnf's timeout. It is a number of seconds + to wait for a connection before timing out.""") + op.add_argument("--retries", dest="retries", type=int, + default=None, version=RHEL7, help=""" + Set up yum's or dnf's retries. It is a number of times + any attempt to retrieve a file should retry before + returning an error.""") + + if self.version < F22: + return op + + op.remove_argument("--nobase", version=F22) + + if self.version < F24: + return op + + op.add_argument("--excludeWeakdeps", dest="excludeWeakdeps", + action="store_true", default=False, version=F24, + help=""" + Do not install packages from weak dependencies. These + are packages linked to the selected package set by + Recommends and Supplements flags. By default weak + dependencies will be installed.""") + + if self.version < F32: + return op + + op.add_argument("--instLangs", "--inst-langs", dest="instLangs", default=None, + version=F32, help="Added ``--inst-langs`` alias") + + op.add_argument("--excludeWeakdeps", "--exclude-weakdeps", dest="excludeWeakdeps", + action="store_true", default=False, version=F32, + help="Added ``--exclude-weakdeps`` alias") + + op.add_argument("--ignorebroken", action="store_true", default=False, version=F32, + help=""" + Ignore any packages, groups or modules with conflicting files. + This issue will disable the DNF `strict` option. The default behavior + is to abort the installation with error message describing the + conflicting files. + + **WARNING: Usage of this parameter is DISCOURAGED! The DNF + strict option will NOT log any information about what packages + were skipped. Using this option may result in an unusable system.** + """) + + if isRHEL(self.version): + # The --ignorebroken feature is not supported on RHEL. + op.remove_argument("--ignorebroken", version=RHEL9) + + return op + def handleHeader(self, lineno, args): """Process the arguments to the %packages header and set attributes on the Version's Packages instance appropriate. This method may be overridden in a subclass if necessary. """ Section.handleHeader(self, lineno, args) - op = KSOptionParser(version=self.version) - op.add_option("--excludedocs", dest="excludedocs", action="store_true", - default=False) - op.add_option("--ignoremissing", dest="ignoremissing", - action="store_true", default=False) - op.add_option("--nobase", dest="nobase", action="store_true", - default=False) - op.add_option("--ignoredeps", dest="resolveDeps", action="store_false", - deprecated=FC4, removed=F9) - op.add_option("--resolvedeps", dest="resolveDeps", action="store_true", - deprecated=FC4, removed=F9) - op.add_option("--default", dest="defaultPackages", action="store_true", - default=False, introduced=F7) - op.add_option("--instLangs", dest="instLangs", type="string", - default="", introduced=F9) - - (opts, extra) = op.parse_args(args=args[1:], lineno=lineno) - - self.handler.packages.excludeDocs = opts.excludedocs - self.handler.packages.addBase = not opts.nobase - if opts.ignoremissing: + op = self._getParser() + ns = op.parse_args(args=args[1:], lineno=lineno) + + self.handler.packages.seen = True + self.handler.packages.excludeDocs = ns.excludedocs + if ns.ignoremissing: self.handler.packages.handleMissing = KS_MISSING_IGNORE else: self.handler.packages.handleMissing = KS_MISSING_PROMPT - if opts.defaultPackages: + if self.version < F7: + return + + if ns.defaultPackages: self.handler.packages.default = True - if opts.instLangs: - self.handler.packages.instLangs = opts.instLangs + if self.version < F9: + return + + if ns.instLangs is not None: + self.handler.packages.instLangs = ns.instLangs + + if self.version < RHEL6: + return + + if ns.defaultPackages and getattr(ns, "nobase", False): + raise KickstartParseError(_("--default and --nobase cannot be used together"), lineno=lineno) + + self.handler.packages.addBase = not getattr(ns, "nobase", False) + + if self.version < F18: + return + + self.handler.packages.multiLib = ns.multiLib + + if self.version < F21: + return + + if ns.defaultPackages and ns.nocore: + raise KickstartParseError(_("--default and --nocore cannot be used together"), lineno=lineno) + + self.handler.packages.nocore = ns.nocore + + if self.version < RHEL7: + return + + self.handler.packages.timeout = ns.timeout + self.handler.packages.retries = ns.retries + + if self.version < F24: + return + + self.handler.packages.excludeWeakdeps = ns.excludeWeakdeps + + if self.version < F32: + return + + if getattr(ns, "ignorebroken", False): + self.handler.packages.handleBroken = KS_BROKEN_IGNORE + else: + self.handler.packages.handleBroken = KS_BROKEN_REPORT + + for arg in args: + for option, new_option in \ + {"--instLangs": "--inst-langs", "--excludeWeakdeps": "--exclude-weakdeps"}.items(): + if option in arg: + warnings.warn(_("The %(option)s option on line %(lineno)s will be deprecated in " + "future releases. Please modify your kickstart file to replace " + "this option with its preferred alias %(new_option)s.") + % {"option": option, "lineno": lineno, "new_option": new_option}, + KickstartDeprecationWarning) class TpkPackageSection(Section): sectionOpen = "%tpk_packages" @@ -290,3 +847,4 @@ class TpkPackageSection(Section): overridden in a subclass if necessary. """ Section.handleHeader(self, lineno, args) + diff --git a/mic/3rdparty/pykickstart/version.py b/mic/3rdparty/pykickstart/version.py index 102cc37..6a8cf21 100644 --- a/mic/3rdparty/pykickstart/version.py +++ b/mic/3rdparty/pykickstart/version.py @@ -1,7 +1,7 @@ # # Chris Lumens <clumens@redhat.com> # -# Copyright 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. +# Copyright 2006-2015 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, modify, # copy, or redistribute it subject to the terms and conditions of the GNU @@ -15,7 +15,7 @@ # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat # trademarks that are incorporated in the source code or documentation are not # subject to the GNU General Public License and may only be used or replicated -# with the express permission of Red Hat, Inc. +# with the express permission of Red Hat, Inc. # """ Methods for working with kickstart versions. @@ -39,17 +39,20 @@ This module also exports several functions: versionToString - Perform the reverse mapping. + versionToLongString - Perform the reverse mapping but use long names. + versionFromFile - Read a kickstart file and determine the version of syntax it uses. This requires the kickstart file to have a version= comment in it. """ -import imputil, re, sys -from urlgrabber import urlopen +import os, re, sys + +import importlib -import gettext -_ = lambda x: gettext.ldgettext("pykickstart", x) +from pykickstart.i18n import _ from pykickstart.errors import KickstartVersionError +from pykickstart.load import load_to_str # Symbolic names for internal version numbers. RHEL3 = 900 @@ -59,7 +62,7 @@ FC4 = 2000 FC5 = 3000 FC6 = 4000 RHEL5 = 4100 -F7 = 5000 +F7 = 5000 F8 = 6000 F9 = 7000 F10 = 8000 @@ -70,17 +73,46 @@ RHEL6 = 11100 F14 = 12000 F15 = 13000 F16 = 14000 +F17 = 15000 +F18 = 16000 +F19 = 17000 +F20 = 18000 +F21 = 19000 +RHEL7 = 19100 +F22 = 20000 +F23 = 21000 +F24 = 22000 +F25 = 23000 +F26 = 24000 +F27 = 25000 +F28 = 26000 +RHEL8 = 26100 +F29 = 27000 +F30 = 30000 +F31 = 31000 +F32 = 32000 +F33 = 33000 +F34 = 34000 +RHEL9 = 34100 +F35 = 35000 +F36 = 36000 +F37 = 37000 # This always points at the latest version and is the default. -DEVEL = F16 +DEVEL = F37 # A one-to-one mapping from string representations to version numbers. versionMap = { - "DEVEL": DEVEL, - "FC3": FC3, "FC4": FC4, "FC5": FC5, "FC6": FC6, "F7": F7, "F8": F8, - "F9": F9, "F10": F10, "F11": F11, "F12": F12, "F13": F13, - "F14": F14, "F15": F15, "F16": F16, - "RHEL3": RHEL3, "RHEL4": RHEL4, "RHEL5": RHEL5, "RHEL6": RHEL6 + "DEVEL": DEVEL, + "FC3": FC3, "FC4": FC4, "FC5": FC5, "FC6": FC6, "F7": F7, "F8": F8, + "F9": F9, "F10": F10, "F11": F11, "F12": F12, "F13": F13, + "F14": F14, "F15": F15, "F16": F16, "F17": F17, "F18": F18, + "F19": F19, "F20": F20, "F21": F21, "F22": F22, "F23": F23, + "F24": F24, "F25": F25, "F26": F26, "F27": F27, "F28": F28, + "F29": F29, "F30": F30, "F31": F31, "F32": F32, "F33": F33, + "F34": F34, "F35": F35, "F36": F36, "F37": F37, + "RHEL3": RHEL3, "RHEL4": RHEL4, "RHEL5": RHEL5, "RHEL6": RHEL6, + "RHEL7": RHEL7, "RHEL8": RHEL8, "RHEL9": RHEL9 } def stringToVersion(s): @@ -94,21 +126,21 @@ def stringToVersion(s): pass # Now try the Fedora versions. - m = re.match("^fedora.* (\d+)$", s, re.I) + m = re.match(r"^fedora.* (\d+)$", s, re.I) # pylint: disable=no-member if m and m.group(1): - if versionMap.has_key("FC" + m.group(1)): + if "FC" + m.group(1) in versionMap: return versionMap["FC" + m.group(1)] - elif versionMap.has_key("F" + m.group(1)): + elif "F" + m.group(1) in versionMap: return versionMap["F" + m.group(1)] else: raise KickstartVersionError(_("Unsupported version specified: %s") % s) # Now try the RHEL versions. - m = re.match("^red hat enterprise linux.* (\d+)([\.\d]*)$", s, re.I) + m = re.match(r"^red hat enterprise linux.* (\d+)([\.\d]*)$", s, re.I) # pylint: disable=no-member if m and m.group(1): - if versionMap.has_key("RHEL" + m.group(1)): + if "RHEL" + m.group(1) in versionMap: return versionMap["RHEL" + m.group(1)] else: raise KickstartVersionError(_("Unsupported version specified: %s") % s) @@ -124,7 +156,7 @@ def versionToString(version, skipDevel=False): if not skipDevel and version == versionMap["DEVEL"]: return "DEVEL" - for (key, val) in versionMap.iteritems(): + for (key, val) in list(versionMap.items()): if key == "DEVEL": continue elif val == version: @@ -132,37 +164,36 @@ def versionToString(version, skipDevel=False): raise KickstartVersionError(_("Unsupported version specified: %s") % version) +def versionToLongString(version): + """ + Convert version into a long string representation. + """ + result = versionToString(version, True) + result = result.replace('FC', 'F').replace('F', 'Fedora') + result = result.replace('RHEL', 'RedHatEnterpriseLinux') + return result + def versionFromFile(f): """Given a file or URL, look for a line starting with #version= and return the version number. If no version is found, return DEVEL. """ v = DEVEL - fh = urlopen(f) + contents = load_to_str(f) - while True: - try: - l = fh.readline() - except StopIteration: - break - - # At the end of the file? - if l == "": - break - - if l.isspace() or l.strip() == "": + for line in contents.splitlines(True): + if line.strip() == "": continue - if l[:9] == "#version=": - v = stringToVersion(l[9:].rstrip()) + if line[:9] == "#version=": + v = stringToVersion(line[9:].rstrip()) break - fh.close() return v def returnClassForVersion(version=DEVEL): """Return the class of the syntax handler for version. version can be - either a string or the matching constant. Raises KickstartValueError + either a string or the matching constant. Raises KickstartVersionError if version does not match anything. """ try: @@ -175,12 +206,11 @@ def returnClassForVersion(version=DEVEL): module = module.lower() try: - import pykickstart.handlers - sys.path.extend(pykickstart.handlers.__path__) - found = imputil.imp.find_module(module) - loaded = imputil.imp.load_module(module, found[0], found[1], found[2]) + _path = os.path.join(os.path.dirname(__file__), "handlers/") + sys.path.extend([_path]) + loaded = importlib.import_module(module) - for (k, v) in loaded.__dict__.iteritems(): + for (k, v) in list(loaded.__dict__.items()): if k.lower().endswith("%shandler" % module): return v except: @@ -195,3 +225,9 @@ def makeVersion(version=DEVEL): """ cl = returnClassForVersion(version) return cl() + +def getVersionFromCommandClass(cls): + return versionMap[cls.__name__.split('_')[0]] + +def isRHEL(version): + return "RHEL" in versionToString(version, skipDevel=True) diff --git a/mic/__init__.py b/mic/__init__.py index 723746b..a60b9b1 100755 --- a/mic/__init__.py +++ b/mic/__init__.py @@ -16,7 +16,7 @@ import os, sys -__version__ = "0.28.17" +__version__ = "0.28.19" cur_path = os.path.dirname(__file__) or '.' sys.path.insert(0, cur_path + '/3rdparty') diff --git a/mic/archive.py b/mic/archive.py index c6fde02..0d9a3d0 100644 --- a/mic/archive.py +++ b/mic/archive.py @@ -180,7 +180,7 @@ def get_compress_formats(): @retval: a list contained supported compress formats """ - return _COMPRESS_FORMATS.keys() + return list(_COMPRESS_FORMATS.keys()) def get_compress_suffixes(): """ Get the list of the support suffixes @@ -188,7 +188,7 @@ def get_compress_suffixes(): @retval: a list contained all suffixes """ suffixes = [] - for key in _COMPRESS_SUFFIXES.keys(): + for key in list(_COMPRESS_SUFFIXES.keys()): suffix = _COMPRESS_SUFFIXES[key] if (suffix): suffixes.extend(suffix) @@ -222,7 +222,7 @@ def decompress(file_path, decompress_format=None): raise OSError ("can't decompress a file not existed: '%s'" % file_path) (file_name, file_ext) = os.path.splitext(file_path) - for key, suffixes in _COMPRESS_SUFFIXES.iteritems(): + for key, suffixes in list(_COMPRESS_SUFFIXES.items()): if file_ext in suffixes: file_ext = key break @@ -377,7 +377,7 @@ def get_archive_formats(): @retval: a list contained archive formats """ - return _ARCHIVE_FORMATS.keys() + return list(_ARCHIVE_FORMATS.keys()) def get_archive_suffixes(): """ Get the list of the support suffixes @@ -385,7 +385,7 @@ def get_archive_suffixes(): @retval: a list contained all suffixes """ suffixes = [] - for name in _ARCHIVE_FORMATS.keys(): + for name in list(_ARCHIVE_FORMATS.keys()): suffix = _ARCHIVE_SUFFIXES.get(name, None) if (suffix): suffixes.extend(suffix) @@ -402,8 +402,8 @@ def make_archive(archive_name, target_name): if not os.path.exists(target_name): raise OSError ("archive object does not exist: '%s'" % target_name) - for aformat, suffixes in _ARCHIVE_SUFFIXES.iteritems(): - if filter(archive_name.endswith, suffixes): + for aformat, suffixes in list(_ARCHIVE_SUFFIXES.items()): + if list(filter(archive_name.endswith, suffixes)): archive_format = aformat break else: diff --git a/mic/bootstrap.py b/mic/bootstrap.py index e2ea8f1..f1bd137 100644 --- a/mic/bootstrap.py +++ b/mic/bootstrap.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2009, 2010, 2011 Intel, Inc. # @@ -15,7 +15,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from __future__ import with_statement + import os import sys import tempfile @@ -30,6 +30,7 @@ from mic.utils import errors, proxy, misc from mic.utils.rpmmisc import readRpmHeader, RPMInstallCallback from mic.chroot import cleanup_mounts, setup_chrootenv, cleanup_chrootenv from mic.conf import configmgr +from functools import reduce PATH_BOOTSTRAP = "/usr/sbin:/usr/bin:/sbin:/bin" @@ -114,10 +115,10 @@ class MiniBackend(object): if not self.scriptlets: return - for pkg in self.preins.keys(): + for pkg in list(self.preins.keys()): prog, script = self.preins[pkg] self.run_pkg_script(pkg, prog, script, '0') - for pkg in self.postins.keys(): + for pkg in list(self.postins.keys()): prog, script = self.postins[pkg] self.run_pkg_script(pkg, prog, script, '1') @@ -141,7 +142,7 @@ class MiniBackend(object): ','.join(nonexist)) def installPkgs(self): - for pkg in self.localpkgs.keys(): + for pkg in list(self.localpkgs.keys()): rpmpath = self.localpkgs[pkg] hdr = readRpmHeader(self.ts, rpmpath) @@ -237,7 +238,7 @@ class Bootstrap(object): pkgmgr.arch = self.arch pkgmgr.repomd = repomd pkgmgr.optionals = list(optlist) - map(pkgmgr.selectPackage, pkglist + list(optlist)) + list(map(pkgmgr.selectPackage, pkglist + list(optlist))) pkgmgr.runInstall() except (OSError, IOError, errors.CreatorError) as err: raise errors.BootstrapError("%s" % err) diff --git a/mic/chroot.py b/mic/chroot.py index 71e35b7..2154c36 100644 --- a/mic/chroot.py +++ b/mic/chroot.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2009, 2010, 2011 Intel, Inc. # @@ -15,7 +15,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from __future__ import with_statement + import os import re import shutil @@ -56,6 +56,7 @@ def ELF_arch(chrootdir): r"Intel 80[0-9]86": "i686", r"x86-64": "x86_64", r"ARM": "arm", + r"RISC-V": "riscv64", } for path in chkfiles: @@ -64,7 +65,7 @@ def ELF_arch(chrootdir): continue outs = runner.outs(['file', cpath]) - for ptn in mapping.keys(): + for ptn in list(mapping.keys()): if re.search(ptn, outs): return mapping[ptn] @@ -280,7 +281,7 @@ def savefs_before_chroot(chrootdir, saveto = None): 'dev/stderr', 'etc/mtab'] ignlst = [os.path.join(saveto, x) for x in devs] - map(os.unlink, filter(os.path.exists, ignlst)) + list(map(os.unlink, list(filter(os.path.exists, ignlst)))) else: msger.warning(wrnmsg) @@ -307,6 +308,8 @@ def chroot(chrootdir, bindmounts = None, execute = "/bin/bash"): qemu_emulators = misc.setup_qemu_emulator(chrootdir, "arm") elif arch == "mipsel": qemu_emulators = misc.setup_qemu_emulator(chrootdir, "mipsel") + elif arch == "riscv64": + qemu_emulators = misc.setup_qemu_emulator(chrootdir, "riscv64") else: qemu_emulators = [] diff --git a/mic/cmd_chroot.py b/mic/cmd_chroot.py index 35b089b..a94d29b 100755 --- a/mic/cmd_chroot.py +++ b/mic/cmd_chroot.py @@ -1,71 +1,69 @@ -#!/usr/bin/python -tt
-# vim: ai ts=4 sts=4 et sw=4
-#
-# Copyright (c) 2012 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; version 2 of the License
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-"""Implementation of subcmd: chroot
-"""
-
-import os
-import os, sys, re
-import pwd
-import argparse
-
-from mic import msger
-from mic.utils import misc, errors
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-
-def _root_confirm():
- """Make sure command is called by root
- There are a lot of commands needed to be run during creating images,
- some of them must be run with root privilege like mount, kpartx"""
- if os.geteuid() != 0:
- msger.error('Root permission is required to continue, abort')
-
-def main(parser, args, argv):
- """mic choot entry point."""
-
- #args is argparser namespace, argv is the input cmd line
- if args is None:
- raise errors.Usage("Invalid arguments")
-
- targetimage = args.imagefile
- if not os.path.exists(targetimage):
- raise errors.CreatorError("Cannot find the image: %s"
- % targetimage)
-
- _root_confirm()
-
- configmgr.chroot['saveto'] = args.saveto
-
- imagetype = misc.get_image_type(targetimage)
- if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg", "f2fsimg"):
- imagetype = "loop"
-
- chrootclass = None
- for pname, pcls in pluginmgr.get_plugins('imager').iteritems():
- if pname == imagetype and hasattr(pcls, "do_chroot"):
- chrootclass = pcls
- break
-
- if not chrootclass:
- raise errors.CreatorError("Cannot support image type: %s" \
- % imagetype)
-
- chrootclass.do_chroot(targetimage, args.cmd)
-
-
+#!/usr/bin/python3 -tt +# vim: ai ts=4 sts=4 et sw=4 +# +# Copyright (c) 2012 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""Implementation of subcmd: chroot +""" + +import os +import os, sys, re +import pwd +import argparse + +from mic import msger +from mic.utils import misc, errors +from mic.conf import configmgr +from mic.plugin import pluginmgr + +def _root_confirm(): + """Make sure command is called by root + There are a lot of commands needed to be run during creating images, + some of them must be run with root privilege like mount, kpartx""" + if os.geteuid() != 0: + msger.error('Root permission is required to continue, abort') + +def main(parser, args, argv): + """mic choot entry point.""" + + #args is argparser namespace, argv is the input cmd line + if args is None: + raise errors.Usage("Invalid arguments") + + targetimage = args.imagefile + if not os.path.exists(targetimage): + raise errors.CreatorError("Cannot find the image: %s" + % targetimage) + + _root_confirm() + + configmgr.chroot['saveto'] = args.saveto + + imagetype = misc.get_image_type(targetimage) + if imagetype in ("ext3fsimg", "ext4fsimg", "btrfsimg", "f2fsimg"): + imagetype = "loop" + + chrootclass = None + for pname, pcls in list(pluginmgr.get_plugins('imager').items()): + if pname == imagetype and hasattr(pcls, "do_chroot"): + chrootclass = pcls + break + + if not chrootclass: + raise errors.CreatorError("Cannot support image type: %s" \ + % imagetype) + + chrootclass.do_chroot(targetimage, args.cmd) diff --git a/mic/cmd_create.py b/mic/cmd_create.py index a62abc7..bb60c9d 100644 --- a/mic/cmd_create.py +++ b/mic/cmd_create.py @@ -1,270 +1,272 @@ -#!/usr/bin/python -tt
-# vim: ai ts=4 sts=4 et sw=4
-#
-# Copyright (c) 2012 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; version 2 of the License
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-"""Implementation of subcmd: create
-"""
-
-import os
-import os, sys, re
-import pwd
-import argparse
-
-from mic import msger
-from mic.utils import errors, rpmmisc
-from mic.conf import configmgr
-from mic.plugin import pluginmgr
-
-def main(parser, args, argv):
- """mic create entry point."""
- #args is argparser namespace, argv is the input cmd line
- if args is None:
- raise errors.Usage("Invalid arguments")
-
- if not os.path.exists(args.ksfile):
- raise errors.CreatorError("Can't find the file: %s" % args.ksfile)
-
- if os.geteuid() != 0:
- msger.error("Root permission is required, abort")
-
- try:
- w = pwd.getpwuid(os.geteuid())
- except KeyError:
- msger.warning("Might fail in compressing stage for undetermined user")
-
- abspath = lambda pth: os.path.abspath(os.path.expanduser(pth))
- if args.logfile:
- logfile_abs_path = abspath(args.logfile)
- if os.path.isdir(logfile_abs_path):
- raise errors.Usage("logfile's path %s should be file"
- % args.logfile)
- configmgr.create['logfile'] = logfile_abs_path
- configmgr.set_logfile()
-
- if args.subcommand == "auto":
- do_auto(parser, args.ksfile, argv)
- return
-
- if args.interactive:
- msger.enable_interactive()
- else:
- msger.disable_interactive()
-
- if args.verbose:
- msger.set_loglevel('VERBOSE')
-
- if args.debug:
- try:
- import rpm
- rpm.setVerbosity(rpm.RPMLOG_NOTICE)
- except ImportError:
- pass
-
- msger.set_loglevel('DEBUG')
-
- if args.rpm_debug:
- try:
- import rpm
- rpm.setVerbosity(rpm.RPMLOG_DEBUG)
- except ImportError:
- pass
- #check the imager type
- createrClass = None
- for subcmd, klass in pluginmgr.get_plugins('imager').iteritems():
- if subcmd == args.subcommand and hasattr(klass, 'do_create'):
- createrClass = klass
-
- if createrClass is None:
- raise errors.CreatorError("Can't support subcommand %s" % args.subcommand)
-
- if args.config:
- configmgr.reset()
- configmgr._siteconf = args.config
-
- if args.outdir is not None:
- configmgr.create['outdir'] = abspath(args.outdir)
- if args.cachedir is not None:
- configmgr.create['cachedir'] = abspath(args.cachedir)
- os.environ['ZYPP_LOCKFILE_ROOT'] = configmgr.create['cachedir']
-
- for cdir in ('outdir', 'cachedir'):
- if os.path.exists(configmgr.create[cdir]) \
- and not os.path.isdir(configmgr.create[cdir]):
- raise errors.Usage('Invalid directory specified: %s' \
- % configmgr.create[cdir])
- if not os.path.exists(configmgr.create[cdir]):
- os.makedirs(configmgr.create[cdir])
- if os.getenv('SUDO_UID', '') and os.getenv('SUDO_GID', ''):
- os.chown(configmgr.create[cdir],
- int(os.getenv('SUDO_UID')),
- int(os.getenv('SUDO_GID')))
-
- if args.local_pkgs_path is not None:
- if not os.path.exists(args.local_pkgs_path):
- raise errors.Usage('Local pkgs directory: \'%s\' not exist' \
- % args.local_pkgs_path)
- configmgr.create['local_pkgs_path'] = args.local_pkgs_path
-
- if args.release:
- configmgr.create['release'] = args.release.rstrip('/')
-
- if args.record_pkgs:
- configmgr.create['record_pkgs'] = []
- for infotype in args.record_pkgs.split(','):
- if infotype not in ('name', 'content', 'license', 'vcs'):
- raise errors.Usage('Invalid pkg recording: %s, valid ones:'
- ' "name", "content", "license", "vcs"' \
- % infotype)
-
- configmgr.create['record_pkgs'].append(infotype)
-
- if args.strict_mode:
- configmgr.create['strict_mode'] = args.strict_mode
- if args.arch is not None:
- supported_arch = sorted(rpmmisc.archPolicies.keys(), reverse=True)
- if args.arch in supported_arch:
- configmgr.create['arch'] = args.arch
- else:
- raise errors.Usage('Invalid architecture: "%s".\n'
- ' Supported architectures are: \n'
- ' %s' % (args.arch,
- ', '.join(supported_arch)))
-
- if args.pkgmgr is not None:
- configmgr.create['pkgmgr'] = args.pkgmgr
-
- if args.skip_set_hosts:
- configmgr.create['skip_set_hosts']=args.skip_set_hosts
- if args.postscripts_maxruntime:
- configmgr.create['postscripts_maxruntime']=int(args.postscripts_maxruntime)
- if args.block_recommends:
- configmgr.create['block_recommends']=args.block_recommends
- if args.runtime:
- configmgr.set_runtime(args.runtime)
-
- if args.use_mic_in_bootstrap:
- configmgr.create['use_mic_in_bootstrap'] = args.use_mic_in_bootstrap
-
- if args.pack_to is not None:
- configmgr.create['pack_to'] = args.pack_to
-
- if args.copy_kernel:
- configmgr.create['copy_kernel'] = args.copy_kernel
-
- if args.install_pkgs:
- configmgr.create['install_pkgs'] = []
- for pkgtype in args.install_pkgs.split(','):
- if pkgtype not in ('source', 'debuginfo', 'debugsource'):
- raise errors.Usage('Invalid parameter specified: "%s", '
- 'valid values: source, debuginfo, '
- 'debusource' % pkgtype)
-
- configmgr.create['install_pkgs'].append(pkgtype)
-
- if args.check_pkgs:
- for pkg in args.check_pkgs.split(','):
- configmgr.create['check_pkgs'].append(pkg)
-
- if args.enabletmpfs:
- configmgr.create['enabletmpfs'] = args.enabletmpfs
-
- if args.repourl:
- for item in args.repourl:
- try:
- key, val = item.split('=')
- except:
- continue
- configmgr.create['repourl'][key] = val
-
- if args.repo:
- for optvalue in args.repo:
- repo = {}
- for item in optvalue.split(';'):
- try:
- key, val = item.split('=')
- except:
- continue
- repo[key.strip()] = val.strip()
- if 'name' in repo:
- configmgr.create['extrarepos'][repo['name']] = repo
-
- if args.ignore_ksrepo:
- configmgr.create['ignore_ksrepo'] = args.ignore_ksrepo
- if args.run_script:
- configmgr.create['run_script'] = args.run_script
- if args.tpk_install:
- configmgr.create['tpk_install'] = args.tpk_install
-
- creater = createrClass()
- creater.do_create(args)
-
-def do_auto(parser, ksfile, argv):
- """${cmd_name}: auto detect image type from magic header
-
- Usage:
- ${name} ${cmd_name} <ksfile>
-
- ${cmd_option_list}
- """
- def parse_magic_line(re_str, pstr, ptype='mic'):
- ptn = re.compile(re_str)
- m = ptn.match(pstr)
- if not m or not m.groups():
- return None
-
- inline_argv = m.group(1).strip()
- if ptype == 'mic':
- m2 = re.search('(?P<format>\w+)', inline_argv)
- elif ptype == 'mic2':
- m2 = re.search('(-f|--format(=)?)\s*(?P<format>\w+)',
- inline_argv)
- else:
- return None
-
- if m2:
- cmdname = m2.group('format')
- inline_argv = inline_argv.replace(m2.group(0), '')
- return (cmdname, inline_argv)
-
- return None
-
- if not os.path.exists(ksfile):
- raise errors.CreatorError("Can't find the file: %s" % ksfile)
-
- with open(ksfile, 'r') as rf:
- first_line = rf.readline()
-
- mic_re = '^#\s*-\*-mic-options-\*-\s+(.*)\s+-\*-mic-options-\*-'
- mic2_re = '^#\s*-\*-mic2-options-\*-\s+(.*)\s+-\*-mic2-options-\*-'
-
- result = parse_magic_line(mic_re, first_line, 'mic') \
- or parse_magic_line(mic2_re, first_line, 'mic2')
- if not result:
- raise errors.KsError("Invalid magic line in file: %s" % ksfile)
-
- ksargv = ' '.join(result).split()
-
- argv.remove("auto")
- index = argv.index("create")
- #insert the subcommand
- argv.insert(index+1, ksargv[0])
- options = argv + ksargv[1:]
-
- args = parser.parse_args(options)
-
- main(parser, args, options)
-
+#!/usr/bin/python3 -tt +# vim: ai ts=4 sts=4 et sw=4 +# +# Copyright (c) 2012 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""Implementation of subcmd: create +""" + +import os +import os, sys, re +import pwd +import argparse + +from mic import msger +from mic.utils import errors, rpmmisc +from mic.conf import configmgr +from mic.plugin import pluginmgr + +def main(parser, args, argv): + """mic create entry point.""" + #args is argparser namespace, argv is the input cmd line + if args is None: + raise errors.Usage("Invalid arguments") + + if not os.path.exists(args.ksfile): + raise errors.CreatorError("Can't find the file: %s" % args.ksfile) + + if os.geteuid() != 0: + msger.error("Root permission is required, abort") + + try: + w = pwd.getpwuid(os.geteuid()) + except KeyError: + msger.warning("Might fail in compressing stage for undetermined user") + + abspath = lambda pth: os.path.abspath(os.path.expanduser(pth)) + if args.logfile: + logfile_abs_path = abspath(args.logfile) + if os.path.isdir(logfile_abs_path): + raise errors.Usage("logfile's path %s should be file" + % args.logfile) + configmgr.create['logfile'] = logfile_abs_path + configmgr.set_logfile() + + if args.subcommand == "auto": + do_auto(parser, args.ksfile, argv) + return + + if args.interactive: + msger.enable_interactive() + else: + msger.disable_interactive() + + if args.verbose: + msger.set_loglevel('VERBOSE') + + if args.debug: + try: + import rpm + rpm.setVerbosity(rpm.RPMLOG_NOTICE) + except ImportError: + pass + + msger.set_loglevel('DEBUG') + + if args.rpm_debug: + try: + import rpm + rpm.setVerbosity(rpm.RPMLOG_DEBUG) + except ImportError: + pass + + #check the imager type + createrClass = None + for subcmd, klass in list(pluginmgr.get_plugins('imager').items()): + if subcmd == args.subcommand and hasattr(klass, 'do_create'): + createrClass = klass + + if createrClass is None: + raise errors.CreatorError("Can't support subcommand %s" % args.subcommand) + + if args.config: + configmgr.reset() + configmgr._siteconf = args.config + + if args.outdir is not None: + configmgr.create['outdir'] = abspath(args.outdir) + if args.cachedir is not None: + configmgr.create['cachedir'] = abspath(args.cachedir) + os.environ['ZYPP_LOCKFILE_ROOT'] = configmgr.create['cachedir'] + + for cdir in ('outdir', 'cachedir'): + if os.path.exists(configmgr.create[cdir]) \ + and not os.path.isdir(configmgr.create[cdir]): + raise errors.Usage('Invalid directory specified: %s' \ + % configmgr.create[cdir]) + if not os.path.exists(configmgr.create[cdir]): + os.makedirs(configmgr.create[cdir]) + if os.getenv('SUDO_UID', '') and os.getenv('SUDO_GID', ''): + os.chown(configmgr.create[cdir], + int(os.getenv('SUDO_UID')), + int(os.getenv('SUDO_GID'))) + + if args.local_pkgs_path is not None: + if not os.path.exists(args.local_pkgs_path): + raise errors.Usage('Local pkgs directory: \'%s\' not exist' \ + % args.local_pkgs_path) + configmgr.create['local_pkgs_path'] = args.local_pkgs_path + + if args.release: + configmgr.create['release'] = args.release.rstrip('/') + + if args.record_pkgs: + configmgr.create['record_pkgs'] = [] + for infotype in args.record_pkgs.split(','): + if infotype not in ('name', 'content', 'license', 'vcs'): + raise errors.Usage('Invalid pkg recording: %s, valid ones:' + ' "name", "content", "license", "vcs"' \ + % infotype) + + configmgr.create['record_pkgs'].append(infotype) + + if args.strict_mode: + configmgr.create['strict_mode'] = args.strict_mode + if args.arch is not None: + supported_arch = sorted(list(rpmmisc.archPolicies.keys()), reverse=True) + if args.arch in supported_arch: + configmgr.create['arch'] = args.arch + else: + raise errors.Usage('Invalid architecture: "%s".\n' + ' Supported architectures are: \n' + ' %s' % (args.arch, + ', '.join(supported_arch))) + + if args.pkgmgr is not None: + configmgr.create['pkgmgr'] = args.pkgmgr + + if args.skip_set_hosts: + configmgr.create['skip_set_hosts']=args.skip_set_hosts + + if args.postscripts_maxruntime: + configmgr.create['postscripts_maxruntime']=int(args.postscripts_maxruntime) + if args.block_recommends: + configmgr.create['block_recommends']=args.block_recommends + + if args.runtime: + configmgr.set_runtime(args.runtime) + + if args.use_mic_in_bootstrap: + configmgr.create['use_mic_in_bootstrap'] = args.use_mic_in_bootstrap + + if args.pack_to is not None: + configmgr.create['pack_to'] = args.pack_to + + if args.copy_kernel: + configmgr.create['copy_kernel'] = args.copy_kernel + + if args.install_pkgs: + configmgr.create['install_pkgs'] = [] + for pkgtype in args.install_pkgs.split(','): + if pkgtype not in ('source', 'debuginfo', 'debugsource'): + raise errors.Usage('Invalid parameter specified: "%s", ' + 'valid values: source, debuginfo, ' + 'debusource' % pkgtype) + + configmgr.create['install_pkgs'].append(pkgtype) + + if args.check_pkgs: + for pkg in args.check_pkgs.split(','): + configmgr.create['check_pkgs'].append(pkg) + + if args.enabletmpfs: + configmgr.create['enabletmpfs'] = args.enabletmpfs + + if args.repourl: + for item in args.repourl: + try: + key, val = item.split('=') + except: + continue + configmgr.create['repourl'][key] = val + + if args.repo: + for optvalue in args.repo: + repo = {} + for item in optvalue.split(';'): + try: + key, val = item.split('=') + except: + continue + repo[key.strip()] = val.strip() + if 'name' in repo: + configmgr.create['extrarepos'][repo['name']] = repo + + if args.ignore_ksrepo: + configmgr.create['ignore_ksrepo'] = args.ignore_ksrepo + if args.run_script: + configmgr.create['run_script'] = args.run_script + if args.tpk_install: + configmgr.create['tpk_install'] = args.tpk_install + + creater = createrClass() + creater.do_create(args) + +def do_auto(parser, ksfile, argv): + """${cmd_name}: auto detect image type from magic header + + Usage: + ${name} ${cmd_name} <ksfile> + + ${cmd_option_list} + """ + def parse_magic_line(re_str, pstr, ptype='mic'): + ptn = re.compile(re_str) + m = ptn.match(pstr) + if not m or not m.groups(): + return None + + inline_argv = m.group(1).strip() + if ptype == 'mic': + m2 = re.search('(?P<format>\w+)', inline_argv) + elif ptype == 'mic2': + m2 = re.search('(-f|--format(=)?)\s*(?P<format>\w+)', + inline_argv) + else: + return None + + if m2: + cmdname = m2.group('format') + inline_argv = inline_argv.replace(m2.group(0), '') + return (cmdname, inline_argv) + + return None + + if not os.path.exists(ksfile): + raise errors.CreatorError("Can't find the file: %s" % ksfile) + + with open(ksfile, 'r') as rf: + first_line = rf.readline() + + mic_re = '^#\s*-\*-mic-options-\*-\s+(.*)\s+-\*-mic-options-\*-' + mic2_re = '^#\s*-\*-mic2-options-\*-\s+(.*)\s+-\*-mic2-options-\*-' + + result = parse_magic_line(mic_re, first_line, 'mic') \ + or parse_magic_line(mic2_re, first_line, 'mic2') + if not result: + raise errors.KsError("Invalid magic line in file: %s" % ksfile) + + ksargv = ' '.join(result).split() + + argv.remove("auto") + index = argv.index("create") + #insert the subcommand + argv.insert(index+1, ksargv[0]) + options = argv + ksargv[1:] + + args = parser.parse_args(options) + + main(parser, args, options) diff --git a/mic/conf.py b/mic/conf.py index 279d14f..d24616b 100755 --- a/mic/conf.py +++ b/mic/conf.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # @@ -16,7 +16,7 @@ # Temple Place - Suite 330, Boston, MA 02111-1307, USA. import os, sys, re -import ConfigParser +import configparser from mic import msger from mic import kickstart @@ -122,14 +122,14 @@ class ConfigMgr(object): self.__siteconf = None # initialize the values with defaults - for sec, vals in self.DEFAULTS.iteritems(): + for sec, vals in list(self.DEFAULTS.items()): setattr(self, sec, vals) def __set_siteconf(self, siteconf): try: self.__siteconf = siteconf self._parse_siteconf(siteconf) - except ConfigParser.Error as error: + except configparser.Error as error: raise errors.ConfigError("%s" % error) def __get_siteconf(self): return self.__siteconf @@ -157,13 +157,13 @@ class ConfigMgr(object): if not siteconf: self.common["distro_name"] = "Tizen" # append common section items to other sections - for section in self.DEFAULTS.keys(): + for section in list(self.DEFAULTS.keys()): if section != "common": getattr(self, section).update(self.common) return - parser = ConfigParser.SafeConfigParser() + parser = configparser.SafeConfigParser() parser.read(siteconf) for section in parser.sections(): @@ -171,7 +171,7 @@ class ConfigMgr(object): getattr(self, section).update(dict(parser.items(section))) # append common section items to other sections - for section in self.DEFAULTS.keys(): + for section in list(self.DEFAULTS.keys()): if section != "common": getattr(self, section).update(self.common) @@ -191,7 +191,7 @@ class ConfigMgr(object): # bootstrap option handling self.set_runtime(self.create['runtime']) - if isinstance(self.bootstrap['packages'], basestring): + if isinstance(self.bootstrap['packages'], str): packages = self.bootstrap['packages'].replace('\n', ' ') if packages.find(',') != -1: packages = packages.split(',') diff --git a/mic/helpformat.py b/mic/helpformat.py index e17f716..f215cf1 100755 --- a/mic/helpformat.py +++ b/mic/helpformat.py @@ -1,90 +1,90 @@ -#!/usr/bin/env python
-# vim: ai ts=4 sts=4 et sw=4
-#
-# Copyright (c) 2011 Intel, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the Free
-# Software Foundation; version 2 of the License
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-"""Local additions to commandline parsing."""
-
-import os
-import re
-import functools
-
-from argparse import RawDescriptionHelpFormatter, ArgumentTypeError
-
-class MICHelpFormatter(RawDescriptionHelpFormatter):
- """Changed default argparse help output by request from cmdln lovers."""
-
- def __init__(self, *args, **kwargs):
- super(MICHelpFormatter, self).__init__(*args, **kwargs)
- self._aliases = {}
-
- def add_argument(self, action):
- """Collect aliases."""
-
- if action.choices:
- for item, parser in action.choices.iteritems():
- self._aliases[str(item)] = parser.get_default('alias')
-
- return super(MICHelpFormatter, self).add_argument(action)
-
- def format_help(self):
- """
- There is no safe and documented way in argparse to reformat
- help output through APIs as almost all of them are private,
- so this method just parses the output and changes it.
- """
- result = []
- subcomm = False
- for line in super(MICHelpFormatter, self).format_help().split('\n'):
- if line.strip().startswith('{'):
- continue
- if line.startswith('optional arguments:'):
- line = 'Global Options:'
- if line.startswith('usage:'):
- line = "Usage: mic [GLOBAL-OPTS] SUBCOMMAND [OPTS]"
- if subcomm:
- match = re.match("[ ]+([^ ]+)[ ]+(.+)", line)
- if match:
- name, help_text = match.group(1), match.group(2)
- alias = self._aliases.get(name) or ''
- if alias:
- alias = "(%s)" % alias
- line = " %-22s%s" % ("%s %s" % (name, alias), help_text)
- if line.strip().startswith('subcommands:'):
- line = 'Subcommands:'
- subcomm = True
- result.append(line)
- return '\n'.join(result)
-
-def subparser(func):
- """Convenient decorator for subparsers."""
- @functools.wraps(func)
- def wrapper(parser):
- """
- Create subparser
- Set first line of function's docstring as a help
- and the rest of the lines as a description.
- Set attribute 'module' of subparser to 'cmd'+first part of function name
- """
- splitted = func.__doc__.split('\n')
- name = func.__name__.split('_')[0]
- subpar = parser.add_parser(name, help=splitted[0],
- description='\n'.join(splitted[1:]),
- formatter_class=RawDescriptionHelpFormatter)
- subpar.set_defaults(module="cmd_%s" % name)
- return func(subpar)
- return wrapper
-
+#!/usr/bin/python3 +# vim: ai ts=4 sts=4 et sw=4 +# +# Copyright (c) 2011 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""Local additions to commandline parsing.""" + +import os +import re +import functools + +from argparse import RawDescriptionHelpFormatter, ArgumentTypeError + +class MICHelpFormatter(RawDescriptionHelpFormatter): + """Changed default argparse help output by request from cmdln lovers.""" + + def __init__(self, *args, **kwargs): + super(MICHelpFormatter, self).__init__(*args, **kwargs) + self._aliases = {} + + def add_argument(self, action): + """Collect aliases.""" + + if action.choices: + for item, parser in list(action.choices.items()): + self._aliases[str(item)] = parser.get_default('alias') + + return super(MICHelpFormatter, self).add_argument(action) + + def format_help(self): + """ + There is no safe and documented way in argparse to reformat + help output through APIs as almost all of them are private, + so this method just parses the output and changes it. + """ + result = [] + subcomm = False + for line in super(MICHelpFormatter, self).format_help().split('\n'): + if line.strip().startswith('{'): + continue + if line.startswith('optional arguments:'): + line = 'Global Options:' + if line.startswith('usage:'): + line = "Usage: mic [GLOBAL-OPTS] SUBCOMMAND [OPTS]" + if subcomm: + match = re.match("[ ]+([^ ]+)[ ]+(.+)", line) + if match: + name, help_text = match.group(1), match.group(2) + alias = self._aliases.get(name) or '' + if alias: + alias = "(%s)" % alias + line = " %-22s%s" % ("%s %s" % (name, alias), help_text) + if line.strip().startswith('subcommands:'): + line = 'Subcommands:' + subcomm = True + result.append(line) + return '\n'.join(result) + +def subparser(func): + """Convenient decorator for subparsers.""" + @functools.wraps(func) + def wrapper(parser): + """ + Create subparser + Set first line of function's docstring as a help + and the rest of the lines as a description. + Set attribute 'module' of subparser to 'cmd'+first part of function name + """ + splitted = func.__doc__.split('\n') + name = func.__name__.split('_')[0] + subpar = parser.add_parser(name, help=splitted[0], + description='\n'.join(splitted[1:]), + formatter_class=RawDescriptionHelpFormatter) + subpar.set_defaults(module="cmd_%s" % name) + return func(subpar) + return wrapper + diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index f0243f7..e3edcbb 100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2007 Red Hat Inc. # Copyright (c) 2009, 2010, 2011 Intel, Inc. @@ -16,8 +16,9 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from __future__ import with_statement -import os, sys + +import os +import sys import stat import tempfile import shutil @@ -58,7 +59,7 @@ class BaseImageCreator(object): def __del__(self): self.cleanup() - def __init__(self, createopts = None, pkgmgr = None): + def __init__(self, createopts=None, pkgmgr=None): """Initialize an ImageCreator instance. ks -- a pykickstart.KickstartParser instance; this instance will be @@ -97,15 +98,15 @@ class BaseImageCreator(object): if createopts: # Mapping table for variables that have different names. - optmap = {"pkgmgr" : "pkgmgr_name", - "arch" : "target_arch", - "local_pkgs_path" : "_local_pkgs_path", - "copy_kernel" : "_need_copy_kernel", - "strict_mode" : "strict_mode", - } + optmap = {"pkgmgr": "pkgmgr_name", + "arch": "target_arch", + "local_pkgs_path": "_local_pkgs_path", + "copy_kernel": "_need_copy_kernel", + "strict_mode": "strict_mode", + } # update setting from createopts - for key in createopts.keys(): + for key in list(createopts.keys()): if key in optmap: option = optmap[key] else: @@ -157,10 +158,11 @@ class BaseImageCreator(object): self._dep_checks.append("mkfs.btrfs") break if part.cpioopts: - if part.fstype == "cpio": + if part.fstype == "cpio": part.fstype = "ext4" else: - raise KsError("The '--fstype' in ks file need to set 'cpio' when you want to generate image by cpio.") + raise KsError( + "The '--fstype' in ks file need to set 'cpio' when you want to generate image by cpio.") if len(self.ks.handler.partition.partitions) > 1: self.multiple_partitions = True @@ -175,15 +177,15 @@ class BaseImageCreator(object): self._dep_checks.append("qemu-arm-static") if os.path.exists("/proc/sys/vm/vdso_enabled"): - vdso_fh = open("/proc/sys/vm/vdso_enabled","r") + vdso_fh = open("/proc/sys/vm/vdso_enabled", "r") vdso_value = vdso_fh.read().strip() vdso_fh.close() if (int)(vdso_value) == 1: msger.warning("vdso is enabled on your host, which might " - "cause problems with arm emulations.\n" - "\tYou can disable vdso with following command before " - "starting image build:\n" - "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled") + "cause problems with arm emulations.\n" + "\tYou can disable vdso with following command before " + "starting image build:\n" + "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled") elif self.target_arch == "mipsel": for dep in self._dep_checks: if dep == "extlinux": @@ -194,7 +196,7 @@ class BaseImageCreator(object): self._dep_checks.append("qemu-mipsel-static") if os.path.exists("/proc/sys/vm/vdso_enabled"): - vdso_fh = open("/proc/sys/vm/vdso_enabled","r") + vdso_fh = open("/proc/sys/vm/vdso_enabled", "r") vdso_value = vdso_fh.read().strip() vdso_fh.close() if (int)(vdso_value) == 1: @@ -203,6 +205,25 @@ class BaseImageCreator(object): "\tYou can disable vdso with following command before " "starting image build:\n" "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled") + elif self.target_arch == "riscv64": + for dep in self._dep_checks: + if dep == "extlinux": + self._dep_checks.remove(dep) + + if not os.path.exists("/usr/bin/qemu-riscv64") or \ + not misc.is_statically_linked("/usr/bin/qemu-riscv64"): + self._dep_checks.append("qemu-riscv64-static") + + if os.path.exists("/proc/sys/vm/vdso_enabled"): + vdso_fh = open("/proc/sys/vm/vdso_enabled","r") + vdso_value = vdso_fh.read().strip() + vdso_fh.close() + if (int)(vdso_value) == 1: + msger.warning("vdso is enabled on your host, which might " + "cause problems with riscv64 emulations.\n" + "\tYou can disable vdso with following command before " + "starting image build:\n" + "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled") # make sure the specified tmpdir and cachedir exist if not os.path.exists(self.tmpdir): @@ -210,10 +231,10 @@ class BaseImageCreator(object): if not os.path.exists(self.cachedir): os.makedirs(self.cachedir) - # # Properties # + def __get_instroot(self): if self.__builddir is None: raise CreatorError("_instroot is not valid before calling mount()") @@ -247,11 +268,10 @@ class BaseImageCreator(object): """ - # # Hooks for subclasses # - def _mount_instroot(self, base_on = None): + def _mount_instroot(self, base_on=None): """Mount or prepare the install root directory. This is the hook where subclasses may prepare the install root by e.g. @@ -306,20 +326,21 @@ class BaseImageCreator(object): shutil.move(self._instroot, self._outdir + "/" + self.name) def get_installed_packages(self): - return self._pkgs_content.keys() + return list(self._pkgs_content.keys()) def _save_recording_pkgs(self, destdir): """Save the list or content of installed packages to file. """ - pkgs = self._pkgs_content.keys() - pkgs.sort() # inplace op + pkgs = list(self._pkgs_content.keys()) + pkgs.sort() # inplace op if not os.path.exists(destdir): os.makedirs(destdir) content = None if 'vcs' in self._recording_pkgs: - vcslst = ["%s %s" % (k, v) for (k, v) in self._pkgs_vcsinfo.items()] + vcslst = ["%s %s" % (k, v) + for (k, v) in list(self._pkgs_vcsinfo.items())] content = '\n'.join(sorted(vcslst)) elif 'name' in self._recording_pkgs: content = '\n'.join(pkgs) @@ -353,14 +374,12 @@ class BaseImageCreator(object): f = open(licensefile, "w") f.write('Summary:\n') - for license in reversed(sorted(self._pkgs_license, key=\ - lambda license: len(self._pkgs_license[license]))): - f.write(" - %s: %s\n" \ + for license in reversed(sorted(self._pkgs_license, key=lambda license: len(self._pkgs_license[license]))): + f.write(" - %s: %s\n" % (license, len(self._pkgs_license[license]))) f.write('\nDetails:\n') - for license in reversed(sorted(self._pkgs_license, key=\ - lambda license: len(self._pkgs_license[license]))): + for license in reversed(sorted(self._pkgs_license, key=lambda license: len(self._pkgs_license[license]))): f.write(" - %s:\n" % (license)) for pkg in sorted(self._pkgs_license[license]): f.write(" - %s\n" % (pkg)) @@ -412,7 +431,7 @@ class BaseImageCreator(object): if self._local_pkgs_path: if os.path.isdir(self._local_pkgs_path): return glob.glob( - os.path.join(self._local_pkgs_path, '*.rpm')) + os.path.join(self._local_pkgs_path, '*.rpm')) elif os.path.splitext(self._local_pkgs_path)[-1] == '.rpm': return [self._local_pkgs_path] @@ -427,9 +446,9 @@ class BaseImageCreator(object): A sensible default implementation is provided. """ - s = "/dev/root / %s %s 0 0\n" \ - % (self._fstype, - "defaults,noatime" if not self._fsopts else self._fsopts) + s = "/dev/root / %s %s 0 0\n" \ + % (self._fstype, + "defaults,noatime" if not self._fsopts else self._fsopts) s += self._get_fstab_special() return s @@ -457,7 +476,7 @@ class BaseImageCreator(object): value = str(value) name = self.installerfw_prefix + ("PART%d_" % pnum) + prop - return { name : value } + return {name: value} def _get_post_scripts_env(self, in_chroot): """Return an environment dict for %post scripts. @@ -581,10 +600,10 @@ class BaseImageCreator(object): return ret - # # Helpers for subclasses # + def _do_bindmounts(self): """Mount various system directories onto _instroot. @@ -621,7 +640,7 @@ class BaseImageCreator(object): os.chroot(self._instroot) os.chdir("/") - def _mkdtemp(self, prefix = "tmp-"): + def _mkdtemp(self, prefix="tmp-"): """Create a temporary directory. This method may be used by subclasses to create a temporary directory @@ -640,9 +659,9 @@ class BaseImageCreator(object): """ self.__ensure_builddir() - return tempfile.mkdtemp(dir = self.__builddir, prefix = prefix) + return tempfile.mkdtemp(dir=self.__builddir, prefix=prefix) - def _mkstemp(self, prefix = "tmp-"): + def _mkstemp(self, prefix="tmp-"): """Create a temporary file. This method may be used by subclasses to create a temporary file @@ -662,9 +681,9 @@ class BaseImageCreator(object): """ self.__ensure_builddir() - return tempfile.mkstemp(dir = self.__builddir, prefix = prefix) + return tempfile.mkstemp(dir=self.__builddir, prefix=prefix) - def _mktemp(self, prefix = "tmp-"): + def _mktemp(self, prefix="tmp-"): """Create a temporary file. This method simply calls _mkstemp() and closes the returned file @@ -683,10 +702,10 @@ class BaseImageCreator(object): os.close(f) return path - # # Actual implementation # + def __ensure_builddir(self): if not self.__builddir is None: return @@ -695,13 +714,13 @@ class BaseImageCreator(object): self.workdir = os.path.join(self.tmpdir, "build") if not os.path.exists(self.workdir): os.makedirs(self.workdir) - self.__builddir = tempfile.mkdtemp(dir = self.workdir, - prefix = "imgcreate-") + self.__builddir = tempfile.mkdtemp(dir=self.workdir, + prefix="imgcreate-") except OSError as msg: raise CreatorError("Failed create build directory in %s: %s" % (self.tmpdir, msg)) - def get_cachedir(self, cachedir = None): + def get_cachedir(self, cachedir=None): if self.cachedir: return self.cachedir @@ -739,7 +758,7 @@ class BaseImageCreator(object): """Create a minimal /dev so that we don't corrupt the host /dev""" origumask = os.umask(0000) devices = (('null', 1, 3, 0o666), - ('urandom',1, 9, 0o666), + ('urandom', 1, 9, 0o666), ('random', 1, 8, 0o666), ('full', 1, 7, 0o666), ('ptmx', 5, 2, 0o666), @@ -755,7 +774,7 @@ class BaseImageCreator(object): if not os.path.exists(self._instroot + "/dev/" + node): os.mknod(self._instroot + "/dev/" + node, perm | stat.S_IFCHR, - os.makedev(major,minor)) + os.makedev(major, minor)) for (src, dest) in links: if not os.path.exists(self._instroot + dest): @@ -776,7 +795,7 @@ class BaseImageCreator(object): runner.show('umount -l %s' % self.workdir) def cp_tpk(self): - #Add tpk-install option + # Add tpk-install option createopts = configmgr.create if createopts['tpk_install']: path = createopts['tpk_install'] @@ -784,15 +803,16 @@ class BaseImageCreator(object): for f in file_list: sub = os.path.splitext(f)[1] if sub != ".tpk": - raise CreatorError("Not all files in the path: "+path +" is tpk") + raise CreatorError( + "Not all files in the path: "+path + " is tpk") tpk_dir = "/usr/apps/.preload-tpk" fs.makedirs(self._instroot + "/usr/apps") fs.makedirs(self._instroot + tpk_dir) for f in file_list: - shutil.copy(path+"/"+f,self._instroot + tpk_dir) + shutil.copy(path+"/"+f, self._instroot + tpk_dir) - def mount(self, base_on = None, cachedir = None): + def mount(self, base_on=None, cachedir=None): """Setup the target filesystem in preparation for an install. This function sets up the filesystem which the ImageCreator will @@ -831,9 +851,9 @@ class BaseImageCreator(object): fs.makedirs(self._instroot + d) if self.target_arch and self.target_arch.startswith("arm") or \ - self.target_arch == "aarch64": + self.target_arch == "aarch64" or self.target_arch == "riscv64": self.qemu_emulators = misc.setup_qemu_emulator(self._instroot, - self.target_arch) + self.target_arch) self.get_cachedir(cachedir) @@ -843,8 +863,8 @@ class BaseImageCreator(object): ("/proc/sys/fs/binfmt_misc", None), ("/dev/pts", None)]: self.__bindmounts.append( - fs.BindChrootMount( - f, self._instroot, dest)) + fs.BindChrootMount( + f, self._instroot, dest)) self._do_bindmounts() @@ -854,7 +874,7 @@ class BaseImageCreator(object): os.unlink(self._instroot + "/etc/mtab") os.symlink("../proc/mounts", self._instroot + "/etc/mtab") - #self.__write_fstab() + # self.__write_fstab() # get size of available space in 'instroot' fs self._root_fs_avail = misc.get_filesystem_avail(self._instroot) @@ -884,10 +904,10 @@ class BaseImageCreator(object): try: instroot_pdir = os.path.dirname(self._instroot + self._instroot) if os.path.exists(instroot_pdir): - shutil.rmtree(instroot_pdir, ignore_errors = True) + shutil.rmtree(instroot_pdir, ignore_errors=True) yumlibdir = self._instroot + "/var/lib/yum" if os.path.exists(yumlibdir): - shutil.rmtree(yumlibdir, ignore_errors = True) + shutil.rmtree(yumlibdir, ignore_errors=True) except OSError: pass @@ -896,7 +916,6 @@ class BaseImageCreator(object): # reset settings of popup dialog in Ubuntu(s) misc.unhide_loopdev_presentation() - def cleanup(self): """Unmounts the target filesystem and deletes temporary files. @@ -921,7 +940,7 @@ class BaseImageCreator(object): self.unmount() - shutil.rmtree(self.__builddir, ignore_errors = True) + shutil.rmtree(self.__builddir, ignore_errors=True) self.__builddir = None self.__clean_tmpdir() @@ -1052,7 +1071,7 @@ class BaseImageCreator(object): return True else: continue - + return False def showErrorInfo(filepath): @@ -1092,7 +1111,6 @@ class BaseImageCreator(object): if 'debuginfo' in self.install_pkgs: pkg_manager.install_debuginfo = True - for repo in kickstart.get_repos(self.ks, repo_urls, self.ignore_ksrepo): (name, baseurl, mirrorlist, inc, exc, proxy, proxy_username, proxy_password, debuginfo, @@ -1101,8 +1119,8 @@ class BaseImageCreator(object): ssl_verify = get_ssl_verify(ssl_verify) yr = pkg_manager.addRepository(name, baseurl, mirrorlist, proxy, - proxy_username, proxy_password, inc, exc, ssl_verify, - nocache, cost, priority) + proxy_username, proxy_password, inc, exc, ssl_verify, + nocache, cost, priority) if kickstart.exclude_docs(self.ks): rpm.addMacro("_excludedocs", "1") @@ -1116,10 +1134,10 @@ class BaseImageCreator(object): self.__select_packages(pkg_manager) self.__select_groups(pkg_manager) self.__deselect_packages(pkg_manager) - #self.__localinst_packages(pkg_manager) + # self.__localinst_packages(pkg_manager) self.__check_packages(pkg_manager) - BOOT_SAFEGUARD = 256 * 1024 * 1024 # 256M + BOOT_SAFEGUARD = 256 * 1024 * 1024 # 256M checksize = self._root_fs_avail if checksize: checksize -= BOOT_SAFEGUARD @@ -1133,7 +1151,7 @@ class BaseImageCreator(object): pkg_manager.runInstall(checksize) except CreatorError as e: raise - except KeyboardInterrupt: + except KeyboardInterrupt: raise else: self._pkgs_content = pkg_manager.getAllContent() @@ -1146,7 +1164,7 @@ class BaseImageCreator(object): if checkScriptletError(self._instroot + "/tmp/.postscript/error/", "_error"): showErrorInfo(self._instroot + "/tmp/.preload_install_error") raise CreatorError('scriptlet errors occurred') - + # hook post install self.postinstall() @@ -1170,28 +1188,30 @@ class BaseImageCreator(object): for pkg in tpk_pkgs: flag = 0 for tpk_repo in tpk_repoList: - if hasattr(tpk_repo,'baseurl') and tpk_repo.baseurl.startswith("file:"): - tpk_repourl = tpk_repo.baseurl.replace('file:','') + if hasattr(tpk_repo, 'baseurl') and tpk_repo.baseurl.startswith("file:"): + tpk_repourl = tpk_repo.baseurl.replace('file:', '') tpk_repourl = "/%s" % tpk_repourl.lstrip('/') - tpk_pkgpath = tpk_repourl + "/"+ pkg + tpk_pkgpath = tpk_repourl + "/" + pkg if os.path.isfile(tpk_pkgpath): - shutil.copy(tpk_pkgpath,self._instroot + tpk_dir) + shutil.copy(tpk_pkgpath, self._instroot + tpk_dir) flag = 1 break - elif hasattr(tpk_repo,'baseurl'): + elif hasattr(tpk_repo, 'baseurl'): url = tpk_repo.baseurl.join(pkg) filename = self._instroot+tpk_dir+"/"+pkg if tpk_repo.baseurl.startswith("http:"): - import urllib - status = urllib.urlopen(url).code + import urllib.request + import urllib.parse + import urllib.error + status = urllib.request.urlopen(url).code if status == 200: filename = myurlgrab(url.full, filename, None) flag = 1 break elif status == 404 or status == None: continue - #url is ok, then download, url wrong, check other url. - elif tpk_repo.baseurl.startswith("https:") : + # url is ok, then download, url wrong, check other url. + elif tpk_repo.baseurl.startswith("https:"): try: flag = 1 filename = myurlgrab(url.full, filename, None) @@ -1233,15 +1253,15 @@ class BaseImageCreator(object): return env def run_sign_scripts(self): - if kickstart.get_sign_scripts(self.ks)==[]: + if kickstart.get_sign_scripts(self.ks) == []: return msger.info("Running sign scripts ...") if os.path.exists(self._instroot + "/tmp"): shutil.rmtree(self._instroot + "/tmp") - os.mkdir (self._instroot + "/tmp", 0o755) + os.mkdir(self._instroot + "/tmp", 0o755) for s in kickstart.get_sign_scripts(self.ks): - (fd, path) = tempfile.mkstemp(prefix = "ks-runscript-", - dir = self._instroot + "/tmp") + (fd, path) = tempfile.mkstemp(prefix="ks-runscript-", + dir=self._instroot + "/tmp") s.script = s.script.replace("\r", "") os.write(fd, s.script) if s.interp == '/bin/sh' or s.interp == '/bin/bash': @@ -1256,9 +1276,9 @@ class BaseImageCreator(object): try: try: p = subprocess.Popen([s.interp, path], - env = env, - stdout = subprocess.PIPE, - stderr = subprocess.STDOUT) + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) while p.poll() == None: msger.info(p.stdout.readline().strip()) if p.returncode != 0: @@ -1275,10 +1295,10 @@ class BaseImageCreator(object): msger.info("Running post scripts ...") if os.path.exists(self._instroot + "/tmp"): shutil.rmtree(self._instroot + "/tmp") - os.mkdir (self._instroot + "/tmp", 0o755) + os.mkdir(self._instroot + "/tmp", 0o755) for s in kickstart.get_post_scripts(self.ks): - (fd, path) = tempfile.mkstemp(prefix = "ks-postscript-", - dir = self._instroot + "/tmp") + (fd, path) = tempfile.mkstemp(prefix="ks-postscript-", + dir=self._instroot + "/tmp") s.script = s.script.replace("\r", "") os.write(fd, s.script) @@ -1302,12 +1322,12 @@ class BaseImageCreator(object): try: try: p = subprocess.Popen([s.interp, script], - preexec_fn = preexec, - env = env, - stdout = subprocess.PIPE, - stderr = subprocess.STDOUT) + preexec_fn=preexec, + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) while p.poll() == None: - msger.info(p.stdout.readline().strip()) + msger.info(p.stdout.readline().strip()) end_time = time.time() if (end_time - start_time)/60 > configmgr.create['postscripts_maxruntime']: raise CreatorError("Your post script is executed more than %d mins, please check it!" % configmgr.create['postscripts_maxruntime']) @@ -1328,10 +1348,10 @@ class BaseImageCreator(object): fs.makedirs(self._instroot + gpgkeydir) for repo in repodata: if repo["repokey"]: - repokey = gpgkeydir + "/RPM-GPG-KEY-%s" % repo["name"] + repokey = gpgkeydir + "/RPM-GPG-KEY-%s" % repo["name"] shutil.copy(repo["repokey"], self._instroot + repokey) - def configure(self, repodata = None): + def configure(self, repodata=None): """Configure the system image according to the kickstart. This method applies the (e.g. keyboard or network) configuration @@ -1348,7 +1368,7 @@ class BaseImageCreator(object): kickstart.LanguageConfig(self._instroot).apply(ksh.lang) kickstart.KeyboardConfig(self._instroot).apply(ksh.keyboard) kickstart.TimezoneConfig(self._instroot).apply(ksh.timezone) - #kickstart.AuthConfig(self._instroot).apply(ksh.authconfig) + # kickstart.AuthConfig(self._instroot).apply(ksh.authconfig) kickstart.FirewallConfig(self._instroot).apply(ksh.firewall) kickstart.UserConfig(self._instroot).apply(ksh.user) kickstart.RootPasswordConfig(self._instroot).apply(ksh.rootpw) @@ -1358,7 +1378,8 @@ class BaseImageCreator(object): kickstart.RPMMacroConfig(self._instroot).apply(self.ks) kickstart.DesktopConfig(self._instroot).apply(ksh.desktop) self.__save_repo_keys(repodata) - kickstart.MoblinRepoConfig(self._instroot).apply(ksh.repo, repodata, self.repourl) + kickstart.MoblinRepoConfig(self._instroot).apply( + ksh.repo, repodata, self.repourl) except: msger.warning("Failed to apply configuration to image") raise @@ -1375,7 +1396,7 @@ class BaseImageCreator(object): """ if launch: msger.info("Launching shell. Exit to continue.") - subprocess.call(["/bin/bash"], preexec_fn = self._chroot) + subprocess.call(["/bin/bash"], preexec_fn=self._chroot) def do_genchecksum(self, image_name): if not self._genchecksum: @@ -1410,9 +1431,11 @@ class BaseImageCreator(object): cpiocmd = fs.find_binary_path('cpio') if cpiocmd: oldoutdir = os.getcwd() - os.chdir(os.path.join(self._instroot, item['mountpoint'].lstrip('/'))) + os.chdir(os.path.join(self._instroot, + item['mountpoint'].lstrip('/'))) # find . | cpio --create --'format=newc' | gzip > ../ramdisk.img - runner.show('find . | cpio --create %s | gzip > %s' % (item['cpioopts'], tmp_cpio_imgfile)) + runner.show('find . | cpio --create %s | gzip > %s' % + (item['cpioopts'], tmp_cpio_imgfile)) os.chdir(oldoutdir) except OSError as msg: raise CreatorError("Create image by cpio error: %s" % msg) @@ -1421,16 +1444,18 @@ class BaseImageCreator(object): for item in self._instloops: if item['cpioopts']: tmp_cpio = self.__builddir + "/tmp-cpio" - msger.info("Copy cpio image from %s to %s." %(tmp_cpio, self._imgdir)) + msger.info("Copy cpio image from %s to %s." % + (tmp_cpio, self._imgdir)) try: - shutil.copyfile(os.path.join(tmp_cpio, item['name']),os.path.join(self._imgdir, item['name'])) + shutil.copyfile(os.path.join(tmp_cpio, item['name']), os.path.join( + self._imgdir, item['name'])) except IOError: raise CreatorError("Copy cpio image error") os.remove(os.path.join(tmp_cpio, item['name'])) if not os.listdir(tmp_cpio): shutil.rmtree(tmp_cpio, ignore_errors=True) - def package(self, destdir = "."): + def package(self, destdir="."): """Prepares the created image for final delivery. In its simplest form, this method merely copies the install root to the @@ -1455,7 +1480,7 @@ class BaseImageCreator(object): # For image formats with two or multiple image files, it will be # better to put them under a directory if self.image_format in ("raw", "vmdk", "vdi", "nand", "mrstnand"): - destdir = os.path.join(destdir, "%s-%s" \ + destdir = os.path.join(destdir, "%s-%s" % (self.name, self.image_format)) msger.debug("creating destination dir: %s" % destdir) fs.makedirs(destdir) @@ -1482,14 +1507,14 @@ class BaseImageCreator(object): for tool in self._dep_checks: fs.find_binary_path(tool) - def package_output(self, image_format, destdir = ".", package="none"): + def package_output(self, image_format, destdir=".", package="none"): if not package or package == "none": return destdir = os.path.abspath(os.path.expanduser(destdir)) (pkg, comp) = os.path.splitext(package) if comp: - comp=comp.lstrip(".") + comp = comp.lstrip(".") if pkg == "tar": if comp: @@ -1505,11 +1530,11 @@ class BaseImageCreator(object): for file in self.outimage: msger.info("adding %s to %s" % (file, dst)) tar.add(file, - arcname=os.path.join("%s-%s" \ - % (self.name, image_format), - os.path.basename(file))) + arcname=os.path.join("%s-%s" + % (self.name, image_format), + os.path.basename(file))) if os.path.isdir(file): - shutil.rmtree(file, ignore_errors = True) + shutil.rmtree(file, ignore_errors=True) else: os.remove(file) @@ -1571,12 +1596,12 @@ class BaseImageCreator(object): outimages.append("%s/%s" % (destdir, hash_name)) hash_dict = { - 'MD5SUMS' : misc.get_md5sum, - 'SHA1SUMS' : misc.get_sha1sum, - 'SHA256SUMS' : misc.get_sha256sum - } + 'MD5SUMS': misc.get_md5sum, + 'SHA1SUMS': misc.get_sha1sum, + 'SHA256SUMS': misc.get_sha256sum + } - for k, v in hash_dict.items(): + for k, v in list(hash_dict.items()): generate_hashsum(k, v) # Filter out the nonexist file @@ -1611,10 +1636,10 @@ class BaseImageCreator(object): pass def get_pkg_manager(self): - return self.pkgmgr(target_arch = self.target_arch, - instroot = self._instroot, - cachedir = self.cachedir, - strict_mode = self.strict_mode) + return self.pkgmgr(target_arch=self.target_arch, + instroot=self._instroot, + cachedir=self.cachedir, + strict_mode=self.strict_mode) def create_manifest(self): def get_pack_suffix(): diff --git a/mic/imager/fs.py b/mic/imager/fs.py index f2ccb78..0fd6b46 100644 --- a/mic/imager/fs.py +++ b/mic/imager/fs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # diff --git a/mic/imager/loop.py b/mic/imager/loop.py index 18f226c..ed0dced 100644 --- a/mic/imager/loop.py +++ b/mic/imager/loop.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # @@ -52,7 +52,7 @@ def save_mountpoints(fpath, loops, arch = None): for loop in loops: part = doc.createElement("partition") imgroot.appendChild(part) - for (key, val) in loop.items(): + for (key, val) in list(loop.items()): if isinstance(val, fs.Mount): continue part.setAttribute(key, str(val)) @@ -77,7 +77,7 @@ def load_mountpoints(fpath): dom = minidom.parse(rf) imgroot = dom.documentElement for part in imgroot.getElementsByTagName("partition"): - p = dict(part.attributes.items()) + p = dict(list(part.attributes.items())) try: mp = (p['mountpoint'], p['label'], p['name'], @@ -128,7 +128,7 @@ class LoopImageCreator(BaseImageCreator): "ext3") self.__fsopts = kickstart.get_image_fsopts(self.ks, "defaults,noatime") - if self.__fstype in AFTER_MNT_FS.keys(): + if self.__fstype in list(AFTER_MNT_FS.keys()): self.__fstype = "ext4" allloops = [] @@ -137,7 +137,7 @@ class LoopImageCreator(BaseImageCreator): aft_fstype = None if part.fstype == "swap": continue - elif part.fstype in AFTER_MNT_FS.keys(): + elif part.fstype in list(AFTER_MNT_FS.keys()): aft_fstype = part.fstype part.fstype = "ext4" @@ -205,7 +205,7 @@ class LoopImageCreator(BaseImageCreator): names = [] for lo in self._instloops : names.append(lo['name']) - for ro in AFTER_MNT_FS.values(): + for ro in list(AFTER_MNT_FS.values()): names.append(lo['name'].replace('.img',ro)) return list(set(names)) @@ -438,7 +438,7 @@ class LoopImageCreator(BaseImageCreator): for item in self._instloops: imgfile = os.path.join(self._imgdir, item['name']) - if item['aft_fstype'] in AFTER_MNT_FS.keys(): + if item['aft_fstype'] in list(AFTER_MNT_FS.keys()): mountpoint = misc.mkdtemp() ext4img = os.path.join(self._imgdir, item['name']) runner.show('mount -t ext4 %s %s' % (ext4img, mountpoint)) diff --git a/mic/imager/raw.py b/mic/imager/raw.py index 452ba8c..d9ea698 100644 --- a/mic/imager/raw.py +++ b/mic/imager/raw.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # @@ -201,7 +201,7 @@ class RawImageCreator(BaseImageCreator): # Create the disks self.__imgdir = self._mkdtemp() - for disk_name, disk in self.__instloop.disks.items(): + for disk_name, disk in list(self.__instloop.disks.items()): full_path = self._full_path(self.__imgdir, disk_name, "raw") msger.debug("Adding disk %s as %s with size %s bytes" \ % (disk_name, full_path, disk['min_size'])) @@ -247,7 +247,7 @@ class RawImageCreator(BaseImageCreator): BaseImageCreator.mount(self, base_on, cachedir) # Copy the disk loop devices - for name in self.__disks.keys(): + for name in list(self.__disks.keys()): loopdev = self.__disks[name].device copy_devnode(loopdev, self._instroot + loopdev) @@ -279,7 +279,7 @@ class RawImageCreator(BaseImageCreator): if os.path.exists(path): shutil.rmtree(path, ignore_errors=True) - for name in self.__disks.keys(): + for name in list(self.__disks.keys()): if self.__disks[name].device: path = self._instroot + self.__disks[name].device if os.path.exists(path): @@ -381,7 +381,7 @@ class RawImageCreator(BaseImageCreator): cfg.close() def _install_syslinux(self): - for name in self.__disks.keys(): + for name in list(self.__disks.keys()): loopdev = self.__disks[name].device # Set MBR @@ -447,12 +447,12 @@ class RawImageCreator(BaseImageCreator): write meta data """ self._resparse() - self.image_files.update({'disks': self.__disks.keys()}) + self.image_files.update({'disks': list(self.__disks.keys())}) if not (self.compress_image or self.pack_to): for imgfile in os.listdir(self.__imgdir): if imgfile.endswith('.raw'): - for disk in self.__disks.keys(): + for disk in list(self.__disks.keys()): if imgfile.find(disk) != -1: self.image_files.setdefault(disk, {}).update( {'image': imgfile}) @@ -466,7 +466,7 @@ class RawImageCreator(BaseImageCreator): msger.info("Compressing image %s" % imgfile) compressing(imgpath, self.compress_image) if imgfile.endswith('.raw') and not self.pack_to: - for disk in self.__disks.keys(): + for disk in list(self.__disks.keys()): if imgfile.find(disk) != -1: imgname = '%s.%s' % (imgfile, self.compress_image) self.image_files.setdefault(disk, {}).update( @@ -491,8 +491,11 @@ class RawImageCreator(BaseImageCreator): def _write_image_xml(self): imgarch = "i686" - if self.target_arch and self.target_arch.startswith("arm"): - imgarch = "arm" + if self.target_arch: + if self.target_arch.startswith("arm"): + imgarch = "arm" + elif self.target_arch == "riscv64": + imgarch = "riscv64" xml = "<image>\n" name_attributes = "" @@ -513,7 +516,7 @@ class RawImageCreator(BaseImageCreator): xml += " </os>\n" i = 0 - for name in self.__disks.keys(): + for name in list(self.__disks.keys()): full_name = self._full_name(name, self.__disk_format) xml += " <drive disk='%s' target='hd%s'/>\n" \ % (full_name, chr(ord('a') + i)) @@ -531,7 +534,7 @@ class RawImageCreator(BaseImageCreator): xml += " <storage>\n" if self.checksum is True: - for name in self.__disks.keys(): + for name in list(self.__disks.keys()): diskpath = self._full_path(self._outdir, name, \ self.__disk_format) full_name = self._full_name(name, self.__disk_format) @@ -549,7 +552,7 @@ class RawImageCreator(BaseImageCreator): % hashes[1] xml += " </disk>\n" else: - for name in self.__disks.keys(): + for name in list(self.__disks.keys()): full_name = self._full_name(name, self.__disk_format) xml += " <disk file='%s' use='system' format='%s'/>\n" \ % (full_name, self.__disk_format) @@ -580,7 +583,7 @@ class RawImageCreator(BaseImageCreator): msger.info("Generating the map file(s)") - for name in self.__disks.keys(): + for name in list(self.__disks.keys()): image = self._full_path(self.__imgdir, name, self.__disk_format) bmap_file = self._full_path(self._outdir, name, "bmap") self.image_files.setdefault(name, {}).update({'bmap': \ diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index 46bcca2..a5f46ef 100755 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2007 Red Hat, Inc. # Copyright (c) 2009, 2010, 2011 Intel, Inc. @@ -33,7 +33,7 @@ from pykickstart.handlers.control import dataMap from mic import msger from mic.utils import errors, misc, runner, fs_related as fs -from custom_commands import desktop, micrepo, micboot, partition, installerfw +from .custom_commands import desktop, micrepo, micboot, partition, installerfw from mic.utils.safeurl import SafeURL AUTH_URL_PTN = r"(?P<scheme>.*)://(?P<username>.*)(:?P<password>.*)?@(?P<url>.*)" @@ -540,7 +540,7 @@ class NetworkConfig(KickstartConfig): def write_ifcfg(self, network): p = self.path("/etc/sysconfig/network-scripts/ifcfg-" + network.device) - f = file(p, "w+") + f = open(p, "w+") os.chmod(p, 0o644) f.write("DEVICE=%s\n" % network.device) @@ -581,14 +581,14 @@ class NetworkConfig(KickstartConfig): return p = self.path("/etc/sysconfig/network-scripts/keys-" + network.device) - f = file(p, "w+") + f = open(p, "w+") os.chmod(p, 0o600) f.write("KEY=%s\n" % network.wepkey) f.close() def write_sysconfig(self, useipv6, hostname, gateway): path = self.path("/etc/sysconfig/network") - f = file(path, "w+") + f = open(path, "w+") os.chmod(path, 0o644) f.write("NETWORKING=yes\n") @@ -618,7 +618,7 @@ class NetworkConfig(KickstartConfig): localline += "localhost.localdomain localhost" path = self.path("/etc/hosts") - f = file(path, "w+") + f = open(path, "w+") os.chmod(path, 0o644) f.write("127.0.0.1\t\t%s\n" % localline) f.write("::1\t\tlocalhost6.localdomain6 localhost6\n") @@ -629,7 +629,7 @@ class NetworkConfig(KickstartConfig): return path = self.path("/etc/resolv.conf") - f = file(path, "w+") + f = open(path, "w+") os.chmod(path, 0o644) for ns in (nameservers): @@ -795,13 +795,13 @@ def get_repos(ks, repo_urls=None, ignore_ksrepo=False): if repo_urls: if ignore_ksrepo: repos = {} - for name, repo in repo_urls.items(): + for name, repo in list(repo_urls.items()): if 'baseurl' in repo: repo['baseurl'] = SafeURL(repo.get('baseurl'), repo.get('user', None), repo.get('passwd', None)) repos[name] = Repo(**repo) - return repos.values() + return list(repos.values()) TpkRepoType = collections.namedtuple("TpkRepo", "name, baseurl,proxy,proxy_username,proxy_password,ssl_verify") @@ -824,7 +824,7 @@ def get_tpkrepos(ks): if 'name' in tpkrepo: tpkrepos[tpkrepo['name']] = TpkRepo(**tpkrepo) - return tpkrepos.values() + return list(tpkrepos.values()) def convert_method_to_repo(ks): diff --git a/mic/kickstart/custom_commands/__init__.py b/mic/kickstart/custom_commands/__init__.py index 381c917..d8d8ec1 100644 --- a/mic/kickstart/custom_commands/__init__.py +++ b/mic/kickstart/custom_commands/__init__.py @@ -1,7 +1,7 @@ -from desktop import Mic_Desktop -from micrepo import Mic_Repo, Mic_RepoData,Mic_Tpk_Repo, Mic_Tpk_RepoData -from partition import Mic_Partition -from installerfw import Mic_installerfw +from .desktop import Mic_Desktop +from .micrepo import Mic_Repo, Mic_RepoData,Mic_Tpk_Repo, Mic_Tpk_RepoData +from .partition import Mic_Partition +from .installerfw import Mic_installerfw __all__ = ( "Mic_Desktop", diff --git a/mic/kickstart/custom_commands/desktop.py b/mic/kickstart/custom_commands/desktop.py index a2359b3..899483b 100644 --- a/mic/kickstart/custom_commands/desktop.py +++ b/mic/kickstart/custom_commands/desktop.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2008, 2009, 2010 Intel, Inc. # @@ -20,6 +20,8 @@ from pykickstart.base import * from pykickstart.errors import * from pykickstart.options import * +from pykickstart.version import DEVEL +from pykickstart.i18n import _ class Mic_Desktop(KickstartCommand): def __init__(self, writePriority=0, @@ -27,10 +29,8 @@ class Mic_Desktop(KickstartCommand): defaultdm=None, autologinuser=None, session=None): - KickstartCommand.__init__(self, writePriority) - self.__new_version = False self.op = self._getParser() self.defaultdesktop = defaultdesktop @@ -56,41 +56,29 @@ class Mic_Desktop(KickstartCommand): return retval def _getParser(self): - try: - #ingnore this pylit error, the lineno argument exist in olg version. using this way can compate old version. - op = KSOptionParser(lineno=self.lineno) #pylint: disable=unexpected-keyword-arg - except TypeError: - # the latest version has not lineno argument - op = KSOptionParser() - self.__new_version = True - - op.add_option("--defaultdesktop", dest="defaultdesktop", + op = KSOptionParser(prog='desktop', description='desktop', version=DEVEL) + op.add_argument("--defaultdesktop", dest="defaultdesktop", action="store", - type="string", - nargs=1) - op.add_option("--autologinuser", dest="autologinuser", + type=str, + nargs=1, version=DEVEL, help='defaultdesktop') + op.add_argument("--autologinuser", dest="autologinuser", action="store", - type="string", - nargs=1) - op.add_option("--defaultdm", dest="defaultdm", + type=str, + nargs=1, version=DEVEL, help='autologinuser') + op.add_argument("--defaultdm", dest="defaultdm", action="store", - type="string", - nargs=1) - op.add_option("--session", dest="session", + type=str, + nargs=1, version=DEVEL, help='defaultdm') + op.add_argument("--session", dest="session", action="store", - type="string", - nargs=1) + type=str, + nargs=1, version=DEVEL, help='session') return op def parse(self, args): - if self.__new_version: - (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) - else: - (opts, extra) = self.op.parse_args(args=args) - - if extra: - m = ("Unexpected arguments to %(command)s command: %(options)s") \ - % {"command": "desktop", "options": extra} - raise KickstartValueError (formatErrorMsg(self.lineno, msg=m)) - self._setToSelf(self.op, opts) + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + if any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "desktop", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + self.set_to_self(ns) diff --git a/mic/kickstart/custom_commands/installerfw.py b/mic/kickstart/custom_commands/installerfw.py index 01deb76..bce1b8e 100644 --- a/mic/kickstart/custom_commands/installerfw.py +++ b/mic/kickstart/custom_commands/installerfw.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2013 Intel, Inc. # @@ -18,6 +18,9 @@ from pykickstart.base import * from pykickstart.options import * from mic import msger +from pykickstart.version import DEVEL + +from pykickstart.i18n import _ class Mic_installerfw(KickstartCommand): """ This class implements the "installerfw_plugins" KS option. The argument @@ -49,17 +52,20 @@ class Mic_installerfw(KickstartCommand): return retval def _getParser(self): - op = KSOptionParser() + op = KSOptionParser(prog='installerfw', description='installerfw', version=DEVEL) return op def parse(self, args): - (_, extra) = self.op.parse_args(args=args, lineno=self.lineno) + print("NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN") + (ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno) + self.set_to_self(ns) if len(extra) != 1: - msg = "Kickstart command \"%s\" requires one " \ - "argumet - a list of legacy features to disable" % self.currentCmd - raise KickstartValueError (formatErrorMsg(self.lineno, msg = msg)) - - self.features = extra[0].split(",") + raise KickstartParseError(_("Kickstart command %s requires one argument") % "installerfw", lineno=self.lineno) + elif any(arg for arg in extra if arg.startswith("-")): + mapping = {"command": "installerfw", "options": extra} + raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno) + else: + self.features = extra[0].split(",") return self diff --git a/mic/kickstart/custom_commands/micboot.py b/mic/kickstart/custom_commands/micboot.py index 66d1678..d978be8 100644 --- a/mic/kickstart/custom_commands/micboot.py +++ b/mic/kickstart/custom_commands/micboot.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2008, 2009, 2010 Intel, Inc. # @@ -43,7 +43,7 @@ class Mic_Bootloader(F8_Bootloader): def _getParser(self): op = F8_Bootloader._getParser(self) - op.add_option("--menus", dest="menus") - op.add_option("--ptable", dest="ptable", type="string") + op.add_argument("--menus", dest="menus",version=FC4, help='menus') + op.add_argument("--ptable", dest="ptable", type=str, version=FC4, help='ptable') return op diff --git a/mic/kickstart/custom_commands/micrepo.py b/mic/kickstart/custom_commands/micrepo.py index 25cdae9..1327bb2 100644 --- a/mic/kickstart/custom_commands/micrepo.py +++ b/mic/kickstart/custom_commands/micrepo.py @@ -17,7 +17,7 @@ # Temple Place - Suite 330, Boston, MA 02111-1307, USA. from pykickstart.commands.repo import F14_RepoData, F14_Repo - +from pykickstart.version import F14 class Mic_RepoData(F14_RepoData): "Mic customized repo data" @@ -64,20 +64,20 @@ class Mic_Repo(F14_Repo): def _getParser(self): op = F14_Repo._getParser(self) - op.add_option('--user') - op.add_option('--passwd') - op.add_option("--proxyuser") - op.add_option("--proxypasswd") - - op.add_option("--save", action="store_true", default=False) - op.add_option("--debuginfo", action="store_true", default=False) - op.add_option("--source", action="store_true", default=False) - op.add_option("--disable", action="store_true", default=False) - op.add_option("--nocache", action="store_true", default=False) - - op.add_option("--gpgkey") - op.add_option("--priority", type="int") - op.add_option("--ssl_verify", default=None) + op.add_argument('--user', version=F14, help='user') + op.add_argument('--passwd', version=F14, help='passwd') + op.add_argument("--proxyuser", version=F14, help='proxyuser') + op.add_argument("--proxypasswd", version=F14, help='proxypasswd') + + op.add_argument("--save", action="store_true", default=False, version=F14, help='save') + op.add_argument("--debuginfo", action="store_true", default=False, version=F14, help='debuginfo') + op.add_argument("--source", action="store_true", default=False, version=F14, help='source') + op.add_argument("--disable", action="store_true", default=False, version=F14, help='disable') + op.add_argument("--nocache", action="store_true", default=False, version=F14, help='nocache') + + op.add_argument("--gpgkey", version=F14, help='gpgkey') + op.add_argument("--priority", type=int, version=F14, help='priority') + op.add_argument("--ssl_verify", default=None, version=F14, help='ssl+verify') return op diff --git a/mic/kickstart/custom_commands/partition.py b/mic/kickstart/custom_commands/partition.py index b0e9246..250875b 100755 --- a/mic/kickstart/custom_commands/partition.py +++ b/mic/kickstart/custom_commands/partition.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Marko Saukko <marko.saukko@cybercom.com> # @@ -74,25 +74,25 @@ class Mic_Partition(FC4_Partition): op = FC4_Partition._getParser(self) # The alignment value is given in kBytes. e.g., value 8 means that # the partition is aligned to start from 8096 byte boundary. - op.add_option("--align", type="int", action="store", dest="align", - default=None) - op.add_option("--extoptions", type="string", action="store", dest="extopts", - default=None) - op.add_option("--f2fsoptions", type="string", action="store", dest="f2fsopts", - default=None) - op.add_option("--part-type", type="string", action="store", dest="part_type", - default=None) - op.add_option("--uuid", dest="uuid", action="store", type="string") - op.add_option("--exclude-from-image", action="store_true", dest="exclude_image", - default=False) - op.add_option("--vdfsoptions", type="string", action="store", dest="vdfsopts", - default=None) - op.add_option("--squashfsoptions", type="string", action="store", dest="squashfsopts", - default=None) - op.add_option("--squashfsoptions_maxsize", type="string", action="store", dest="squashfsoptions_maxsize", - default=None) - op.add_option("--cpiooptions", type="string", action="store", dest="cpioopts", - default=None) - op.add_option("--no-shrink", action="store_true", dest="no_shrink", default=False) - op.add_option("--init-expand", action="store_true", dest="init_expand", default=False) + op.add_argument("--align", type=int, action="store", dest="align", + default=None, version=FC4, help='align') + op.add_argument("--extoptions", type=str, action="store", dest="extopts", + default=None, version=FC4, help='extoptions') + op.add_argument("--f2fsoptions", type=str, action="store", dest="f2fsopts", + default=None, version=FC4, help='f2fsoptions') + op.add_argument("--part-type", type=str, action="store", dest="part_type", + default=None, version=FC4, help='part-type') + op.add_argument("--uuid", dest="uuid", action="store", type=str, version=FC4, help='uuid') + op.add_argument("--exclude-from-image", action="store_true", dest="exclude_image", + default=False, version=FC4, help='exclude-from-image') + op.add_argument("--vdfsoptions", type=str, action="store", dest="vdfsopts", + default=None, version=FC4, help='vdfsoptions') + op.add_argument("--squashfsoptions", type=str, action="store", dest="squashfsopts", + default=None, version=FC4, help='squashfsoptions') + op.add_argument("--squashfsoptions_maxsize", type=str, action="store", dest="squashfsoptions_maxsize", + default=None, version=FC4, help='squashfsoptions_maxsiz') + op.add_argument("--cpiooptions", type=str, action="store", dest="cpioopts", + default=None, version=FC4, help='cpiooptions') + op.add_argument("--no-shrink", action="store_true", dest="no_shrink", default=False, version=FC4, help='no-shrink') + op.add_argument("--init-expand", action="store_true", dest="init_expand", default=False, version=FC4, help='init-expand') return op diff --git a/mic/msger.py b/mic/msger.py index 31ac9bd..99e4c94 100644 --- a/mic/msger.py +++ b/mic/msger.py @@ -57,7 +57,7 @@ __ALL__ = [ # define the color constants -BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(30, 38) +BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = list(range(30, 38)) # color sequence for tty terminal COLOR_SEQ = "\033[%dm" @@ -319,17 +319,17 @@ class MicLogger(logging.Logger): def select(self, msg, optdict, default=None): """ Log a message in interactive mode """ - if not optdict.keys(): + if not list(optdict.keys()): return default if default is None: - default = optdict.keys()[0] - msg += " [%s](%s): " % ('/'.join(optdict.keys()), default) + default = list(optdict.keys())[0] + msg += " [%s](%s): " % ('/'.join(list(optdict.keys())), default) if not self.interactive or self.logfile: reply = default self.raw(msg + reply) else: while True: - reply = raw_input(msg).strip() + reply = input(msg).strip() if not reply or reply in optdict: break if not reply: @@ -370,7 +370,7 @@ def select(msg, optdict, default=None): def choice(msg, optlist, default=0): """ Give some alternatives to users for answering the question """ - return LOGGER.select(msg, dict(zip(optlist, optlist)), optlist[default]) + return LOGGER.select(msg, dict(list(zip(optlist, optlist))), optlist[default]) def ask(msg, ret=True): """ Ask users to answer 'yes' or 'no' to the question """ @@ -382,7 +382,7 @@ def pause(msg=None): """ Pause for any key """ if msg is None: msg = "press ANY KEY to continue ..." - raw_input(msg) + eval(input(msg)) def set_logfile(logfile, mode='w'): """ Set logfile path to the MIC logger """ @@ -390,7 +390,7 @@ def set_logfile(logfile, mode='w'): def set_loglevel(level): """ Set loglevel to the MIC logger """ - if isinstance(level, basestring): + if isinstance(level, str): level = logging.getLevelName(level) LOGGER.setLevel(level) diff --git a/mic/plugin.py b/mic/plugin.py index e433e25..3cd9bc8 100644 --- a/mic/plugin.py +++ b/mic/plugin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # @@ -62,7 +62,7 @@ class PluginMgr(object): # the value True/False means "loaded" def _load_all(self): - for (pdir, loaded) in self.plugin_dirs.iteritems(): + for (pdir, loaded) in list(self.plugin_dirs.items()): if loaded: continue sys.path.insert(0, pdir) diff --git a/mic/pluginbase.py b/mic/pluginbase.py index db438b6..65351c5 100644 --- a/mic/pluginbase.py +++ b/mic/pluginbase.py @@ -1,8 +1,3 @@ -#!/usr/bin/python -tt -# -# Copyright (c) 2011 Intel, Inc. -# -# This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; version 2 of the License # @@ -20,25 +15,31 @@ import shutil from mic import msger from mic.utils import errors -class _Plugin(object): - class __metaclass__(type): - def __init__(cls, name, bases, attrs): - if not hasattr(cls, 'plugins'): - cls.plugins = {} +class pluginMetaClass(type): + def __new__(cls, name, bases, attrs): + + return type.__new__(cls,name, bases, attrs) + + def __init__(cls, name, bases, attrs): + if not hasattr(cls, 'plugins'): + cls.plugins = {} + elif 'mic_plugin_type' in attrs: + if attrs['mic_plugin_type'] not in cls.plugins: + cls.plugins[attrs['mic_plugin_type']] = {} + + elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs: + cls.plugins[cls.mic_plugin_type][attrs['name']] = cls - elif 'mic_plugin_type' in attrs: - if attrs['mic_plugin_type'] not in cls.plugins: - cls.plugins[attrs['mic_plugin_type']] = {} + def show_plugins(cls): + for cls in cls.plugins[cls.mic_plugin_type]: + print (cls) - elif hasattr(cls, 'mic_plugin_type') and 'name' in attrs: - cls.plugins[cls.mic_plugin_type][attrs['name']] = cls + def get_plugins(cls): + return cls.plugins - def show_plugins(cls): - for cls in cls.plugins[cls.mic_plugin_type]: - print (cls) - def get_plugins(cls): - return cls.plugins +class _Plugin(object, metaclass=pluginMetaClass): + pass class ImagerPlugin(_Plugin): mic_plugin_type = "imager" diff --git a/mic/rt_util.py b/mic/rt_util.py index b79e800..61b9353 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2009, 2010, 2011 Intel, Inc. # @@ -150,8 +150,8 @@ def get_bindmounts(cropts): for ltpkrepo in cropts['localtpkrepos']: binddirs.append(ltpkrepo) - bindlist = map(expath, filter(None, binddirs)) - bindlist += map(os.path.dirname, map(expath, filter(None, bindfiles))) + bindlist = list(map(expath, [_f for _f in binddirs if _f])) + bindlist += list(map(os.path.dirname, list(map(expath, [_f for _f in bindfiles if _f])))) bindlist = sorted(set(bindlist)) bindmounts = ';'.join(bindlist) return bindmounts @@ -196,7 +196,7 @@ def get_mic_libpath(): def sync_mic(bootstrap, binpth = '/usr/bin/mic', libpth='/usr/lib', plugin='/usr/lib/mic/plugins', - pylib = '/usr/lib/python2.7/site-packages', + pylib = '/usr/lib/python3/site-packages', conf = '/etc/mic/mic.conf'): _path = lambda p: os.path.join(bootstrap, p.lstrip('/')) @@ -217,14 +217,14 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', raise errors.BootstrapError("Can't find python site dir in: %s" % bootstrap) - for key, value in micpaths.items(): + for key, value in list(micpaths.items()): try: safecopy(value, _path(eval(key)), False, ["*.pyc", "*.pyo"]) except (OSError, IOError) as err: raise errors.BootstrapError(err) # auto select backend - conf_str = file(_path(conf)).read() + conf_str = open(_path(conf)).read() conf_str = re.sub("pkgmgr\s*=\s*.*", "pkgmgr=auto", conf_str) with open(_path(conf), 'w') as wf: wf.write(conf_str) @@ -232,13 +232,6 @@ def sync_mic(bootstrap, binpth = '/usr/bin/mic', # chmod +x /usr/bin/mic os.chmod(_path(binpth), 0o777) - # correct python interpreter - mic_cont = file(_path(binpth)).read() - mic_cont = "#!/usr/bin/python\n" + mic_cont - with open(_path(binpth), 'w') as wf: - wf.write(mic_cont) - - def safecopy(src, dst, symlinks=False, ignore_ptns=()): if os.path.isdir(src): if os.path.isdir(dst): @@ -302,7 +295,7 @@ def prepare_create(args): pkgmgr = backends[key] break else: - for key in backends.keys(): + for key in list(backends.keys()): if key == creatoropts['pkgmgr']: pkgmgr = backends[key] break @@ -311,6 +304,6 @@ def prepare_create(args): raise errors.CreatorError("Can't find backend: %s, " "available choices: %s" % (creatoropts['pkgmgr'], - ','.join(backends.keys()))) + ','.join(list(backends.keys())))) return creatoropts, pkgmgr, recording_pkgs diff --git a/mic/utils/errors.py b/mic/utils/errors.py index 12ddde6..9e7f133 100644 --- a/mic/utils/errors.py +++ b/mic/utils/errors.py @@ -25,7 +25,7 @@ class CreatorError(Exception): self.msg = msg def __str__(self): - if isinstance(self.msg, unicode): + if isinstance(self.msg, str): self.msg = self.msg.encode('utf-8', 'ignore') else: self.msg = str(self.msg) diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py index 9e2e2c3..f3d16e4 100755 --- a/mic/utils/fs_related.py +++ b/mic/utils/fs_related.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2007, Red Hat, Inc. # Copyright (c) 2009, 2010, 2011 Intel, Inc. @@ -16,7 +16,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from __future__ import with_statement + import os import re import sys @@ -46,11 +46,11 @@ def find_binary_inchroot(binary, chroot): return None def find_binary_path(binary): - if os.environ.has_key("PATH"): + if "PATH" in os.environ: paths = os.environ["PATH"].split(":") else: paths = [] - if os.environ.has_key("HOME"): + if "HOME" in os.environ: paths += [os.environ["HOME"] + "/bin"] paths += ["/usr/local/sbin", "/usr/local/bin", "/usr/sbin", "/usr/bin", "/sbin", "/bin"] @@ -476,7 +476,7 @@ class F2fsDiskMount(DiskMount): found = False """ Need to load f2fs module to mount it """ load_module("f2fs") - for line in open("/proc/filesystems").xreadlines(): + for line in open("/proc/filesystems"): if line.find("f2fs") > -1: found = True break @@ -499,7 +499,7 @@ class F2fsDiskMount(DiskMount): cmdlist = [self.mkfscmd, "-l", self.fslabel] if self.__f2fsopts: - cmdlist.extend(self.__f2fsopts.split()) + cmdlist.extend(self._f2fsopts.split()) cmdlist.extend([self.disk.device]) rc, errout = runner.runtool(cmdlist, catch=2) @@ -541,7 +541,7 @@ class F2fsDiskMount(DiskMount): def mount(self, options = None, init_expand = False): self.__create() if init_expand: - expand_size = long(self.disk.size * 1.5) + expand_size = int(self.disk.size * 1.5) msger.info("Initial partition size expanded : %ld -> %ld" % (self.disk.size, expand_size)) self.__resize_filesystem(expand_size) self.disk.reread_size() @@ -662,7 +662,7 @@ class ExtDiskMount(DiskMount): def mount(self, options = None, init_expand = False): self.__create() if init_expand: - expand_size = long(self.disk.size * 1.5) + expand_size = int(self.disk.size * 1.5) msger.info("Initial partition size expanded : %ld -> %ld" % (self.disk.size, expand_size)) self.__resize_filesystem(expand_size) self.disk.reread_size() @@ -751,7 +751,7 @@ class VfatDiskMount(DiskMount): def mount(self, options = None, init_expand = False): self.__create() if init_expand: - expand_size = long(self.disk.size * 1.5) + expand_size = int(self.disk.size * 1.5) msger.info("Initial partition size expanded : %ld -> %ld" % (self.disk.size, expand_size)) self.__resize_filesystem(expand_size) self.disk.reread_size() @@ -799,7 +799,7 @@ class BtrfsDiskMount(DiskMount): found = False """ Need to load btrfs module to mount it """ load_module("btrfs") - for line in open("/proc/filesystems").xreadlines(): + for line in open("/proc/filesystems"): if line.find("btrfs") > -1: found = True break @@ -859,7 +859,7 @@ class BtrfsDiskMount(DiskMount): def mount(self, options = None, init_expand = False): self.__create() if init_expand: - expand_size = long(self.disk.size * 1.5) + expand_size = int(self.disk.size * 1.5) msger.info("Initial partition size expanded : %ld -> %ld" % (self.disk.size, expand_size)) self.__resize_filesystem(expand_size) self.disk.reread_size() @@ -999,7 +999,7 @@ def create_image_minimizer(path, image, minimal_size): def load_module(module): found = False - for line in open('/proc/modules').xreadlines(): + for line in open('/proc/modules'): if line.startswith("%s " % module): found = True break @@ -1030,8 +1030,7 @@ class LoopDevice(object): return 10 fint = lambda x: x[9:].isdigit() and int(x[9:]) or 0 - maxid = 1 + max(filter(lambda x: x<256, - map(fint, glob.glob("/dev/loop[0-9]*")))) + maxid = 1 + max([x for x in map(fint, glob.glob("/dev/loop[0-9]*")) if x<256]) if maxid < 10: maxid = 10 if maxid >= 256: raise Exception("maxid >= 256") @@ -1081,7 +1080,7 @@ class LoopDevice(object): try: self.cleanup() self.device = None - except MountError as e: + except MountError as e: raise CreatorError("%s" % e) def cleanup(self): diff --git a/mic/utils/gpt_parser.py b/mic/utils/gpt_parser.py index c499e81..5c770eb 100644 --- a/mic/utils/gpt_parser.py +++ b/mic/utils/gpt_parser.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2013 Intel, Inc. # @@ -255,7 +255,7 @@ class GptParser: header = self.read_header(primary) raw_ptable = self._read_raw_ptable(header) - for index in xrange(0, header['entries_cnt']): + for index in range(0, header['entries_cnt']): start = header['entry_size'] * index end = start + header['entry_size'] raw_entry = struct.unpack(_GPT_ENTRY_FORMAT, raw_ptable[start:end]) diff --git a/mic/utils/grabber.py b/mic/utils/grabber.py index a87d5a4..afbd267 100644 --- a/mic/utils/grabber.py +++ b/mic/utils/grabber.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # Copyright (c) 2014 Intel, Inc. # diff --git a/mic/utils/misc.py b/mic/utils/misc.py index a49e20f..2898f1d 100755 --- a/mic/utils/misc.py +++ b/mic/utils/misc.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2010, 2011 Intel Inc. # @@ -15,7 +15,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # Temple Place - Suite 330, Boston, MA 02111-1307, USA. -from __future__ import with_statement + import os import sys import time @@ -27,7 +27,7 @@ import hashlib import subprocess import platform import traceback - +import distro try: import sqlite3 as sqlite @@ -106,12 +106,8 @@ def get_distro(): 'meego', 'moblin', 'tizen') - try: - (dist, ver, id) = platform.linux_distribution( \ - supported_dists = support_dists) - except: - (dist, ver, id) = platform.dist( \ - supported_dists = support_dists) + #platform.linux_distribution was removed in Python 3.8, use distro.linux_distribution(full_distribution_name=False) instead. + (dist, ver, id) = distro.linux_distribution(full_distribution_name=False) return (dist, ver, id) @@ -315,9 +311,9 @@ def _check_mic_chroot(rootdir): def _path(path): return rootdir.rstrip('/') + path - release_files = map(_path, [ "/etc/moblin-release", + release_files = list(map(_path, [ "/etc/moblin-release", "/etc/meego-release", - "/etc/tizen-release"]) + "/etc/tizen-release"])) if not any(map(os.path.exists, release_files)): msger.warning("Dir %s is not a MeeGo/Tizen chroot env" % rootdir) @@ -338,7 +334,7 @@ def selinux_check(arch, fstypes): raise CreatorError("Can't create arm image if selinux is enabled, " "please run 'setenforce 0' to disable selinux") - use_btrfs = filter(lambda typ: typ == 'btrfs', fstypes) + use_btrfs = [typ for typ in fstypes if typ == 'btrfs'] if use_btrfs and selinux_status == "Enforcing": raise CreatorError("Can't create btrfs image if selinux is enabled," " please run 'setenforce 0' to disable selinux") @@ -566,14 +562,14 @@ def get_metadata_from_repos(repos, cachedir): checksums = {} sumtypes = {} - for elm in root.getiterator("%sdata" % ns): + for elm in root.iter("%sdata" % ns): if elm.attrib["type"] == "patterns": filepaths['patterns'] = elm.find("%slocation" % ns).attrib['href'] checksums['patterns'] = elm.find("%sopen-checksum" % ns).text sumtypes['patterns'] = elm.find("%sopen-checksum" % ns).attrib['type'] break - for elm in root.getiterator("%sdata" % ns): + for elm in root.iter("%sdata" % ns): #"group" type has no "open-checksum" filed, remove it. if elm.attrib["type"] == "group_gz": filepaths['comps'] = elm.find("%slocation" % ns).attrib['href'] @@ -582,7 +578,7 @@ def get_metadata_from_repos(repos, cachedir): break primary_type = None - for elm in root.getiterator("%sdata" % ns): + for elm in root.iter("%sdata" % ns): if elm.attrib["type"] in ("primary_db", "primary"): primary_type = elm.attrib["type"] filepaths['primary'] = elm.find("%slocation" % ns).attrib['href'] @@ -639,17 +635,17 @@ def get_rpmver_in_repo(repometadata): ns = ns[0:ns.rindex("}")+1] versionlist = [] - for elm in root.getiterator("%spackage" % ns): + for elm in root.iter("%spackage" % ns): if elm.find("%sname" % ns).text == 'rpm': for node in elm.getchildren(): if node.tag == "%sversion" % ns: versionlist.append(node.attrib['ver']) if versionlist: - return reversed( + return next(reversed( sorted( versionlist, - key = lambda ver: map(int, ver.split('.')))).next() + key = lambda ver: list(map(int, ver.split('.')))))) elif repo["primary"].endswith(".sqlite"): con = sqlite.connect(repo["primary"]) @@ -667,7 +663,7 @@ def get_arch(repometadata): root = xmlparse(repo["primary"]) ns = root.getroot().tag ns = ns[0:ns.rindex("}")+1] - for elm in root.getiterator("%spackage" % ns): + for elm in root.iter("%spackage" % ns): if elm.find("%sarch" % ns).text not in ("noarch", "src"): arch = elm.find("%sarch" % ns).text if arch not in archlist: @@ -682,7 +678,7 @@ def get_arch(repometadata): uniq_arch = [] for i in range(len(archlist)): - if archlist[i] not in rpmmisc.archPolicies.keys(): + if archlist[i] not in list(rpmmisc.archPolicies.keys()): continue need_append = True j = 0 @@ -720,7 +716,7 @@ def get_package(pkg, repometadata, arch = None): root = xmlparse(repo["primary"]) ns = root.getroot().tag ns = ns[0:ns.rindex("}")+1] - for elm in root.getiterator("%spackage" % ns): + for elm in root.iter("%spackage" % ns): if elm.find("%sname" % ns).text == pkg and elm.find("%sarch" % ns).text in arches: if repo["priority"] != None: tmpprior = int(repo["priority"]) @@ -808,7 +804,7 @@ def get_source_name(pkg, repometadata): root = xmlparse(repo["primary"]) ns = root.getroot().tag ns = ns[0:ns.rindex("}")+1] - for elm in root.getiterator("%spackage" % ns): + for elm in root.iter("%spackage" % ns): if elm.find("%sname" % ns).text == pkg_name: if elm.find("%sarch" % ns).text != "src": version = elm.find("%sversion" % ns) @@ -881,7 +877,7 @@ def get_pkglist_in_comps(group, comps): except SyntaxError: raise SyntaxError("%s syntax error." % comps) - for elm in root.getiterator("group"): + for elm in root.iter("group"): id = elm.find("id") name = elm.find("name") if id.text == group or name.text == group: @@ -892,7 +888,7 @@ def get_pkglist_in_comps(group, comps): if not found: return pkglist - for require in elm.getiterator("packagereq"): + for require in elm.iter("packagereq"): if require.tag.endswith("packagereq"): pkgname = require.text if pkgname not in pkglist: @@ -923,6 +919,15 @@ def get_qemu_arm_binary(arch): arm_binary = "qemu-mipsel-static" if not os.path.exists("/usr/bin/%s" % arm_binary): raise CreatorError("Please install a statically-linked %s" % arm_binary) + elif arch == "riscv64": + node = "/proc/sys/fs/binfmt_misc/riscv64" + arm_binary = "qemu-riscv64" + if os.path.exists("/usr/bin/qemu-riscv64") and is_statically_linked("/usr/bin/qemu-riscv64"): + arm_binary = "qemu-riscv64" + elif os.path.exists("/usr/bin/qemu-riscv64-static"): + arm_binary = "qemu-riscv64-static" + else: + raise CreatorError("Please install a statically-linked %s" % arm_binary) else: node = "/proc/sys/fs/binfmt_misc/arm" arm_binary = "qemu-arm" @@ -964,6 +969,8 @@ def setup_qemu_emulator(rootdir, arch): qemu_arm_string = ":aarch64:M::\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xb7:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff:%s:\n" % qemu_emulator elif arch == "mipsel": qemu_arm_string = ":mipsel:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x08\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xfe\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff\\xff:%s:\n" % qemu_emulator + elif arch == "riscv64": + qemu_arm_string = ":riscv64:M::\\x7fELF\\x02\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\xf3\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfe\\xff\\xff\\xff:%s:\n" % qemu_emulator else: qemu_arm_string = ":arm:M::\\x7fELF\\x01\\x01\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x02\\x00\\x28\\x00:\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\x00\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xff\\xfa\\xff\\xff\\xff:%s:\n" % qemu_emulator @@ -1022,7 +1029,7 @@ def SrcpkgsDownload(pkgs, repometadata, instroot, cachedir): for lpkg in lpkgs_path: lpkg_name = get_src_name(os.path.basename(lpkg)) lpkgs_dict[lpkg_name] = lpkg - localpkgs = lpkgs_dict.keys() + localpkgs = list(lpkgs_dict.keys()) cached_count = 0 destdir = instroot+'/usr/src/SRPMS' diff --git a/mic/utils/partitionedfs.py b/mic/utils/partitionedfs.py index cac360b..ddd29ee 100644 --- a/mic/utils/partitionedfs.py +++ b/mic/utils/partitionedfs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2009, 2010, 2011 Intel, Inc. # Copyright (c) 2007, 2008 Red Hat, Inc. @@ -188,7 +188,7 @@ class PartitionedMount(Mount): for n in range(len(self.partitions)): p = self.partitions[n] - if not self.disks.has_key(p['disk_name']): + if p['disk_name'] not in self.disks: raise MountError("No disk %s for partition %s" \ % (p['disk_name'], p['mountpoint'])) @@ -263,7 +263,7 @@ class PartitionedMount(Mount): # Once all the partitions have been laid out, we can calculate the # minimum disk sizes. - for disk_name, d in self.disks.items(): + for disk_name, d in list(self.disks.items()): d['min_size'] = d['offset'] if d['ptable_format'] == 'gpt': # Account for the backup partition table at the end of the disk @@ -308,7 +308,7 @@ class PartitionedMount(Mount): msger.debug("Skipping disk format, because skipformat flag is set.") return - for dev in self.disks.keys(): + for dev in list(self.disks.keys()): d = self.disks[dev] msger.debug("Initializing partition table for %s" % \ (d['disk'].device)) @@ -371,7 +371,7 @@ class PartitionedMount(Mount): # If the partition table format is "gpt", find out PARTUUIDs for all # the partitions. And if users specified custom parition type UUIDs, # set them. - for disk_name, disk in self.disks.items(): + for disk_name, disk in list(self.disks.items()): if disk['ptable_format'] != 'gpt': continue @@ -403,7 +403,7 @@ class PartitionedMount(Mount): """Load it if dm_snapshot isn't loaded. """ load_module("dm_snapshot") - for dev in self.disks.keys(): + for dev in list(self.disks.keys()): d = self.disks[dev] if d['mapped']: continue @@ -492,7 +492,7 @@ class PartitionedMount(Mount): d['mapped'] = True def __unmap_partitions(self): - for dev in self.disks.keys(): + for dev in list(self.disks.keys()): d = self.disks[dev] if not d['mapped']: continue @@ -526,7 +526,7 @@ class PartitionedMount(Mount): Mount.cleanup(self) if self.disks: self.__unmap_partitions() - for dev in self.disks.keys(): + for dev in list(self.disks.keys()): d = self.disks[dev] try: d['disk'].cleanup() @@ -764,7 +764,7 @@ class PartitionedMount(Mount): self.snapshot_created = True def mount(self): - for dev in self.disks.keys(): + for dev in list(self.disks.keys()): d = self.disks[dev] d['disk'].create() diff --git a/mic/utils/proxy.py b/mic/utils/proxy.py index ca884a2..af6ab3e 100644 --- a/mic/utils/proxy.py +++ b/mic/utils/proxy.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2010, 2011 Intel, Inc. # @@ -17,7 +17,7 @@ import os import re -import urlparse +import urllib.parse from mic import msger _my_proxies = {} @@ -27,7 +27,7 @@ _my_noproxy_list = [] def set_proxy_environ(): if not _my_proxies: return - for key in _my_proxies.keys(): + for key in list(_my_proxies.keys()): os.environ[key + "_proxy"] = _my_proxies[key] if not _my_noproxy: return @@ -60,7 +60,7 @@ def _set_proxies(proxy = None, no_proxy = None): # Get proxy settings from environment if not provided if not proxy and not no_proxy: - proxies = os.environ.items() + proxies = list(os.environ.items()) # Remove proxy env variables, urllib2 can't handle them correctly unset_proxy_environ() @@ -163,7 +163,7 @@ def _set_noproxy_list(): _my_noproxy = _my_noproxy_bak def _isnoproxy(url): - host = urlparse.urlparse(url)[1] + host = urllib.parse.urlparse(url)[1] # urlparse.urlparse(url) returns (scheme, host, path, parm, query, frag) if '@' in host: @@ -202,9 +202,9 @@ def get_proxy_for(url): type = url[0:url.index(":")] proxy = None - if _my_proxies.has_key(type): + if type in _my_proxies: proxy = _my_proxies[type] - elif _my_proxies.has_key("http"): + elif "http" in _my_proxies: proxy = _my_proxies["http"] else: proxy = None diff --git a/mic/utils/rpmmisc.py b/mic/utils/rpmmisc.py index a656e40..9d36586 100644 --- a/mic/utils/rpmmisc.py +++ b/mic/utils/rpmmisc.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2008, 2009, 2010, 2011 Intel, Inc. # @@ -323,6 +323,7 @@ archPolicies = { "armv5tel": "armv5tel:armv5l:armv4tl:armv4l:armv3l", "armv5l": "armv5l:armv4tl:armv4l:armv3l", "mipsel": "mipsel", + "riscv64": "riscv64", } # dict mapping arch -> ( multicompat, best personality, biarch personality ) @@ -358,6 +359,8 @@ arches = { "ia64": "noarch", "mipsel": "mipsel", + + "riscv64": "noarch", } def isMultiLibArch(arch=None): @@ -365,29 +368,29 @@ def isMultiLibArch(arch=None): if arch is None: arch = getCanonArch() - if not arches.has_key(arch): # or we could check if it is noarch + if arch not in arches: # or we could check if it is noarch return False - if multilibArches.has_key(arch): + if arch in multilibArches: return True - if multilibArches.has_key(arches[arch]): + if arches[arch] in multilibArches: return True return False def getBaseArch(): myarch = getCanonArch() - if not arches.has_key(myarch): + if myarch not in arches: return myarch if isMultiLibArch(arch=myarch): - if multilibArches.has_key(myarch): + if myarch in multilibArches: return myarch else: return arches[myarch] - if arches.has_key(myarch): + if myarch in arches: basearch = myarch value = arches[basearch] while value != 'noarch': diff --git a/mic/utils/runner.py b/mic/utils/runner.py index cd361a1..bbb57dd 100644 --- a/mic/utils/runner.py +++ b/mic/utils/runner.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # @@ -46,17 +46,14 @@ def runtool(cmdln_or_args, catch=1): cmd = shlex.split(cmdln_or_args)[0] shell = True - if catch != 3: - dev_null = os.open("/dev/null", os.O_WRONLY) - if catch == 0: - sout = dev_null - serr = dev_null + sout = subprocess.DEVNULL + serr = subprocess.DEVNULL elif catch == 1: sout = subprocess.PIPE - serr = dev_null + serr = subprocess.DEVNULL elif catch == 2: - sout = dev_null + sout = subprocess.DEVNULL serr = subprocess.PIPE elif catch == 3: sout = subprocess.PIPE @@ -64,10 +61,10 @@ def runtool(cmdln_or_args, catch=1): try: p = subprocess.Popen(cmdln_or_args, stdout=sout, - stderr=serr, shell=shell) + stderr=serr, shell=shell, universal_newlines=True) (sout, serr) = p.communicate() # combine stdout and stderr, filter None out - out = ''.join(filter(None, [sout, serr])) + out = ''.join([_f for _f in [sout, serr] if _f]) except OSError as e: if e.errno == 2: # [Errno 2] No such file or directory @@ -75,8 +72,7 @@ def runtool(cmdln_or_args, catch=1): else: raise # relay finally: - if catch != 3: - os.close(dev_null) + pass return (p.returncode, out) diff --git a/mic/utils/safeurl.py b/mic/utils/safeurl.py index 0a82f8e..6333618 100644 --- a/mic/utils/safeurl.py +++ b/mic/utils/safeurl.py @@ -18,8 +18,8 @@ This module provides a class SafeURL which can contain url/user/password read from config file, and hide plain user and password when it print to screen """ import os.path -import urllib -from urlparse import urlsplit, urlunsplit +import urllib.request, urllib.parse, urllib.error +from urllib.parse import urlsplit, urlunsplit def join_userpass(href, user, passwd): @@ -28,10 +28,10 @@ def join_userpass(href, user, passwd): return href if passwd: - userpass = '%s:%s' % (urllib.quote(user, safe=''), - urllib.quote(passwd, safe='')) + userpass = '%s:%s' % (urllib.parse.quote(user, safe=''), + urllib.parse.quote(passwd, safe='')) else: - userpass = urllib.quote(user, safe='') + userpass = urllib.parse.quote(user, safe='') parts = urlsplit(href) netloc = '%s@%s' % (userpass, parts[1]) @@ -50,7 +50,7 @@ def split_userpass(href): userpass, netloc = netloc.split('@', 1) if ':' in userpass: - user, passwd = [ urllib.unquote(i) + user, passwd = [ urllib.parse.unquote(i) for i in userpass.split(':', 1) ] else: user, passwd = userpass, None diff --git a/packaging/mic.changes b/packaging/mic.changes index 10ecdd2..55d72de 100644 --- a/packaging/mic.changes +++ b/packaging/mic.changes @@ -1,3 +1,9 @@ +* Thu Apr 13 2023 Biao Wang <biao716.wang@samsung.com> - 0.28.19 + * Fix mic create image error with rpm 4.14 if %prepackages section exists in ks file. + +* Thu Jan 12 2023 Biao Wang <biao716.wang@samsung.com> - 0.28.18 + * Add support for RISC-V arch. + * Thu Aug 10 2022 Biao Wang <biao716.wang@samsung.com> - 0.28.17 * Add block-recommends option to block install recommends packages. diff --git a/packaging/mic.spec b/packaging/mic.spec index 2032f45..4a30006 100755 --- a/packaging/mic.spec +++ b/packaging/mic.spec @@ -1,5 +1,3 @@ -%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} -%{!?python_version: %define python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])")} %define rc_version 0 @@ -9,53 +7,46 @@ Name: mic Summary: Image Creator for Linux Distributions -Version: 0.28.17 -Release: 0 +Version: 0.28.19 +Release: %{?release_prefix}%{?opensuse_bs:<CI_CNT>.<B_CNT>}%{!?opensuse_bs:0} Group: Development/Tools License: GPLv2 BuildArch: noarch URL: http://www.tizen.org Source0: %{name}_%{version}.tar.gz -%if 0%{?tizen_version:1} -Source1001: mic.manifest -%endif -Requires: python >= 2.6 -Requires: python-urlgrabber >= 3.9.0 -Requires: yum -%if 0%{?suse_version} || 0%{?tizen_version:1} -Requires: python-xml -%endif +Requires: python3 >= 3.1 -%if "%{?python_version}" < "2.7" -Requires: python-argparse +#for mic in mic-bootstrap, we don't need the below three dependency packages. +#what is more, thre is no python3.x version currently in tizne platform. +#Requires: python3-urlgrabber >= 3.9.0 +#Requires: yum +#Requires: python3-requests + +#xml module has been exist in python3 path once installing python3 package. +%if 0%{?suse_version} +Requires: python3-xml %endif %if 0%{?tizen_version:1} -Requires: python-rpm +Requires: python3-rpm %else Requires: rpm-python %endif - +Requires: python3-distro Requires: cpio # not neccessary Requires: gzip Requires: bzip2 -%if 0%{?tizen_version:1} -Requires: qemu-linux-user -%else -Requires: qemu-arm-static -%endif - -BuildRequires: python-devel +BuildRequires: python3-devel %if ! 0%{?tizen_version:1} -BuildRequires: python-docutils +BuildRequires: python3-docutils %endif -%if ! 0%{?centos_version} -BuildRequires:fdupes -%endif +Obsoletes: mic2 + +BuildRoot: %{_tmppath}/%{name}_%{version}-build %description The tool mic is used to create and manipulate images for Linux distributions. @@ -66,29 +57,22 @@ an image. %prep %setup -q -n %{name}-%{version} -%if 0%{?tizen_version:1} -cp %{SOURCE1001} . -%endif %build -CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build -%if ! 0%{?tizen_version:1} - make man -%endif +CFLAGS="$RPM_OPT_FLAGS" python3 setup.py build +make man %install -rm -rf %{buildroot} +rm -rf $RPM_BUILD_ROOT %if 0%{?suse_version} -%{__python} setup.py install --root=%{buildroot} --prefix=%{_prefix} +python3 setup.py install --root=$RPM_BUILD_ROOT --prefix=%{_prefix} %else -%{__python} setup.py install --root=%{buildroot} -O1 +python3 setup.py install --root=$RPM_BUILD_ROOT -O1 %endif # install man page mkdir -p %{buildroot}/%{_prefix}/share/man/man1 -%if ! 0%{?tizen_version:1} install -m644 doc/mic.1 %{buildroot}/%{_prefix}/share/man/man1 -%endif # install bash completion install -d -m0755 %{buildroot}/%{_sysconfdir}/bash_completion.d/ @@ -98,27 +82,16 @@ install -Dp -m0755 etc/bash_completion.d/%{name}.sh %{buildroot}/%{_sysconfdir}/ install -d -m0755 %{buildroot}/%{_sysconfdir}/zsh_completion.d/ install -Dp -m0755 etc/zsh_completion.d/_%{name} %{buildroot}/%{_sysconfdir}/zsh_completion.d/ -%if ! 0%{?centos_version} -%fdupes %{buildroot} -%endif - - %files -%if 0%{?tizen_version:1} -%manifest %{name}.manifest -%endif %defattr(-,root,root,-) -%if ! (0%{?suse_version} || 0%{?centos_version}) -%license COPYING -%endif %doc doc/* -%doc README.rst AUTHORS ChangeLog +%doc README.rst AUTHORS COPYING ChangeLog %if ! 0%{?tizen_version:1} %{_mandir}/man1/* %endif %dir %{_sysconfdir}/%{name} %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf -%{python_sitelib}/* +%{python3_sitelib}/* %dir %{_prefix}/lib/%{name} %{_prefix}/lib/%{name}/* %{_bindir}/mic diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index d63c592..51d9786 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2007 Red Hat Inc. # Copyright (c) 2010, 2011 Intel, Inc. @@ -121,7 +121,7 @@ class Yum(BackendPlugin, yum.YumBase): self.strict_mode = strict_mode if self.target_arch: - if not rpmUtils.arch.arches.has_key(self.target_arch): + if self.target_arch not in rpmUtils.arch.arches: rpmUtils.arch.arches["armv7hl"] = "noarch" rpmUtils.arch.arches["armv7tnhl"] = "armv7nhl" rpmUtils.arch.arches["armv7tnhl"] = "armv7thl" @@ -161,7 +161,7 @@ class Yum(BackendPlugin, yum.YumBase): def _writeConf(self, confpath, installroot): conf = Template(YUMCONF_TEMP).safe_substitute(installroot=installroot) - f = file(confpath, "w+") + f = open(confpath, "w+") f.write(conf) f.close() @@ -233,7 +233,7 @@ class Yum(BackendPlugin, yum.YumBase): # we also need to remove from the conditionals # dict so that things don't get pulled back in as a result # of them. yes, this is ugly. conditionals should die. - for req, pkgs in self.tsInfo.conditionals.iteritems(): + for req, pkgs in list(self.tsInfo.conditionals.items()): if x in pkgs: pkgs.remove(x) self.tsInfo.conditionals[req] = pkgs @@ -244,11 +244,11 @@ class Yum(BackendPlugin, yum.YumBase): try: yum.YumBase.selectGroup(self, grp) if include == ksparser.GROUP_REQUIRED: - for p in grp.default_packages.keys(): + for p in list(grp.default_packages.keys()): self.deselectPackage(p) elif include == ksparser.GROUP_ALL: - for p in grp.optional_packages.keys(): + for p in list(grp.optional_packages.keys()): self.selectPackage(p) return None @@ -283,7 +283,7 @@ class Yum(BackendPlugin, yum.YumBase): repo.mirrorlist = _varSubstitute(mirrorlist) conf = yum.config.RepoConf() - for k, v in conf.iteritems(): + for k, v in list(conf.items()): if v or not hasattr(repo, k): repo.setAttribute(k, v) @@ -317,11 +317,7 @@ class Yum(BackendPlugin, yum.YumBase): def installHasFile(self, file): provides_pkg = self.whatProvides(file, None, None) - dlpkgs = map( - lambda x: x.po, - filter( - lambda txmbr: txmbr.ts_state in ("i", "u"), - self.tsInfo.getMembers())) + dlpkgs = [x.po for x in [txmbr for txmbr in self.tsInfo.getMembers() if txmbr.ts_state in ("i", "u")]] for p in dlpkgs: for q in provides_pkg: @@ -342,11 +338,7 @@ class Yum(BackendPlugin, yum.YumBase): raise CreatorError("Failed to build transaction : %s" \ % str.join("\n", resmsg)) - dlpkgs = map( - lambda x: x.po, - filter( - lambda txmbr: txmbr.ts_state in ("i", "u"), - self.tsInfo.getMembers())) + dlpkgs = [x.po for x in [txmbr for txmbr in self.tsInfo.getMembers() if txmbr.ts_state in ("i", "u")]] # record all pkg and the content for pkg in dlpkgs: @@ -358,7 +350,7 @@ class Yum(BackendPlugin, yum.YumBase): } self.__pkgs_content[pkg_long_name] = pkg.files license = pkg.license - if license in self.__pkgs_license.keys(): + if license in list(self.__pkgs_license.keys()): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] @@ -371,12 +363,12 @@ class Yum(BackendPlugin, yum.YumBase): total_count = len(dlpkgs) cached_count = 0 - download_total_size = sum(map(lambda x: int(x.packagesize), dlpkgs)) + download_total_size = sum([int(x.packagesize) for x in dlpkgs]) msger.info("\nChecking packages cached ...") for po in dlpkgs: local = po.localPkg() - repo = filter(lambda r: r.id == po.repoid, self.repos.listEnabled())[0] + repo = list(filter(lambda r: r.id == po.repoid, self.repos.listEnabled()))[0] if repo.nocache and os.path.exists(local): os.unlink(local) if not os.path.exists(local): @@ -483,7 +475,7 @@ class Yum(BackendPlugin, yum.YumBase): if not pkgname: return None - pkg = filter(lambda txmbr: txmbr.po.name == pkgname, self.tsInfo.getMembers()) + pkg = [txmbr for txmbr in self.tsInfo.getMembers() if txmbr.po.name == pkgname] if not pkg: return None return pkg[0].po.filelist diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index afddfd7..7822904 100644 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2010, 2011 Intel, Inc. # @@ -17,7 +17,7 @@ import os import shutil -import urlparse +import urllib.parse import rpm import glob @@ -72,6 +72,7 @@ class Zypp(BackendPlugin): self.Z = None self.ts = None self.ts_pre = None + self.pkgs_bak = [] self.incpkgs = {} self.excpkgs = {} self.pre_pkgs = [] @@ -99,7 +100,9 @@ class Zypp(BackendPlugin): if self.ts_pre: self.ts_pre.closeDB() - self.ts = None + self.ts_pre = None + + self.pkgs_bak = [] self.closeRpmDB() @@ -190,8 +193,8 @@ class Zypp(BackendPlugin): ed1 = p1.edition() ed2 = p2.edition() - (e1, v1, r1) = map(str, [ed1.epoch(), ed1.version(), ed1.release()]) - (e2, v2, r2) = map(str, [ed2.epoch(), ed2.version(), ed2.release()]) + (e1, v1, r1) = list(map(str, [ed1.epoch(), ed1.version(), ed1.release()])) + (e2, v2, r2) = list(map(str, [ed2.epoch(), ed2.version(), ed2.release()])) return rpm.labelCompare((e1, v1, r1), (e2, v2, r2)) found = False @@ -226,10 +229,10 @@ class Zypp(BackendPlugin): cmp=lambda x,y: cmpEVR(zypp.asKindPackage(x), zypp.asKindPackage(y)), reverse=True): item = zypp.asKindPackage(pitem) - if item.name() in self.excpkgs.keys() and \ + if item.name() in list(self.excpkgs.keys()) and \ self.excpkgs[item.name()] == item.repoInfo().name(): continue - if item.name() in self.incpkgs.keys() and \ + if item.name() in list(self.incpkgs.keys()) and \ self.incpkgs[item.name()] != item.repoInfo().name(): continue @@ -254,10 +257,10 @@ class Zypp(BackendPlugin): cmp=lambda x,y: cmpEVR(zypp.asKindPackage(x), zypp.asKindPackage(y)), reverse=True): item = zypp.asKindPackage(pitem) - if item.name() in self.excpkgs.keys() and \ + if item.name() in list(self.excpkgs.keys()) and \ self.excpkgs[item.name()] == item.repoInfo().name(): continue - if item.name() in self.incpkgs.keys() and \ + if item.name() in list(self.incpkgs.keys()) and \ self.incpkgs[item.name()] != item.repoInfo().name(): continue @@ -320,9 +323,7 @@ class Zypp(BackendPlugin): if found: if include == ksparser.GROUP_REQUIRED: - map( - lambda p: self.deselectPackage(p), - grp.default_packages.keys()) + list([self.deselectPackage(p) for p in list(grp.default_packages.keys())]) return None else: @@ -384,7 +385,7 @@ class Zypp(BackendPlugin): if not ssl_verify: baseurl.setQueryParam("ssl_verify", "no") if proxy: - host = urlparse.urlparse(proxy)[1] + host = urllib.parse.urlparse(proxy)[1] # scheme, host, path, parm, query, frag = urlparse.urlparse(proxy) proxyinfo = host.rsplit(":", 1) @@ -516,7 +517,7 @@ class Zypp(BackendPlugin): raise CreatorError('Packages absent in image: %s' % ','.join(self.check_pkgs)) # record all pkg and the content - localpkgs = self.localpkgs.keys() + localpkgs = list(self.localpkgs.keys()) for pkg in dlpkgs: license = '' if pkg.name() in localpkgs: @@ -539,15 +540,15 @@ class Zypp(BackendPlugin): license = pkg.license() - if license in self.__pkgs_license.keys(): + if license in list(self.__pkgs_license.keys()): self.__pkgs_license[license].append(pkg_long_name) else: self.__pkgs_license[license] = [pkg_long_name] total_count = len(dlpkgs) cached_count = 0 - download_total_size = sum(map(lambda x: int(x.downloadSize()), dlpkgs)) - localpkgs = self.localpkgs.keys() + download_total_size = sum([int(x.downloadSize()) for x in dlpkgs]) + localpkgs = list(self.localpkgs.keys()) msger.info("Checking packages cached ...") for po in dlpkgs: @@ -558,7 +559,7 @@ class Zypp(BackendPlugin): local = self.getLocalPkgPath(po) name = str(po.repoInfo().name()) try: - repo = filter(lambda r: r.name == name, self.repos)[0] + repo = list(filter(lambda r: r.name == name, self.repos))[0] except IndexError: repo = None nocache = repo.nocache if repo else False @@ -574,7 +575,7 @@ class Zypp(BackendPlugin): raise CreatorError("No enough space used for downloading.") # record the total size of installed pkgs - install_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) + install_total_size = sum([int(x.installSize()) for x in dlpkgs]) # check needed size before actually download and install # FIXME: for multiple partitions for loop type, check fails @@ -785,7 +786,7 @@ class Zypp(BackendPlugin): % (pkg, hdr['arch'])) def downloadPkgs(self, package_objects, count): - localpkgs = self.localpkgs.keys() + localpkgs = list(self.localpkgs.keys()) progress_obj = TextProgress(count) for po in package_objects: @@ -872,7 +873,7 @@ class Zypp(BackendPlugin): self.ts.setProbFilter(probfilter) self.ts_pre.setProbFilter(probfilter) - localpkgs = self.localpkgs.keys() + localpkgs = list(self.localpkgs.keys()) for po in package_objects: pkgname = po.name() @@ -896,13 +897,17 @@ class Zypp(BackendPlugin): msger.verbose("pre-install package added: %s" % pkgname) self.ts_pre.addInstall(h, rpmpath, 'u') - self.ts.addInstall(h, rpmpath, 'u') + #for rpm4.14 vesion, need to split addInstall for these two transactionSet. + #addInstall for self.ts should be after self.ts_pre done. + self.pkgs_bak.append({"header": h, "rpmpath": rpmpath}) unresolved_dependencies = self.ts.check() if not unresolved_dependencies: if self.pre_pkgs: self.preinstallPkgs() + for pkg_bak in self.pkgs_bak: + self.ts.addInstall(pkg_bak["header"], pkg_bak["rpmpath"], 'u') self.ts.order() cb = rpmmisc.RPMInstallCallback(self.ts) installlogfile = "%s/__catched_stderr.buf" % (self.instroot) @@ -915,6 +920,7 @@ class Zypp(BackendPlugin): msger.disable_logstderr() self.ts.closeDB() self.ts = None + self.pkgs_bak = [] if errors is not None: if len(errors) == 0: @@ -968,7 +974,7 @@ class Zypp(BackendPlugin): proxies = None repoinfo = pobj.repoInfo() reponame = "%s" % repoinfo.name() - repos = filter(lambda r: r.name == reponame, self.repos) + repos = [r for r in self.repos if r.name == reponame] repourl = str(repoinfo.baseUrls()[0]) if repos: @@ -986,7 +992,7 @@ class Zypp(BackendPlugin): name = str(pobj.repoInfo().name()) try: - repo = filter(lambda r: r.name == name, self.repos)[0] + repo = list(filter(lambda r: r.name == name, self.repos))[0] except IndexError: return None @@ -1002,8 +1008,8 @@ class Zypp(BackendPlugin): def cmpEVR(p1, p2): ed1 = p1.edition() ed2 = p2.edition() - (e1, v1, r1) = map(str, [ed1.epoch(), ed1.version(), ed1.release()]) - (e2, v2, r2) = map(str, [ed2.epoch(), ed2.version(), ed2.release()]) + (e1, v1, r1) = list(map(str, [ed1.epoch(), ed1.version(), ed1.release()])) + (e2, v2, r2) = list(map(str, [ed2.epoch(), ed2.version(), ed2.release()])) return rpm.labelCompare((e1, v1, r1), (e2, v2, r2)) if not self.Z: diff --git a/plugins/hook/empty_hook.py b/plugins/hook/empty_hook.py index 397585d..25e5663 100644 --- a/plugins/hook/empty_hook.py +++ b/plugins/hook/empty_hook.py @@ -1,3 +1,3 @@ -#!/usr/bin/python +#!/usr/bin/python3 # TODO: plugin base for hooks diff --git a/plugins/imager/fs_plugin.py b/plugins/imager/fs_plugin.py index 21bb544..d08e3ff 100755..100644 --- a/plugins/imager/fs_plugin.py +++ b/plugins/imager/fs_plugin.py @@ -1,4 +1,4 @@ -#! /usr/bin/python2 +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # diff --git a/plugins/imager/loop_plugin.py b/plugins/imager/loop_plugin.py index f35ffd8..dc0bfd9 100755..100644 --- a/plugins/imager/loop_plugin.py +++ b/plugins/imager/loop_plugin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # diff --git a/plugins/imager/qcow_plugin.py b/plugins/imager/qcow_plugin.py index 2329958..2329958 100755..100644 --- a/plugins/imager/qcow_plugin.py +++ b/plugins/imager/qcow_plugin.py diff --git a/plugins/imager/raw_plugin.py b/plugins/imager/raw_plugin.py index 697a35e..e5b35dc 100755..100644 --- a/plugins/imager/raw_plugin.py +++ b/plugins/imager/raw_plugin.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt # # Copyright (c) 2011 Intel, Inc. # @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2014 Intel, Inc. # diff --git a/tests/pluginmgr_fixtures/backend/yumtest.py b/tests/pluginmgr_fixtures/backend/yumtest.py index 61ba220..8b428b8 100644 --- a/tests/pluginmgr_fixtures/backend/yumtest.py +++ b/tests/pluginmgr_fixtures/backend/yumtest.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt from mic.pluginbase import BackendPlugin class Yum(BackendPlugin): diff --git a/tests/pluginmgr_fixtures/backend/zypptest.py b/tests/pluginmgr_fixtures/backend/zypptest.py index 6ebe1f3..8976ea5 100644 --- a/tests/pluginmgr_fixtures/backend/zypptest.py +++ b/tests/pluginmgr_fixtures/backend/zypptest.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt from mic.pluginbase import BackendPlugin class Zypp(BackendPlugin): diff --git a/tests/pluginmgr_fixtures/imager/fs_test.py b/tests/pluginmgr_fixtures/imager/fs_test.py index ced1ce2..e6c464b 100644 --- a/tests/pluginmgr_fixtures/imager/fs_test.py +++ b/tests/pluginmgr_fixtures/imager/fs_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt from mic.pluginbase import ImagerPlugin class FsPlugin(ImagerPlugin): diff --git a/tests/pluginmgr_fixtures/imager/loop_test.py b/tests/pluginmgr_fixtures/imager/loop_test.py index 5fb515c..ada6025 100644 --- a/tests/pluginmgr_fixtures/imager/loop_test.py +++ b/tests/pluginmgr_fixtures/imager/loop_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python -tt +#!/usr/bin/python3 -tt from mic.pluginbase import ImagerPlugin class LoopPlugin(ImagerPlugin): diff --git a/tests/test_baseimager.py b/tests/test_baseimager.py index 0348b36..a4f66e8 100644 --- a/tests/test_baseimager.py +++ b/tests/test_baseimager.py @@ -1,11 +1,11 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys import rpm import glob import shutil -import StringIO +import io import subprocess import unittest from mic import plugin as pluginmgr @@ -33,7 +33,7 @@ class BaseImgrTest(unittest.TestCase): def setUp(self): self.stdout = sys.stdout self.stream = sys.stdout - msger.STREAM = StringIO.StringIO() + msger.STREAM = io.StringIO() shutil.copy2(KSCONF, KSBAK) with open(KSCONF, 'r') as f: content = f.read() @@ -85,7 +85,7 @@ class BaseImgrTest(unittest.TestCase): creatoropts['pkgmgr'] = backend cfgmgr._ksconf = KSCONF pkgmgr = None - for (key, pcls) in pluginmgr.PluginMgr().get_plugins('backend').iteritems(): + for (key, pcls) in list(pluginmgr.PluginMgr().get_plugins('backend').items()): if key == creatoropts['pkgmgr']: pkgmgr = pcls break diff --git a/tests/test_chroot.py b/tests/test_chroot.py index c98a889..e31c36e 100644 --- a/tests/test_chroot.py +++ b/tests/test_chroot.py @@ -1,10 +1,10 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys import shutil import tarfile -import StringIO +import io import unittest from mic import chroot @@ -24,8 +24,8 @@ class ChrootTest(unittest.TestCase): self.chrootdir = TEST_CHROOT_DIR self.stdout = sys.stdout self.stderr = sys.stderr - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() def tearDown(self): sys.stdout = self.stdout diff --git a/tests/test_configmgr.py b/tests/test_configmgr.py index 08c3744..d97c752 100644 --- a/tests/test_configmgr.py +++ b/tests/test_configmgr.py @@ -1,9 +1,9 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys import shutil -import StringIO +import io import unittest from mic import conf, msger diff --git a/tests/test_pluginmgr.py b/tests/test_pluginmgr.py index aad4b5e..126a574 100644 --- a/tests/test_pluginmgr.py +++ b/tests/test_pluginmgr.py @@ -1,9 +1,9 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys import glob -import StringIO +import io from mic import plugin from mic import pluginbase from mic import msger @@ -23,8 +23,8 @@ class PluginMgrTest(unittest.TestCase): self.plugin.plugin_dir = TEST_PLUGINS_LOC self.stdout = sys.stdout self.stderr = sys.stderr - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() def tearDown(self): sys.stdout = self.stdout @@ -36,7 +36,7 @@ class PluginMgrTest(unittest.TestCase): for pt in plugin.PLUGIN_TYPES: plugindir[os.path.join(TEST_PLUGINS_LOC, pt)] = True #self.assertEqual(self.plugin.plugin_dirs.keys(), plugindir.keys()) - self.assertTrue(any([x in plugindir.keys() for x in self.plugin.plugin_dirs.keys()])) + self.assertTrue(any([x in list(plugindir.keys()) for x in list(self.plugin.plugin_dirs.keys())])) def testNoExistedPluginDir(self): noexistdir = "/xxxx/xxxx/xxxx/xxxx" @@ -49,7 +49,7 @@ class PluginMgrTest(unittest.TestCase): expect = ['zypptest', 'yumtest'] expect.sort() lst = [] - for name, cls in self.plugin.get_plugins('backend').items(): + for name, cls in list(self.plugin.get_plugins('backend').items()): lst.append(name) lst.sort() #self.assertEqual(lst, expect) @@ -59,7 +59,7 @@ class PluginMgrTest(unittest.TestCase): expect = ['fstest', 'looptest'] expect.sort() lst = [] - for name, cls in self.plugin.get_plugins('imager').items(): + for name, cls in list(self.plugin.get_plugins('imager').items()): lst.append(name) lst.sort() #self.assertEqual(lst, expect) diff --git a/tests/test_proxy.py b/tests/test_proxy.py index 9655b58..3c9fe18 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import unittest from mic.utils import proxy diff --git a/tests/test_runner.py b/tests/test_runner.py index 5ed26cd..e481939 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -1,8 +1,8 @@ -#!/usr/bin/python +#!/usr/bin/python3 import os import sys -import StringIO +import io import unittest from mic.utils import runner @@ -14,8 +14,8 @@ class RunnerTest(unittest.TestCase): def setUp(self): self.stdout = sys.stdout self.stderr = sys.stderr - sys.stdout = StringIO.StringIO() - sys.stderr = StringIO.StringIO() + sys.stdout = io.StringIO() + sys.stderr = io.StringIO() def tearDown(self): sys.stdout = self.stdout @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 -tt #Copyright (c) 2011 Intel, Inc. # @@ -38,7 +38,6 @@ from mic.utils import misc, errors from mic.conf import configmgr from mic.plugin import pluginmgr from mic.helpformat import MICHelpFormatter, subparser - @subparser def chroot_parser(parser): @@ -148,7 +147,8 @@ def create_parser(parser): parser.set_defaults(alias="cr") - subparsers = parser.add_subparsers(title='Subcommands', dest='subcommand') + subparsers = parser.add_subparsers(title='Subcommands' ) + subparsers.required = True auto_parser = subparsers.add_parser('auto', parents=[parent_parser], help='auto detect image type from magic header') fs_parser = subparsers.add_parser('fs', parents=[parent_parser], @@ -243,7 +243,7 @@ def main(argv): if key in args: parser_kwargs[key] = args[key] - if args['short'] is '': + if args['short'] == '': parser.add_argument(args['long'], **parser_kwargs) else: parser.add_argument(args['short'], args['long'], **parser_kwargs) @@ -253,10 +253,11 @@ def main(argv): # Create parsers for subcommands subparsers = parser.add_subparsers(title='subcommands') + subparsers.required = True # collect aliases aliases = {} - for name, obj in globals().iteritems(): + for name, obj in globals().items(): if name.endswith('_parser') and callable(obj): aliases[obj(subparsers).get_default('alias')] = name.split('_')[0] @@ -291,9 +292,9 @@ def main(argv): print_version() # Import target module and call 'main' from it + module = __import__("mic.%s" % args.module, fromlist=[args.module]) return module.main(parser, args, argv[1:]) - if __name__ == "__main__": try: |