summaryrefslogtreecommitdiffstats
path: root/storage/formats/disklabel.py
diff options
context:
space:
mode:
authorDavid Lehman <dlehman@redhat.com>2009-12-14 16:03:12 -0600
committerDavid Lehman <dlehman@redhat.com>2009-12-15 09:54:35 -0600
commit384ee2fc5ce5ef7111482405d5303064b67a0c05 (patch)
treee50550cfbaa7fb07fe54271c3a1ac552ac074de9 /storage/formats/disklabel.py
parent9f5eb5924cb419b62022a15119be643edd1cb1d9 (diff)
downloadanaconda-384ee2fc5ce5ef7111482405d5303064b67a0c05.tar.gz
anaconda-384ee2fc5ce5ef7111482405d5303064b67a0c05.tar.xz
anaconda-384ee2fc5ce5ef7111482405d5303064b67a0c05.zip
Add an alignment property to DiskLabel.
Diffstat (limited to 'storage/formats/disklabel.py')
-rw-r--r--storage/formats/disklabel.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
index d27732314..8917efd11 100644
--- a/storage/formats/disklabel.py
+++ b/storage/formats/disklabel.py
@@ -62,6 +62,7 @@ class DiskLabel(DeviceFormat):
self._partedDevice = None
self._partedDisk = None
self._origPartedDisk = None
+ self._alignment = None
if self.partedDevice:
# set up the parted objects and raise exception on failure
@@ -278,5 +279,36 @@ class DiskLabel(DeviceFormat):
parts = []
return parts
+ @property
+ def alignment(self):
+ """ Alignment requirements for this device. """
+ if not self._alignment:
+ try:
+ disklabel_alignment = self.partedDisk.partitionAlignment
+ except _ped.CreateException:
+ disklabel_alignment = parted.Alignment(offset=0, grainSize=1)
+
+ try:
+ optimum_device_alignment = self.partedDevice.optimumAlignment
+ except _ped.CreateException:
+ optimum_device_alignment = None
+
+ try:
+ minimum_device_alignment = self.partedDevice.minimumAlignment
+ except _ped.CreateException:
+ minimum_device_alignment = None
+
+ try:
+ a = optimum_device_alignment.intersect(disklabel_alignment)
+ except (ArithmeticError, AttributeError):
+ try:
+ a = minimum_device_alignment.intersect(disklabel_alignment)
+ except (ArithmeticError, AttributeError):
+ a = disklabel_alignment
+
+ self._alignment = a
+
+ return self._alignment
+
register_device_format(DiskLabel)