[PATCH 3/4] Support a force=True argument on SwapSpace.create()

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

 



force=True will tear down the device, unmount if necessary, and then
reformat it.
---
 storage/formats/swap.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/storage/formats/swap.py b/storage/formats/swap.py
index 392ed11..e1dacb0 100644
--- a/storage/formats/swap.py
+++ b/storage/formats/swap.py
@@ -132,10 +132,14 @@ class SwapSpace(DeviceFormat):
         """ Create the device. """
         log_method_call(self, device=self.device,
                         type=self.type, status=self.status)
-        if self.exists:
+        force = kwargs.get("force")
+
+        if not force and self.exists:
             raise SwapSpaceError("format already exists")
 
-        if self.status:
+        if force:
+            self.teardown()
+        elif self.status:
             raise SwapSpaceError("device exists and is active")
 
         DeviceFormat.create(self, *args, **kwargs)
-- 
1.6.2.5

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

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux