[blivet:rhel7/master 3/8] Factor canceling actions into a separate method (#1043763)
mulhern
amulhern at redhat.com
Mon Feb 24 17:41:58 UTC 2014
Related: rhbz#1043763
This change should be entirely semantics preserving.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/devicetree.py | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 5a0b6a4..ffbe72e 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1816,24 +1816,30 @@ class DeviceTree(object):
if isinstance(device, DASDDevice):
self.dasd.removeDASD(device)
+ def remove_actions(device):
+ """Cancel all actions relating to a single device and remove them
+ from the action list.
+ """
+ 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)
+
if device in self._hidden:
return
for d in self.getChildren(device):
self.hide(d)
- 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)
+ remove_actions(device)
# XXX modifications that do not require actions, like setting a
# mountpoint, will not be reversed here
--
1.8.3.1
More information about the anaconda-patches
mailing list