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]

 



Ack.

On Mon, 2009-03-02 at 10:35 -1000, David Cantrell wrote:
> David Lehman wrote:
> > 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.
> 
> Ah, cool.  Didn't see that.  I've updated the patch and attached it to 
> this email.  minSize is now just on StorageDevice.  maxSize is on 
> StorageDevice but then overridden on PartitionDevice.
> 
> > 
> >> +
> >> +    @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
> 
> 
> plain text document attachment
> (0011-Add-minSize-and-maxSize-properties-to-StorageDevice.patch)
> >From cba30d1a45e23c1dd1063b9dbe79543b5728f27a Mon Sep 17 00:00:00 2001
> From: David Cantrell <dcantrell@xxxxxxxxxx>
> Date: Mon, 2 Mar 2009 10:32:12 -1000
> Subject: [PATCH 11/11] Add minSize and maxSize properties to StorageDevice and PartitionDevice.
> 
> 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.
> ---
>  storage/devices.py |   27 +++++++++++++++++++++++++++
>  1 files changed, 27 insertions(+), 0 deletions(-)
> 
> diff --git a/storage/devices.py b/storage/devices.py
> index 4703fa5..d55f120 100644
> --- a/storage/devices.py
> +++ b/storage/devices.py
> @@ -477,6 +477,22 @@ class StorageDevice(Device):
>          return size
>  
>      @property
> +    def minSize(self):
> +        """ The minimum size this device can be. """
> +        if self.format.minSize < self.size:
> +            return self.format.minSize
> +        else:
> +            return size
> +
> +    @property
> +    def maxSize(self):
> +        """ The maximum size this device can be. """
> +        if self.format.maxSize > self.currentSize:
> +            return self.currentSize
> +        else:
> +            return self.format.maxSize
> +
> +    @property
>      def status(self):
>          """ This device's status.
>  
> @@ -1029,6 +1045,17 @@ class PartitionDevice(StorageDevice):
>  
>      disk = property(lambda p: p._getDisk(), lambda p,d: p._setDisk(d))
>  
> +    @property
> +    def maxSize(self):
> +        """ The maximum size this partition can be. """
> +        # XXX: this is MB by default
> +        max = self.partedPartition.getMaxAvailableSize()
> +
> +        if self.format.maxSize > max:
> +            return max
> +        else:
> +            return self.format.maxSize
> +
>  
>  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

_______________________________________________
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