pykickstart package¶
Subpackages¶
- pykickstart.commands package
- Submodules
- pykickstart.commands.authconfig module
- pykickstart.commands.authselect module
- pykickstart.commands.autopart module
- pykickstart.commands.autostep module
- pykickstart.commands.bootc module
- pykickstart.commands.bootloader module
- pykickstart.commands.btrfs module
- pykickstart.commands.cdrom module
- pykickstart.commands.clearpart module
- pykickstart.commands.device module
- pykickstart.commands.deviceprobe module
- pykickstart.commands.displaymode module
- pykickstart.commands.dmraid module
- pykickstart.commands.driverdisk module
- pykickstart.commands.eula module
- pykickstart.commands.fcoe module
- pykickstart.commands.firewall module
- pykickstart.commands.firstboot module
- pykickstart.commands.group module
- pykickstart.commands.harddrive module
- pykickstart.commands.hmc module
- pykickstart.commands.ignoredisk module
- pykickstart.commands.install module
- pykickstart.commands.interactive module
- pykickstart.commands.iscsi module
- pykickstart.commands.iscsiname module
- pykickstart.commands.key module
- pykickstart.commands.keyboard module
- pykickstart.commands.lang module
- pykickstart.commands.langsupport module
- pykickstart.commands.lilocheck module
- pykickstart.commands.liveimg module
- pykickstart.commands.logging module
- pykickstart.commands.logvol module
F12_LogVolF12_LogVolDataF14_LogVolF14_LogVolDataF15_LogVolF15_LogVolDataF17_LogVolF17_LogVolDataF18_LogVolF18_LogVolDataF20_LogVolF20_LogVolDataF21_LogVolF21_LogVolDataF23_LogVolF23_LogVolDataF29_LogVolF29_LogVolDataF9_LogVolF9_LogVolDataFC3_LogVolFC3_LogVolDataFC4_LogVolFC4_LogVolDataRHEL10_LogVolRHEL5_LogVolRHEL5_LogVolDataRHEL6_LogVolRHEL6_LogVolDataRHEL7_LogVolRHEL7_LogVolDataRHEL8_LogVolRHEL8_LogVolDataRHEL9_LogVol
- pykickstart.commands.mediacheck module
- pykickstart.commands.method module
- pykickstart.commands.module module
- pykickstart.commands.monitor module
- pykickstart.commands.mount module
- pykickstart.commands.mouse module
- pykickstart.commands.multipath module
- pykickstart.commands.network module
F16_NetworkF16_NetworkDataF18_NetworkF19_NetworkF19_NetworkDataF20_NetworkF20_NetworkDataF21_NetworkF21_NetworkDataF22_NetworkF22_NetworkDataF24_NetworkF25_NetworkF25_NetworkDataF27_NetworkF27_NetworkDataF39_NetworkF39_NetworkDataF8_NetworkF8_NetworkDataF9_NetworkFC3_NetworkFC3_NetworkDataFC4_NetworkFC4_NetworkDataFC6_NetworkFC6_NetworkDataRHEL10_NetworkRHEL4_NetworkRHEL4_NetworkDataRHEL5_NetworkRHEL6_NetworkRHEL6_NetworkDataRHEL7_NetworkRHEL7_NetworkDataRHEL9_NetworkRHEL9_NetworkDatavalidate_network_interface_name()
- pykickstart.commands.nfs module
- pykickstart.commands.nvdimm module
- pykickstart.commands.ostreecontainer module
- pykickstart.commands.ostreesetup module
- pykickstart.commands.partition module
F11_PartDataF11_PartitionF12_PartDataF12_PartitionF14_PartDataF14_PartitionF17_PartDataF17_PartitionF18_PartDataF18_PartitionF20_PartitionF23_PartDataF23_PartitionF29_PartDataF29_PartitionF34_PartitionF41_PartDataF41_PartitionF9_PartDataF9_PartitionFC3_PartDataFC3_PartitionFC4_PartDataFC4_PartitionRHEL10_PartitionRHEL11_PartitionRHEL5_PartDataRHEL5_PartitionRHEL6_PartDataRHEL6_PartitionRHEL7_PartDataRHEL7_PartitionRHEL8_PartDataRHEL8_PartitionRHEL9_Partition
- pykickstart.commands.raid module
F12_RaidF12_RaidDataF13_RaidF13_RaidDataF14_RaidF14_RaidDataF15_RaidF15_RaidDataF18_RaidF18_RaidDataF19_RaidF20_RaidF23_RaidF23_RaidDataF25_RaidF25_RaidDataF29_RaidF29_RaidDataF43_RaidF7_RaidF7_RaidDataF9_RaidF9_RaidDataFC3_RaidFC3_RaidDataFC4_RaidFC4_RaidDataFC5_RaidFC5_RaidDataRHEL10_RaidRHEL5_RaidRHEL5_RaidDataRHEL6_RaidRHEL6_RaidDataRHEL7_RaidRHEL7_RaidDataRHEL8_RaidRHEL8_RaidDataRHEL9_Raid
- pykickstart.commands.rdp module
- pykickstart.commands.realm module
- pykickstart.commands.reboot module
- pykickstart.commands.repo module
- pykickstart.commands.reqpart module
- pykickstart.commands.rescue module
- pykickstart.commands.rhsm module
- pykickstart.commands.rootpw module
- pykickstart.commands.selinux module
- pykickstart.commands.services module
- pykickstart.commands.skipx module
- pykickstart.commands.snapshot module
- pykickstart.commands.sshkey module
- pykickstart.commands.sshpw module
- pykickstart.commands.syspurpose module
- pykickstart.commands.timesource module
- pykickstart.commands.timezone module
- pykickstart.commands.unsupported_hardware module
- pykickstart.commands.updates module
- pykickstart.commands.upgrade module
- pykickstart.commands.url module
- pykickstart.commands.user module
- pykickstart.commands.vnc module
- pykickstart.commands.volgroup module
- pykickstart.commands.xconfig module
- pykickstart.commands.zerombr module
- pykickstart.commands.zfcp module
- pykickstart.commands.zipl module
- Module contents
- pykickstart.handlers package
- Submodules
- pykickstart.handlers.control module
- pykickstart.handlers.f10 module
- pykickstart.handlers.f11 module
- pykickstart.handlers.f12 module
- pykickstart.handlers.f13 module
- pykickstart.handlers.f14 module
- pykickstart.handlers.f15 module
- pykickstart.handlers.f16 module
- pykickstart.handlers.f17 module
- pykickstart.handlers.f18 module
- pykickstart.handlers.f19 module
- pykickstart.handlers.f20 module
- pykickstart.handlers.f21 module
- pykickstart.handlers.f22 module
- pykickstart.handlers.f23 module
- pykickstart.handlers.f24 module
- pykickstart.handlers.f25 module
- pykickstart.handlers.f26 module
- pykickstart.handlers.f27 module
- pykickstart.handlers.f28 module
- pykickstart.handlers.f29 module
- pykickstart.handlers.f30 module
- pykickstart.handlers.f31 module
- pykickstart.handlers.f32 module
- pykickstart.handlers.f33 module
- pykickstart.handlers.f34 module
- pykickstart.handlers.f35 module
- pykickstart.handlers.f36 module
- pykickstart.handlers.f37 module
- pykickstart.handlers.f38 module
- pykickstart.handlers.f39 module
- pykickstart.handlers.f40 module
- pykickstart.handlers.f41 module
- pykickstart.handlers.f42 module
- pykickstart.handlers.f43 module
- pykickstart.handlers.f44 module
- pykickstart.handlers.f45 module
- pykickstart.handlers.f7 module
- pykickstart.handlers.f8 module
- pykickstart.handlers.f9 module
- pykickstart.handlers.fc3 module
- pykickstart.handlers.fc4 module
- pykickstart.handlers.fc5 module
- pykickstart.handlers.fc6 module
- pykickstart.handlers.rhel10 module
- pykickstart.handlers.rhel11 module
- pykickstart.handlers.rhel3 module
- pykickstart.handlers.rhel4 module
- pykickstart.handlers.rhel5 module
- pykickstart.handlers.rhel6 module
- pykickstart.handlers.rhel7 module
- pykickstart.handlers.rhel8 module
- pykickstart.handlers.rhel9 module
- Module contents
Submodules¶
pykickstart.base module¶
Base classes for creating commands and syntax version object.
This module exports several important base classes:
- BaseData - The base abstract class for all data objects. Data objects
are contained within a BaseHandler object.
- BaseHandler - The base abstract class from which versioned kickstart
handler are derived. Subclasses of BaseHandler hold BaseData and KickstartCommand objects.
- DeprecatedCommand - An abstract subclass of KickstartCommand that should
be further subclassed by users of this module. When 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.
- class pykickstart.base.BaseData(*args, **kwargs)[source]¶
Bases:
KickstartObjectThe base class for all data objects. This is an abstract class.
- deleteRemovedAttrs()[source]¶
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.
- removedAttrs = []¶
- removedKeywords = []¶
- class pykickstart.base.BaseHandler(mapping=None, dataMapping=None, commandUpdates=None, dataUpdates=None, *args, **kwargs)[source]¶
Bases:
KickstartHandlerA 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.
- class pykickstart.base.DeprecatedCommand(writePriority=None, *args, **kwargs)[source]¶
Bases:
KickstartCommandSpecify that a command is deprecated and no longer has any function. Any command that is deprecated should be subclassed from this class, only specifying an __init__ method that calls the superclass’s __init__. This is an abstract class.
- property dataClass¶
Override the attribute of the deprecated command.
- class pykickstart.base.KickstartCommand(writePriority=0, *args, **kwargs)[source]¶
Bases:
KickstartObjectThe base class for all kickstart commands. This is an abstract class.
- conflictingCommands = []¶
- property dataClass¶
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.
- dataList()[source]¶
For commands that can occur multiple times in a single kickstart file (like network, part, etc.), return the list that we should append more data objects to.
- deleteRemovedAttrs()[source]¶
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.
- parse(args)[source]¶
Parse the list of args and set data on the KickstartCommand object. This method must be provided by all subclasses.
- removedAttrs = []¶
- removedKeywords = []¶
- set_to_obj(namespace, obj)[source]¶
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.
- class pykickstart.base.KickstartHandler(*args, **kwargs)[source]¶
Bases:
KickstartObjectAn 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 KickstartHandler subclass and is used to set up the command dict. It is for read-only use.
- dispatcher(args, lineno)[source]¶
Call the appropriate KickstartCommand handler for the current line in the kickstart file. A handler for the current command should be registered, though a handler of None is not an error. Returns the data object returned by KickstartCommand.parse.
args – A list of arguments to the current command lineno – The line number in the file, for error reporting
- resetCommand(cmdName)[source]¶
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.
This method raises a KeyError if cmdName is invalid.
- version = None¶
- class pykickstart.base.RemovedCommand(writePriority=None, *args, **kwargs)[source]¶
Bases:
KickstartCommandSpecify 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.
- property dataClass¶
Override the attribute of the removed command.
pykickstart.constants module¶
pykickstart.errors module¶
Error and warning handling classes and functions.
This module exports several exception classes:
KickstartError - A generic exception class.
KickstartParseError - An exception for errors occurring during parsing.
- 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.
- exception pykickstart.errors.KickstartDeprecationWarning[source]¶
Bases:
KickstartParseWarning,DeprecationWarningA class for warnings occurring during parsing related to using deprecated commands and options.
- exception pykickstart.errors.KickstartError(msg='', lineno=None, formatting=True)[source]¶
Bases:
ExceptionA generic exception class for unspecific error conditions.
- exception pykickstart.errors.KickstartParseError(msg='', lineno=None, formatting=True)[source]¶
Bases:
KickstartErrorAn exception class for errors when processing the input file, such as unknown options, commands, or sections.
- exception pykickstart.errors.KickstartParseWarning[source]¶
Bases:
KickstartWarning,UserWarningA class for warnings occurring during parsing an input file, such as defining duplicate entries and setting removed keywords.
- exception pykickstart.errors.KickstartValueError(msg='', lineno=None, formatting=True)[source]¶
Bases:
KickstartErrorThis exception class is no longer raised by pykickstart but is kept for backwards compatibility.
- exception pykickstart.errors.KickstartVersionError(msg='', lineno=None, formatting=True)[source]¶
Bases:
KickstartErrorAn exception class for errors related to using an incorrect version of kickstart syntax.
- exception pykickstart.errors.KickstartWarning[source]¶
Bases:
WarningA generic warning class for unspecific conditions.
- pykickstart.errors.formatErrorMsg(lineno, msg='')[source]¶
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))
pykickstart.i18n module¶
pykickstart.ko module¶
Base classes for internal pykickstart use.
The module exports the following important classes:
KickstartObject - The base class for all classes in pykickstart
pykickstart.load module¶
- pykickstart.load.is_url(location)¶
- pykickstart.load.load_to_file(location, destination)[source]¶
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
pykickstart.options module¶
Specialized option handling.
This module exports three classes:
- 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.
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.
- class pykickstart.options.ExtendAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶
Bases:
Action
- class pykickstart.options.ExtendConstAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]¶
Bases:
Action
- class pykickstart.options.KSHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]¶
Bases:
RawTextHelpFormatterUsed in generating documentation
- class pykickstart.options.KSOptionParser(*args, **kwargs)[source]¶
Bases:
ArgumentParserA 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.
- add_argument(dest, ..., name=value, ...)[source]¶
- add_argument(option_string, option_string, ..., name=value, ...)
pykickstart.parser module¶
Main kickstart file processing module.
This module exports several important classes:
Certificate - Representation of a single %certificate section.
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.
- class pykickstart.parser.Certificate(*args, **kwargs)[source]¶
Bases:
KickstartObjectA class representing a single %certificate section.
- class pykickstart.parser.Group(name='', include=1)[source]¶
Bases:
KickstartObjectA class representing a single group in the %packages section.
- class pykickstart.parser.KickstartParser(handler, followIncludes=True, errorsAreFatal=True, missingIncludeIsFatal=True, unknownSectionIsFatal=True)[source]¶
Bases:
objectThe 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.
- getSection(s)[source]¶
Return a reference to the requested section (s must start with ‘%’s), or raise KeyError if not found.
- handleCommand(lineno, args)[source]¶
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.
- readKickstartFromString(s, reset=True)[source]¶
Process a kickstart file, provided as the string str.
- class pykickstart.parser.Packages(*args, **kwargs)[source]¶
Bases:
KickstartObject
- class pykickstart.parser.Script(script, *args, **kwargs)[source]¶
Bases:
KickstartObject
- pykickstart.parser.preprocessFromString(s)[source]¶
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.
- pykickstart.parser.preprocessFromStringToString(s)[source]¶
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.
- pykickstart.parser.preprocessKickstart(f)[source]¶
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.
- pykickstart.parser.preprocessKickstartToString(f)[source]¶
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.
pykickstart.sections module¶
This module exports the classes that define a section of a kickstart file. A section is a chunk of the file starting with a %tag and ending with a %end. Examples of sections include %packages, %pre, and %post.
You may use this module to define your own custom sections which will be 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.
- class pykickstart.sections.CertificateSection(*args, **kwargs)[source]¶
Bases:
Section- allLines = True¶
- sectionOpen = '%certificate'¶
- class pykickstart.sections.NullSection(*args, **kwargs)[source]¶
Bases:
SectionThis defines a section that pykickstart will recognize but do nothing with. If the parser runs across a %section that has no object registered, it will raise an error. Sometimes, you may want to simply ignore those sections instead. This class is useful for that purpose.
- allLines = True¶
- finalize()[source]¶
This method is called when the %end tag for a section is seen. It is not required to be provided.
- class pykickstart.sections.OnErrorScriptSection(*args, **kwargs)[source]¶
Bases:
ScriptSection- sectionOpen = '%onerror'¶
- class pykickstart.sections.PackageSection(handler, **kwargs)[source]¶
Bases:
Section- handleHeader(lineno, args)[source]¶
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.
- handleLine(line)[source]¶
This method is called for every line of a section. Take whatever action is appropriate. While this method is not required to be provided, not providing it does not make a whole lot of sense.
Arguments:
line – The complete line, with any trailing newline.
- sectionOpen = '%packages'¶
- class pykickstart.sections.PostScriptSection(*args, **kwargs)[source]¶
Bases:
ScriptSection- sectionOpen = '%post'¶
- class pykickstart.sections.PreInstallScriptSection(*args, **kwargs)[source]¶
Bases:
ScriptSection- sectionOpen = '%pre-install'¶
- class pykickstart.sections.PreScriptSection(*args, **kwargs)[source]¶
Bases:
ScriptSection- sectionOpen = '%pre'¶
- class pykickstart.sections.ScriptSection(*args, **kwargs)[source]¶
Bases:
Section- allLines = True¶
- finalize()[source]¶
This method is called when the %end tag for a section is seen. It is not required to be provided.
- class pykickstart.sections.Section(handler, **kwargs)[source]¶
Bases:
objectThe base class for defining kickstart sections. You are free to subclass this as appropriate.
Class attributes:
- allLines – Does this section require the parser to call handleLine
for every line in the section, even blanks and comments?
- sectionOpen – The string that denotes the start of this section. You
must start your tag with a percent sign.
- timesSeen – This attribute is for informational purposes only. It is
incremented every time handleHeader is called to keep track of the number of times a section of this type is seen.
- allLines = False¶
- finalize()[source]¶
This method is called when the %end tag for a section is seen. It is not required to be provided.
- handleHeader(lineno, args)[source]¶
This method is called when the opening tag for a section is seen. Not all sections will need this method, though all provided with kickstart include one.
Arguments:
- args – A list of all strings passed as arguments to the section
opening tag.
- handleLine(line)[source]¶
This method is called for every line of a section. Take whatever action is appropriate. While this method is not required to be provided, not providing it does not make a whole lot of sense.
Arguments:
line – The complete line, with any trailing newline.
- sectionOpen = ''¶
- property seen¶
This property is given for consistency with KickstartCommand objects only. It simply returns whether timesSeen is non-zero.
- timesSeen = 0¶
- class pykickstart.sections.TracebackScriptSection(*args, **kwargs)[source]¶
Bases:
OnErrorScriptSection- handleHeader(lineno, args)[source]¶
Process the arguments to a %pre/%post/%traceback header for later setting on a Script instance once the end of the script is found. This method may be overridden in a subclass if necessary.
- sectionOpen = '%traceback'¶
pykickstart.version module¶
Methods for working with kickstart versions.
This module defines several symbolic constants that specify kickstart syntax versions. Each version corresponds roughly to one release of Red Hat Linux, Red Hat Enterprise Linux, or Fedora Core as these are where most syntax changes take place.
This module also exports several functions:
- makeVersion - Given a version number, return an instance of the
matching handler class.
- returnClassForVersion - Given a version number, return the matching
handler class. This does not return an instance of that class, however.
- stringToVersion - Convert a string representation of a version number
into the symbolic constant.
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.
- pykickstart.version.makeVersion(version=45000)[source]¶
Return a new instance of the syntax handler for version. version can be either a string or the matching constant. This function is useful for standalone programs which just need to handle a specific version of kickstart syntax (as provided by a command line argument, for example) and need to instantiate the correct object.
- pykickstart.version.returnClassForVersion(version=45000)[source]¶
Return the class of the syntax handler for version. version can be either a string or the matching constant. Raises KickstartVersionError if version does not match anything.
- pykickstart.version.stringToVersion(s)[source]¶
Convert string into one of the provided version constants. Raises KickstartVersionError if string does not match anything.
- pykickstart.version.versionFromFile(f)[source]¶
Given a file or URL, look for a line starting with #version= and return the version number. If no version is found, return the default version (DEVEL on Fedora and RHELx on RHEL).