Re: [PATCH] Add --root-device to upgrade command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Lumens wrote:
Thanks for fetching pykickstart first and following all my recent
stylistic changes (like the kwargs.get stuff)!

However, you don't want to add this option to FC3_Upgrade.  You'll want
to make a new F11_Upgrade object that inherits from FC3_Upgrade, then
modify the appropriate commandMap entry in handlers/control.py to
reference the F11_Upgrade object.  Then the F11_Upgrade class gets the
new option and the FC3_Upgrade class goes untouched.


I don't fully understand the reasoning behind this because the new features are backwards compatible. Anyway I've moved them into a separate class and updated the control map.

I only don't understand what's the purpose of:

removedKeywords = KickstartCommand.removedKeywords
removedAttrs = KickstartCommand.removedAttrs


in FC3_Upgrade (and other classes) and not sure if I need it in the new class.

Btw as pointed in anaconda-devel-list it will be necessary to support UUID and LABEL when specifying the device but the pykickstart bits don't need to change. Just change synopsis to:

upgrade [--root-device=DEV] where

DEV=/dev/sda1               or
DEV=UUID=abcd-fdeb-....     or
DEV=LABEL=/

This is consistent with /etc/fstab and other places and the calling application (Anaconda) will need to take care of finding the correct device.

Regards,
Alexander.
 pykickstart/commands/upgrade.py |   33 +++++++++++++++++++++++++++++++++
 pykickstart/handlers/control.py |    4 ++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/pykickstart/commands/upgrade.py b/pykickstart/commands/upgrade.py
index b7dba86..5fbf93a 100644
--- a/pykickstart/commands/upgrade.py
+++ b/pykickstart/commands/upgrade.py
@@ -49,3 +49,36 @@ class FC3_Upgrade(KickstartCommand):
            self.upgrade = True
         else:
            self.upgrade = False
+
+class F11_Upgrade(FC3_Upgrade):
+    def __init__(self, writePriority=0, *args, **kwargs):
+        FC3_Upgrade.__init__(self, writePriority, *args, **kwargs)
+
+        self.op = self._getParser()
+        self.root_device = kwargs.get("root_device", None)
+
+    def __str__(self):
+        if self.upgrade and (self.root_device is not None):
+            retval="# Upgrade existing installation\nupgrade --root-device=%s\n" % self.root_device
+        else:
+            retval=FC3_Upgrade.__str(self)__
+
+        return retval
+
+    def _getParser(self):
+        op = KSOptionParser(lineno=self.lineno)
+        op.add_option("--root-device", dest="root_device")
+        return op
+
+    def parse(self, args):
+        (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
+        else:
+           self.upgrade = False
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index 459d3a8..961176a 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -488,7 +488,7 @@ commandMap = {
         "halt": reboot.FC6_Reboot,
         "harddrive": method.FC6_Method,
         "ignoredisk": ignoredisk.F8_IgnoreDisk,
-        "install": upgrade.FC3_Upgrade,
+        "install": upgrade.F11_Upgrade,
         "interactive": interactive.FC3_Interactive,
         "iscsi": iscsi.F10_Iscsi,
         "iscsiname": iscsiname.FC6_IscsiName,
@@ -517,7 +517,7 @@ commandMap = {
         "text": displaymode.FC3_DisplayMode,
         "timezone": timezone.FC6_Timezone,
         "updates": updates.F7_Updates,
-        "upgrade": upgrade.FC3_Upgrade,
+        "upgrade": upgrade.F11_Upgrade,
         "url": method.FC6_Method,
         "user": user.F8_User,
         "vnc": vnc.F9_Vnc,
_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list

[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux