diff options
-rw-r--r-- | storage/devicetree.py | 8 | ||||
-rw-r--r-- | storage/partitioning.py | 14 |
2 files changed, 21 insertions, 1 deletions
diff --git a/storage/devicetree.py b/storage/devicetree.py index 8ecf81530..83d756ba9 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -676,6 +676,14 @@ class DeviceTree(object): log.debug("cmp: %d -- %s | %s" % (ret, a1, a2)) return ret + # setup actions to create any extended partitions we added + for device in self.devices: + if isinstance(device, PartitionDevice) and \ + device.isExtended and not device.exists: + # don't properly register the action since the device is + # already in the tree + self._actions.append(ActionCreateDevice(device)) + for action in self._actions: log.debug("action: %s" % action) diff --git a/storage/partitioning.py b/storage/partitioning.py index 65c1f5dcc..e44d7f4d4 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -603,9 +603,19 @@ def doPartitioning(storage, exclusiveDisks=None): for disk in disks: extended = disk.format.extendedPartition if not extended: + # remove any obsolete extended partitions + for part in storage.partitions: + if part.disk == disk and part.isExtended: + storage.devicetree._removeDevice(part, moddisk=False) continue extendedName = devicePathToName(extended.getDeviceNodeName()) + # remove any obsolete extended partitions + for part in storage.partitions: + if part.disk == disk and part.isExtended and \ + part.name != extendedName: + storage.devicetree._removeDevice(part, moddisk=False) + device = storage.devicetree.getDeviceByName(extendedName) if device: if not device.exists: @@ -620,7 +630,9 @@ def doPartitioning(storage, exclusiveDisks=None): device = PartitionDevice(extendedName, parents=disk) device.parents = [disk] device.partedPartition = extended - storage.createDevice(device) + # just add the device for now -- we'll handle actions at the last + # moment to simplify things + storage.devicetree._addDevice(device) def allocatePartitions(disks, partitions): """ Allocate partitions based on requested features. |