On Tue, 2014-02-25 at 12:44 -0500, mulhern wrote:
Related: rhbz#1043763
If a device is hidden these things now happen:
1) All actions are canceled. Note that canceling a device create action will
cause the device to be removed. Note that it should be the case that no
existing device has a device create action associated with it.
Previously only a subset of actions were canceled.
2) The device being hidden is removed using _removeDevice. An additional
post-processing step adds the name of the device back into self.names.
Other steps associated with hiding the device remain the same.
Note: The device exists if and only if it has not been removed by the
cancellation of all actions. So, if it does not exist, then the method
is done after action cancelation. However, if the device does exist, it should
be removed, special hiding actions should be done, and its name should be
inserted back into self.names.
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devicetree.py | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 8a79f14..1b3b750 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1795,43 +1795,27 @@ class DeviceTree(object):
if device in self._hidden:
return
- for d in self.getChildren(device):
- self.hide(d)
-
Don't we still need to do this, although probably after canceling all of
the actions? Consider calling hide() on a disk with several preexisting
devices on it. I don't think those devices will get hidden with this
change. The rest looks good.
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
-
- log.debug("cancelling action: %s" % action)
- try:
- action.cancel()
- except Exception:
- log.warning("failed to cancel action while hiding %s: %s"
- % (device.name, action))
- finally:
- self._actions.remove(action)
-
- # 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()
+ self.cancelAction(action)
if not device.exists:
return
+ self._removeDevice(device)
+
self._hidden.append(device)
lvm.lvm_cc_addFilterRejectRegexp(device.name)
if isinstance(device, DASDDevice):
self.dasd.removeDASD(device)
+ if device.name not in self.names:
+ self.names.append(device.name)
+
def unhide(self, device):
# the hidden list should be in leaves-first order
for hidden in reversed(self._hidden):