[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [PATCH 08/14] Add minSize and maxSize properties to StorageDevice and PartitionDevice.
- From: David Lehman <dlehman redhat com>
- To: Discussion of Development and Customization of the Red Hat Linux Installer <anaconda-devel-list redhat com>
- Subject: Re: [PATCH 08/14] Add minSize and maxSize properties to StorageDevice and PartitionDevice.
- Date: Mon, 02 Mar 2009 10:14:51 -0600
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 """
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]