[blivet:rhel7/master 2/8] Factor hiding a single device into a separate method (#1043763)

mulhern amulhern at redhat.com
Mon Feb 24 17:41:57 UTC 2014


Related: rhbz#1043763

This should be entirely semantics preserving.

Signed-off-by: mulhern <amulhern at 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
-- 
1.8.3.1



More information about the anaconda-patches mailing list