Re: Cannot add a partition after devicetree.processActions()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/27/2012 04:58 PM, Jan Safranek wrote:
> On 03/27/2012 03:12 PM, David Lehman wrote:
>> On Tue, 2012-03-27 at 08:06 -0500, David Lehman wrote:
>>> Since you are apparently going to be performing one action at a time,
>>> there is no need for you to use processActions. It's main purpose is to
>>> execute a potentially long series of actions. You should just create the
>>> actions yourself and then directly execute them as follows:
>>>
>>> part1 = storage.newPartition(disks=[disk], size=10)
>>> action1 = pyanaconda.storage.deviceaction.ActionCreateDevice(part1)
>>> storage.devicetree.registerAction(action1)
>>
>> I forgot to add the call to doPartitioning here:
>>
>> pyanaconda.storage.partitioning.doPartitioning(storage=storage)
>>
>>> action1.execute()
> 
> DeviceCreateError: ("Can't have overlapping partitions.", 'sda1')
> 
> And no, there is no sda1 on /dev/sda, I'm just creating it.

Just for archiving, David Lehman provided me a very hackish workaround:

part1 = storage.newPartition(disks=[disk], size=10)
action1 = pyanaconda.storage.deviceaction.ActionCreateDevice(part1)
storage.devicetree.registerAction(action1)
pyanaconda.storage.partitioning.doPartitioning(storage=storage)

new_partitions = [p for p in storage.partitions if not p.exists]
for disk in storage.partitioned:
  partitions = [p for p in new_partitions if p.disk == disk]
  partitions.sort(key=lambda p: p.partedPartition.number, reverse=True)
  for partition in partitions:
    disk.format.partedDisk.removePartition(partition.partedPartition)

action1.execute()

Thanks again, David!

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux