Re: [PATCH 08/14] Add minSize and maxSize properties to StorageDevice and PartitionDevice.

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

 



On Sun, 2009-03-01 at 20:32 -1000, David Cantrell wrote:
> These properties take in to account the minimum and maximum sizes
> imposed by the device and partition type currently in use as well
> as the minimum and maximum sizes imposed by the DeviceFormat type
> on the device.

Aside from the note below this looks good.

> ---
>  storage/devices.py |   41 +++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 41 insertions(+), 0 deletions(-)
> 
> diff --git a/storage/devices.py b/storage/devices.py
> index 3cc2599..2301e8b 100644
> --- a/storage/devices.py
> +++ b/storage/devices.py
> @@ -477,6 +477,25 @@ class StorageDevice(Device):
>          return size
>  
>      @property
> +    def minSize(self):
> +        """ The minimum size this device can be. """
> +        if self.format:
> +            return self.format.minSize
> +        else:
> +            return self.size

After the constructor has finished, all StorageDevice instances will
have a format. It may be the base format ("Unknown"), whose type attr is
None, but there will be a format there. It allows us to skip
conditionals like this and simplify the code.

> +
> +    @property
> +    def maxSize(self):
> +        """ The maximum size this device can be. """
> +        if self.format:
> +            if self.format.maxSize > self.currentSize:
> +                return self.currentSize
> +            else:
> +                return self.format.maxSize
> +        else:
> +            return self.currentSize
> +
> +    @property
>      def status(self):
>          """ This device's status.
>  
> @@ -1033,6 +1052,28 @@ class PartitionDevice(StorageDevice):
>  
>      disk = property(lambda p: p._getDisk(), lambda p,d: p._setDisk(d))
>  
> +    @property
> +    def minSize(self):
> +        """ The minimum size this partition can be. """
> +        if self.format:
> +            return self.format.minSize
> +        else:
> +            return self.size
> +
> +    @property
> +    def maxSize(self):
> +        """ The maximum size this partition can be. """
> +        # XXX: this is MB by default
> +        max = self.partedPartition.getMaxAvailableSize()
> +
> +        if self.format:
> +            if self.format.maxSize > max:
> +                return max
> +            else:
> +                return self.format.maxSize
> +        else:
> +            return self.max
> +
>  
>  class DMDevice(StorageDevice):
>      """ A device-mapper device """

_______________________________________________
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