[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[PATCH] Add --root-device to upgrade command
- From: Alexander Todorov <atodorov redhat com>
- To: Discussion list about Kickstart <kickstart-list redhat com>
- Subject: [PATCH] Add --root-device to upgrade command
- Date: Thu, 11 Dec 2008 19:58:20 +0200
Hi all,
the attached patch adds new option to the
upgrade command in kickstart.
upgrade [--root-device=/dev/sda2]
The purpose is to be able to automatically upgrade systems that are dual boot.
Specifying which is the root device makes upgrades more flexible.
More info is available at anaconda-devel-list:
https://www.redhat.com/archives/anaconda-devel-list/2008-December/msg00162.html
Thanks,
Alexander.
pykickstart/commands/upgrade.py | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/pykickstart/commands/upgrade.py b/pykickstart/commands/upgrade.py
index b7dba86..8510fbe 100644
--- a/pykickstart/commands/upgrade.py
+++ b/pykickstart/commands/upgrade.py
@@ -30,20 +30,37 @@ class FC3_Upgrade(KickstartCommand):
def __init__(self, writePriority=0, *args, **kwargs):
KickstartCommand.__init__(self, writePriority, *args, **kwargs)
+ self.op = self._getParser()
+
self.upgrade = kwargs.get("upgrade", None)
+ self.root_device = kwargs.get("root_device", None)
def __str__(self):
if self.upgrade is None:
- return ""
+ retval=""
if self.upgrade:
- return "# Upgrade existing installation\nupgrade\n"
+ if (self.root_device is not None):
+ retval="# Upgrade existing installation\nupgrade --root-device=%s\n" % self.root_device
+ else:
+ retval="# Upgrade existing installation\nupgrade\n"
else:
- return "# Install OS instead of upgrade\ninstall\n"
+ retval="# Install OS instead of upgrade\ninstall\n"
+
+ return retval
+
+ def _getParser(self):
+ op = KSOptionParser(lineno=self.lineno)
+ op.add_option("--root-device", dest="root_device")
+ return op
def parse(self, args):
- if len(args) > 0:
- raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade")
+ (opts, extra) = self.op.parse_args(args=args)
+
+ 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"))
+ else:
+ self.root_device = opts.root_device
if self.currentCmd == "upgrade":
self.upgrade = True
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]