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

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

 



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 |   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
+
+    @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 """
-- 
1.6.1.3

_______________________________________________
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