本文整理汇总了Python中pykickstart.options.KSOptionParser类的典型用法代码示例。如果您正苦于以下问题:Python KSOptionParser类的具体用法?Python KSOptionParser怎么用?Python KSOptionParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KSOptionParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _getParser
def _getParser(self):
op = KSOptionParser()
# people would struggle remembering the exact word
op.add_option("--agreed", "--agree", "--accepted", "--accept",
dest="agreed", action="store_true", default=False)
return op
示例2: _getParser
def _getParser(self):
try:
op = KSOptionParser(lineno=self.lineno)
except TypeError:
# the latest version has not lineno argument
op = KSOptionParser()
self.__new_version = True
op.add_option(
"--defaultdesktop",
dest="defaultdesktop",
action="store",
type="string",
nargs=1)
op.add_option(
"--autologinuser",
dest="autologinuser",
action="store",
type="string",
nargs=1)
op.add_option(
"--defaultdm",
dest="defaultdm",
action="store",
type="string",
nargs=1)
op.add_option(
"--session",
dest="session",
action="store",
type="string",
nargs=1)
return op
示例3: _getParser
def _getParser(self):
op = KSOptionParser()
op.add_option("--biospart", dest="biospart")
op.add_option("--partition", dest="partition")
op.add_option("--dir", dest="dir", required=1)
return op
示例4: _getParser
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)
return op
示例5: handle_header
def handle_header(self, lineno, args):
op = KSOptionParser()
op.add_option("--enable", "-e", action="store_true", default=False,
dest="state", help="Enable Cloud Support")
op.add_option("--disable", "-d", action="store_false",
dest="state", help="(Default) Disable Cloud Support")
op.add_option("--allinone", "-a", action="store_true", default=False,
dest="mode", help="Specify the mode of Packstack Installation")
op.add_option("--answer-file", "-f", action="store", type="string",
dest="file", help="Specify URL of answers file")
(options, extra) = op.parse_args(args=args, lineno=lineno)
# Error Handling
if str(options.state) == "True":
self.state = str(options.state)
if options.file and options.mode:
msg = "options --allinone and --answer-file are mutually exclusive"
raise KickstartParseError(msg)
elif options.file:
try:
response = urllib2.urlopen(options.file)
for line in response:
self.lines += line
except urllib2.HTTPError, e:
msg = "Kickstart Error:: HTTPError: " + str(e.code)
raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
except urllib2.URLError, e:
msg = "Kickstart Error: HTTPError: " + str(e.reason)
raise KickstartParseError, formatErrorMsg(lineno, msg=msg)
except:
示例6: handle_header
def handle_header(self, lineno, args):
"""
The handle_header method is called to parse additional arguments in the
%addon section line.
args is a list of all the arguments following the addon ID. For
example, for the line:
%addon org_fedora_hello_world --reverse --arg2="example"
handle_header will be called with args=['--reverse', '--arg2="example"']
:param lineno: the current line number in the kickstart file
:type lineno: int
:param args: the list of arguments from the %addon line
:type args: list
"""
op = KSOptionParser()
op.add_option("--reverse", action="store_true", default=False,
dest="reverse", help="Reverse the display of the addon text")
(opts, extra) = op.parse_args(args=args, lineno=lineno)
# Reject any additional arguments. Since AddonData.handle_header
# rejects any arguments, we can use it to create an error message
# and raise an exception.
if extra:
AddonData.handle_header(self, lineno, args)
# Store the result of the option parsing
self.reverse = opts.reverse
示例7: _getParser
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
示例8: _getParser
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
示例9: _getParser
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
示例10: _getParser
def _getParser(self):
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
示例11: _getParser
def _getParser(self):
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
示例12: _getParser
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)
return op
示例13: _getParser
def _getParser(self):
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
示例14: handleHeader
def handleHeader(self, lineno, args):
"""Process the arguments to the %addon header."""
Section.handleHeader(self, lineno, args)
op = KSOptionParser(version=self.version)
(_opts, extra) = op.parse_args(args=args[1:], lineno=lineno)
self.addon_id = extra[0]
# if the addon is not registered, create dummy placeholder for it
if self.addon_id and not hasattr(self.handler.addons, self.addon_id):
setattr(self.handler.addons, self.addon_id, AddonData(self.addon_id))
示例15: _getParser
def _getParser(self):
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