summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py86
1 files changed, 86 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py b/scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py
new file mode 100644
index 0000000000..a8089fcb99
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/clearpart.py
@@ -0,0 +1,86 @@
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#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25class FC3_ClearPart(KickstartCommand):
26 removedKeywords = KickstartCommand.removedKeywords
27 removedAttrs = KickstartCommand.removedAttrs
28
29 def __init__(self, writePriority=120, *args, **kwargs):
30 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
31 self.op = self._getParser()
32
33 self.drives = kwargs.get("drives", [])
34 self.initAll = kwargs.get("initAll", False)
35 self.type = kwargs.get("type", None)
36
37 def __str__(self):
38 retval = KickstartCommand.__str__(self)
39
40 if self.type is None:
41 return retval
42
43 if self.type == CLEARPART_TYPE_NONE:
44 clearstr = "--none"
45 elif self.type == CLEARPART_TYPE_LINUX:
46 clearstr = "--linux"
47 elif self.type == CLEARPART_TYPE_ALL:
48 clearstr = "--all"
49 else:
50 clearstr = ""
51
52 if self.initAll:
53 initstr = "--initlabel"
54 else:
55 initstr = ""
56
57 if len(self.drives) > 0:
58 drivestr = "--drives=" + ",".join(self.drives)
59 else:
60 drivestr = ""
61
62 retval += "# Partition clearing information\nclearpart %s %s %s\n" % (clearstr, initstr, drivestr)
63 return retval
64
65 def _getParser(self):
66 def drive_cb (option, opt_str, value, parser):
67 for d in value.split(','):
68 parser.values.ensure_value(option.dest, []).append(d)
69
70 op = KSOptionParser()
71 op.add_option("--all", dest="type", action="store_const",
72 const=CLEARPART_TYPE_ALL)
73 op.add_option("--drives", dest="drives", action="callback",
74 callback=drive_cb, nargs=1, type="string")
75 op.add_option("--initlabel", dest="initAll", action="store_true",
76 default=False)
77 op.add_option("--linux", dest="type", action="store_const",
78 const=CLEARPART_TYPE_LINUX)
79 op.add_option("--none", dest="type", action="store_const",
80 const=CLEARPART_TYPE_NONE)
81 return op
82
83 def parse(self, args):
84 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
85 self._setToSelf(self.op, opts)
86 return self