Skip to content

Commit

Permalink
Allow adding new partitions to disks with active devices (#1212841)
Browse files Browse the repository at this point in the history
Parted doesn't allow changing disklabel when there is an active
partition on the disk. Current implementation of
findActiveDevicesOnActionDisks doesn't allow adding new partitions
when there is an existing active (child) device other than another
partition (eg. VG). New version checks only actions that actually
changes the disklabel and checks status of formats of (child) devices
on the disk with changes.

Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
  • Loading branch information
vojtechtrefny committed Apr 27, 2015
1 parent de7b86c commit b72e957
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions blivet/actionlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,21 @@ def _findActiveDevicesOnActionDisks(self, devices=None):
disks = []
for action in self._actions:
disk = None
if action.isDevice and isinstance(action.device, PartitionDevice):
disk = action.device.disk
elif action.isFormat and action.format.type == "disklabel":
if action.isFormat and action.format.type == "disklabel":
disk = action.device

if disk is not None and disk not in disks:
disks.append(disk)

active = (dev for dev in devices
if (dev.status and
(not dev.isDisk and
not isinstance(dev, PartitionDevice))))
active = []
for dev in devices:
if dev.status and not dev.isDisk and \
not isinstance(dev, PartitionDevice):
active.append(dev)

elif dev.format.status and not dev.isDisk:
active.append(dev)

devices = [a.name for a in active if any(d in disks for d in a.disks)]
return devices

Expand Down

1 comment on commit b72e957

@mulkieran
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active = (dev for dev in devices
   if not dev.isDisk and
  ((dev.status and not isinstance(dev, PartitionDevice)) or dev.format.status))

has fewer redundant parts and seems a bit clearer.

Please sign in to comment.