From f8f07743bf69e44dd3156524730a4faeb7d0193a Mon Sep 17 00:00:00 2001 From: David Lehman Date: Fri, 8 Nov 2019 14:13:59 -0500 Subject: [PATCH] Don't raise safe_mode failures when packages_only is True. --- library/blivet.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/blivet.py b/library/blivet.py index ed061530..2c1c7abb 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -222,7 +222,8 @@ def _reformat(self): if self._device.format.type == fmt.type: return - if safe_mode and (self._device.format.type is not None or self._device.format.name != get_format(None).name): + if safe_mode and (self._device.format.type is not None or self._device.format.name != get_format(None).name) and \ + not packages_only: raise BlivetAnsibleError("cannot remove existing formatting on volume '%s' in safe mode" % self._volume['name']) if self._device.format.status and not packages_only: @@ -452,7 +453,7 @@ def _create_members(self): members = list() for disk in self._disks: if not disk.isleaf or disk.format.type is not None: - if safe_mode: + if safe_mode and not packages_only: raise BlivetAnsibleError("cannot remove existing formatting and/or devices on disk '%s' (pool '%s') in safe mode" % (disk.name, self._pool['name'])) else: self._blivet.devicetree.recursive_remove(disk) @@ -516,7 +517,7 @@ def _look_up_device(self): def _create(self): if self._device.format.type != "disklabel" or \ self._device.format.label_type != disklabel_type: - if safe_mode: + if safe_mode and not packages_only: raise BlivetAnsibleError("cannot remove existing formatting and/or devices on disk '%s' " "(pool '%s') in safe mode" % (self._device.name, self._pool['name'])) else: