Skip to content

Commit

Permalink
Don't raise safe_mode failures when packages_only is True.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlehman committed Nov 14, 2019
1 parent a8fc751 commit f1d2b7e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f1d2b7e

Please sign in to comment.