diff options
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py')
| -rw-r--r-- | scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py b/scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py new file mode 100644 index 0000000000..a68a82d378 --- /dev/null +++ b/scripts/lib/mic/3rdparty/pykickstart/commands/upgrade.py | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | # | ||
| 2 | # Chris Lumens <clumens@redhat.com> | ||
| 3 | # | ||
| 4 | # Copyright 2005, 2006, 2007 Red Hat, Inc. | ||
| 5 | # | ||
| 6 | # This copyrighted material is made available to anyone wishing to use, modify, | ||
| 7 | # copy, or redistribute it subject to the terms and conditions of the GNU | ||
| 8 | # General Public License v.2. This program is distributed in the hope that it | ||
| 9 | # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the | ||
| 10 | # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 11 | # See the GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License along with | ||
| 14 | # this program; if not, write to the Free Software Foundation, Inc., 51 | ||
| 15 | # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat | ||
| 16 | # trademarks that are incorporated in the source code or documentation are not | ||
| 17 | # subject to the GNU General Public License and may only be used or replicated | ||
| 18 | # with the express permission of Red Hat, Inc. | ||
| 19 | # | ||
| 20 | from pykickstart.base import * | ||
| 21 | from pykickstart.errors import * | ||
| 22 | from pykickstart.options import * | ||
| 23 | |||
| 24 | import gettext | ||
| 25 | _ = lambda x: gettext.ldgettext("pykickstart", x) | ||
| 26 | |||
| 27 | class FC3_Upgrade(KickstartCommand): | ||
| 28 | removedKeywords = KickstartCommand.removedKeywords | ||
| 29 | removedAttrs = KickstartCommand.removedAttrs | ||
| 30 | |||
| 31 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 32 | KickstartCommand.__init__(self, writePriority, *args, **kwargs) | ||
| 33 | self.upgrade = kwargs.get("upgrade", None) | ||
| 34 | self.op = self._getParser() | ||
| 35 | |||
| 36 | def __str__(self): | ||
| 37 | retval = KickstartCommand.__str__(self) | ||
| 38 | |||
| 39 | if self.upgrade is None: | ||
| 40 | return retval | ||
| 41 | |||
| 42 | if self.upgrade: | ||
| 43 | retval += "# Upgrade existing installation\nupgrade\n" | ||
| 44 | else: | ||
| 45 | retval += "# Install OS instead of upgrade\ninstall\n" | ||
| 46 | |||
| 47 | return retval | ||
| 48 | |||
| 49 | def _getParser(self): | ||
| 50 | op = KSOptionParser() | ||
| 51 | return op | ||
| 52 | |||
| 53 | def parse(self, args): | ||
| 54 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 55 | |||
| 56 | if len(extra) > 0: | ||
| 57 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade") | ||
| 58 | |||
| 59 | if self.currentCmd == "upgrade": | ||
| 60 | self.upgrade = True | ||
| 61 | else: | ||
| 62 | self.upgrade = False | ||
| 63 | |||
| 64 | return self | ||
| 65 | |||
| 66 | class F11_Upgrade(FC3_Upgrade): | ||
| 67 | removedKeywords = FC3_Upgrade.removedKeywords | ||
| 68 | removedAttrs = FC3_Upgrade.removedAttrs | ||
| 69 | |||
| 70 | def __init__(self, writePriority=0, *args, **kwargs): | ||
| 71 | FC3_Upgrade.__init__(self, writePriority, *args, **kwargs) | ||
| 72 | |||
| 73 | self.op = self._getParser() | ||
| 74 | self.root_device = kwargs.get("root_device", None) | ||
| 75 | |||
| 76 | def __str__(self): | ||
| 77 | if self.upgrade and (self.root_device is not None): | ||
| 78 | retval = KickstartCommand.__str__(self) | ||
| 79 | retval += "# Upgrade existing installation\nupgrade --root-device=%s\n" % self.root_device | ||
| 80 | else: | ||
| 81 | retval = FC3_Upgrade.__str__(self) | ||
| 82 | |||
| 83 | return retval | ||
| 84 | |||
| 85 | def _getParser(self): | ||
| 86 | op = KSOptionParser() | ||
| 87 | op.add_option("--root-device", dest="root_device") | ||
| 88 | return op | ||
| 89 | |||
| 90 | def parse(self, args): | ||
| 91 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
| 92 | |||
| 93 | if len(extra) > 0: | ||
| 94 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade") | ||
| 95 | |||
| 96 | if (opts.root_device is not None) and (opts.root_device == ""): | ||
| 97 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not accept empty parameter %s") % ("upgrade", "--root-device")) | ||
| 98 | else: | ||
| 99 | self.root_device = opts.root_device | ||
| 100 | |||
| 101 | if self.currentCmd == "upgrade": | ||
| 102 | self.upgrade = True | ||
| 103 | else: | ||
| 104 | self.upgrade = False | ||
| 105 | |||
| 106 | return self | ||
