Add an alignment property to DiskLabel.
---
storage/formats/disklabel.py | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
index d277323..8917efd 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_align ment)
+ except (ArithmeticError, AttributeError):
+ try:
+ a = minimum_device_alignment.intersect(disklabel_align ment)
+ except (ArithmeticError, AttributeError):
+ a = disklabel_alignment
+
+ self._alignment = a
+
+ return self._alignment
+
register_device_format(DiskLabel)
--
1.6.2.5
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list