[blivet:rhel7/master] Force removal of hidden devices (#1078163)
Vratislav Podzimek
vpodzime at redhat.com
Fri Mar 21 09:24:33 UTC 2014
On Thu, 2014-03-20 at 13:23 -0400, mulhern wrote:
> 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)
This looks good to me, but I think that the explanation is too far from
the actual line in the code. A comment right above with at least a
reference to the docstring would be nice.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list