Add new RHEL7 logvol objects to master
[pykickstart.git] / pykickstart / commands / upgrade.py
blobeff9e8dfe6505729b2d3fd41a93a01043661345d
2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007 Red Hat, Inc.
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.
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.
20 from pykickstart.base import DeprecatedCommand, KickstartCommand
21 from pykickstart.errors import KickstartValueError, formatErrorMsg
22 from pykickstart.options import KSOptionParser
24 import gettext
25 _ = lambda x: gettext.ldgettext("pykickstart", x)
27 class FC3_Upgrade(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
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()
36 def __str__(self):
37 retval = KickstartCommand.__str__(self)
39 if self.upgrade is None:
40 return retval
42 if self.upgrade:
43 retval += "# Upgrade existing installation\nupgrade\n"
44 else:
45 retval += "# Install OS instead of upgrade\ninstall\n"
47 return retval
49 def _getParser(self):
50 op = KSOptionParser()
51 return op
53 def parse(self, args):
54 (_opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
56 if len(extra) > 0:
57 raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade"))
59 if self.currentCmd == "upgrade":
60 self.upgrade = True
61 else:
62 self.upgrade = False
64 return self
66 class F11_Upgrade(FC3_Upgrade):
67 removedKeywords = FC3_Upgrade.removedKeywords
68 removedAttrs = FC3_Upgrade.removedAttrs
70 def __init__(self, writePriority=0, *args, **kwargs):
71 FC3_Upgrade.__init__(self, writePriority, *args, **kwargs)
73 self.op = self._getParser()
74 self.root_device = kwargs.get("root_device", None)
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)
83 return retval
85 def _getParser(self):
86 op = KSOptionParser()
87 op.add_option("--root-device", dest="root_device")
88 return op
90 def parse(self, args):
91 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
93 if len(extra) > 0:
94 raise KickstartValueError(formatErrorMsg(self.lineno, msg=_("Kickstart command %s does not take any arguments") % "upgrade"))
96 if 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
101 if self.currentCmd == "upgrade":
102 self.upgrade = True
103 else:
104 self.upgrade = False
106 return self
108 class F20_Upgrade(DeprecatedCommand):
109 def __init__(self):
110 DeprecatedCommand.__init__(self)