[blivet:rhel7/master] Force removal of hidden devices (#1078163)

mulhern amulhern at redhat.com
Thu Mar 20 17:23:05 UTC 2014


Resolves: rhbz#1078163

An extended partition is considered a non-leaf device if the parted info
indicates that it contains some logical partitions.

In hide, we need to preserve the parted info, when we are removing existing
devices, in order to reconstruct it later if we unhide the device.

Therefore, in hide, when removing a PartitionDevice, we are not changing the
parted information, so we must force the removal to avoid throwing the
non-leaf exception.

In theory, we only need to force the removal for PartitionDevices that happen
to be extended, but making the force conditional in that way is probably
excessive.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devicetree.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 8ec0852..17ab8dd 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -1842,6 +1842,16 @@ class DeviceTree(object):
            If a device does not exist then it must have been removed by the
            cancelation of all the actions, so it does not need to be removed
            explicitly.
+
+           Most devices are considered leaf devices if they have no children,
+           however, some devices must satisfy more stringent requirements.
+           _removeDevice() will raise an exception if the device it is
+           removing is not a leaf device. hide() guarantees that any
+           device that it removes will have no children, but it does not
+           guarantee that the more stringent requirements will be enforced.
+           Therefore, _removeDevice() is invoked with the force parameter
+           set to True, to skip the isleaf check.
+
         """
         if device in self._hidden:
             return
@@ -1859,7 +1869,7 @@ class DeviceTree(object):
         if not device.exists:
             return
 
-        self._removeDevice(device, moddisk=False)
+        self._removeDevice(device, force=True, moddisk=False)
 
         self._hidden.append(device)
         lvm.lvm_cc_addFilterRejectRegexp(device.name)
-- 
1.8.3.1



More information about the anaconda-patches mailing list