From: David Lehman <dlehman(a)redhat.com>
With this flag the method will recursively clear a device without
removing it. This is the same behavior it has always had for disks.
---
blivet/devicetree.py | 5 +++--
blivet/populator/populator.py | 7 ++-----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 1d73b69..e692330 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -204,11 +204,12 @@ def _remove_device(self, dev, force=None, modparent=True):
dev.name,
dev.id)
- def recursive_remove(self, device, actions=True):
+ def recursive_remove(self, device, actions=True, remove_device=True):
""" Remove a device after removing its dependent devices.
:param :class:`~.devices.StorageDevice` device: the device to remove
:keyword bool actions: whether to schedule actions for the removal
+ :keyword bool remove_device: whether to remove the root device
If the device is not a leaf, all of its dependents are removed
recursively until it is a leaf device. At that point the device is
@@ -249,7 +250,7 @@ def recursive_remove(self, device, actions=True):
else:
device.format = None
- if not device.is_disk:
+ if remove_device and not device.is_disk:
if actions:
self.actions.add(ActionDestroyDevice(device))
else:
diff --git a/blivet/populator/populator.py b/blivet/populator/populator.py
index efea071..4718fe8 100644
--- a/blivet/populator/populator.py
+++ b/blivet/populator/populator.py
@@ -236,13 +236,10 @@ def _clear_new_multipath_member(self, device):
return
# newly added device (eg iSCSI) could make this one a multipath member
- if device.format and device.format.type != "multipath_member":
+ if device.format.type != "multipath_member":
log.debug("%s newly detected as multipath member, dropping old format
and removing kids", device.name)
# remove children from tree so that we don't stumble upon them later
- for child in device.children:
- self.recursive_remove(child, actions=False)
-
- device.format = None
+ self.recursive_remove(device, actions=False, remove_device=False)
def _mark_readonly_device(self, info, device):
# If this device is read-only, mark it as such now.
--
To view this commit on github, visit
https://github.com/rhinstaller/blivet/commit/70d920b387af42484858ed70d507...