diff options
author | David Cantrell <dcantrell@redhat.com> | 2009-09-03 16:52:19 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2009-09-04 09:42:44 -1000 |
commit | f3a9063c024396cb04908deda1f9643511108291 (patch) | |
tree | 244390ca38776a397edf69956f0f61f990ede005 /storage | |
parent | b8b14a762b224001c9925807885930dff724447f (diff) | |
download | anaconda-f3a9063c024396cb04908deda1f9643511108291.tar.gz anaconda-f3a9063c024396cb04908deda1f9643511108291.tar.xz anaconda-f3a9063c024396cb04908deda1f9643511108291.zip |
Support a force=True argument on SwapSpace.create()
force=True will tear down the device, unmount if necessary, and then
reformat it.
Diffstat (limited to 'storage')
-rw-r--r-- | 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 392ed11ae..e1dacb09d 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) |