Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian ISP (http://www.linux-archive.org/debian-isp/)
-   -   Add --list= mode to clearpart for explicit list of partitions to remove. (http://www.linux-archive.org/debian-isp/648109-add-list-mode-clearpart-explicit-list-partitions-remove.html)

David Lehman 03-23-2012 03:59 PM

Add --list= mode to clearpart for explicit list of partitions to remove.
 
---
pykickstart/commands/clearpart.py | 26 +++++++++++++++++++++++++-
pykickstart/constants.py | 1 +
pykickstart/handlers/control.py | 2 +-
tests/commands/clearpart.py | 6 ++++++
4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/pykickstart/commands/clearpart.py b/pykickstart/commands/clearpart.py
index a8089fc..f918f5a 100644
--- a/pykickstart/commands/clearpart.py
+++ b/pykickstart/commands/clearpart.py
@@ -1,7 +1,7 @@
#
# Chris Lumens <clumens@redhat.com>
#
-# Copyright 2005, 2006, 2007 Red Hat, Inc.
+# Copyright 2005, 2006, 2007, 2012 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the GNU
@@ -84,3 +84,27 @@ class FC3_ClearPart(KickstartCommand):
(opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
self._setToSelf(self.op, opts)
return self
+
+class F17_ClearPart(FC3_ClearPart):
+ def __init__(self, *args, **kwargs):
+ super(F17_ClearPart, self).__init__(*args, **kwargs)
+ self.devices = kwargs.get("devices", [])
+
+ def __str__(self):
+ s = super(F17_ClearPart, self).__str__()
+ if s and len(self.devices) > 0:
+ s = s.rstrip()
+ s += " --list=" + ",".join(self.devices)
+ s += "
"
+ return s
+
+ def _getParser(self):
+ op = super(F17_ClearPart, self)._getParser()
+ def list_cb (option, opt_str, value, parser):
+ self.type = CLEARPART_TYPE_LIST
+ for d in value.split(','):
+ parser.values.ensure_value(option.dest, []).append(d)
+
+ op.add_option("--list", dest="devices", action="callback",
+ callback=list_cb, nargs=1, type="string")
+ return op
diff --git a/pykickstart/constants.py b/pykickstart/constants.py
index d6fb9d4..d476c49 100644
--- a/pykickstart/constants.py
+++ b/pykickstart/constants.py
@@ -20,6 +20,7 @@
CLEARPART_TYPE_LINUX = 0
CLEARPART_TYPE_ALL = 1
CLEARPART_TYPE_NONE = 2
+CLEARPART_TYPE_LIST = 3

AUTOPART_TYPE_PLAIN = 0
AUTOPART_TYPE_BTRFS = 1
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index 31385f7..db9acc5 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -832,7 +832,7 @@ commandMap = {
"bootloader": bootloader.F17_Bootloader,
"btrfs": btrfs.F17_BTRFS,
"cdrom": method.F14_Method,
- "clearpart": clearpart.FC3_ClearPart,
+ "clearpart": clearpart.F17_ClearPart,
"cmdline": displaymode.FC3_DisplayMode,
"device": device.F8_Device,
"deviceprobe": deviceprobe.FC3_DeviceProbe,
diff --git a/tests/commands/clearpart.py b/tests/commands/clearpart.py
index 4409033..7f441e6 100644
--- a/tests/commands/clearpart.py
+++ b/tests/commands/clearpart.py
@@ -29,5 +29,11 @@ class FC3_TestCase(CommandTest):
# nonsensical parameter test
self.assert_parse_error("clearpart --cheese")

+class F17_TestCase(FC3_TestCase):
+ def runTest(self):
+ FC3_TestCase.runTest(self)
+ self.assert_parse("clearpart --list=sda2,sda3,disk/by-label/foo",
+ "clearpart --list=sda2,sda3,disk/by-label/foo
")
+
if __name__ == "__main__":
unittest.main()
--
1.7.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


All times are GMT. The time now is 05:29 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.