On Mon, 2014-02-24 at 12:41 -0500, mulhern wrote:
Related: rhbz#1043763
This should be entirely semantics preserving.
This is exactly the sort of thing we do not do on rhel7-branch at this
point in the cycle. Master is another matter.
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devicetree.py | 43 +++++++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 8a79f14..5a0b6a4 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1792,16 +1792,36 @@ class DeviceTree(object):
devicelibs.lvm.lvm_cc_addFilterRejectRegexp(pv.name)
def hide(self, device):
+
+ def hide_device(device):
+ """Hide a single device.
+
+ If the device does not exist, just remove it.
+
+ self.names is not modified, even if a device is removed
+ """
+ log.info("hiding device %s %s (id %d)" % (device.type,
+ device.name,
+ device.id))
+ self._devices.remove(device)
+ for parent in device.parents:
+ parent.removeChild()
+
+ if not device.exists:
+ return
+
+ self._hidden.append(device)
+ lvm.lvm_cc_addFilterRejectRegexp(device.name)
+
+ if isinstance(device, DASDDevice):
+ self.dasd.removeDASD(device)
+
if device in self._hidden:
return
for d in self.getChildren(device):
self.hide(d)
- log.info("hiding device %s %s (id %d)" % (device.type,
- device.name,
- device.id))
-
for action in reversed(self._actions):
if not action.device.dependsOn(device) and action.device != device:
continue
@@ -1817,20 +1837,7 @@ class DeviceTree(object):
# XXX modifications that do not require actions, like setting a
# mountpoint, will not be reversed here
-
- # we're intentionally not modifying self.names here
- self._devices.remove(device)
- for parent in device.parents:
- parent.removeChild()
-
- if not device.exists:
- return
-
- self._hidden.append(device)
- lvm.lvm_cc_addFilterRejectRegexp(device.name)
-
- if isinstance(device, DASDDevice):
- self.dasd.removeDASD(device)
+ hide_device(device)
def unhide(self, device):
# the hidden list should be in leaves-first order