Re: [PATCH 2/2] Pre-existing partitions names may change (#494833)

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

 



looks good.
On Wed, Apr 08, 2009 at 02:50:01PM +0200, Hans de Goede wrote:
> When there are multiple (pre-existing) logical partitions and a logical
> partition other then the last partition gets deleted, the number
> of the partitions after it changes. Causing getDeviceByName, with the
> name based on the new partition number (gotten through parted) to fail.
> 
> Specifically this causes a "'NoneType' object has no attribute 'path'"
> exception in populate() in partition_gui.py . This patch fixes this by
> updating all partitions names in doPartitioning.
> 
> Note that for this patch to help the following pyparted bug must also
> be fixed: https://fedorahosted.org/pyparted/ticket/17
> ---
>  storage/devices.py      |   16 +++++++++-------
>  storage/partitioning.py |    5 +++++
>  2 files changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/storage/devices.py b/storage/devices.py
> index fa9bd3f..0d39d12 100644
> --- a/storage/devices.py
> +++ b/storage/devices.py
> @@ -1030,13 +1030,8 @@ class PartitionDevice(StorageDevice):
>          log.debug("device %s new partedPartition %s has path %s" % (self.name,
>                                                                      partition,
>                                                                      path))
> -
> -        if partition is None:
> -            self._partedPartition = None
> -            self._name = self.req_name
> -        else:
> -            self._partedPartition = partition
> -            self._name = devicePathToName(partition.getDeviceNodeName())
> +        self._partedPartition = partition
> +        self.updateName()
>  
>      partedPartition = property(lambda d: d._getPartedPartition(),
>                                 lambda d,p: d._setPartedPartition(p))
> @@ -1064,6 +1059,13 @@ class PartitionDevice(StorageDevice):
>          else:
>              StorageDevice.updateSysfsPath(self)
>  
> +    def updateName(self):
> +        if self.partedPartition is None:
> +            self._name = self.req_name
> +        else:
> +            self._name = \
> +                devicePathToName(self.partedPartition.getDeviceNodeName())
> +
>      def dependsOn(self, dep):
>          """ Return True if this device depends on dep. """
>          if isinstance(dep, PartitionDevice) and dep.isExtended and self.isLogical:
> diff --git a/storage/partitioning.py b/storage/partitioning.py
> index 619b474..5fba2e1 100644
> --- a/storage/partitioning.py
> +++ b/storage/partitioning.py
> @@ -561,6 +561,11 @@ def doPartitioning(storage, exclusiveDisks=None):
>      # FIXME: make sure non-existent partitions have empty parents list
>      allocatePartitions(disks, partitions)
>      growPartitions(disks, partitions)
> +    # The number and thus the name of partitions may have changed now,
> +    # allocatePartitions() takes care of this for new partitions, but not
> +    # for pre-existing ones, so we update the name of all partitions here
> +    for part in partitions:
> +        part.updateName()
>  
>      # XXX hack -- if we created any extended partitions we need to add
>      #             them to the tree now
> -- 
> 1.6.2
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

-- 
Joel Andres Granados
Brno, Czech Republic, Red Hat.

_______________________________________________
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