[PATCH 2/5] Remove unused fallback code from DiskLabel.
David Lehman
dlehman at redhat.com
Thu Oct 9 21:53:54 UTC 2014
This is not used, and the partitions part would cause calling code
to fail anyway since it all expects a list of parted.Partition instances.
---
blivet/formats/disklabel.py | 43 +++----------------------------------------
1 file changed, 3 insertions(+), 40 deletions(-)
diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py
index 71c9a25..e80b1e4 100644
--- a/blivet/formats/disklabel.py
+++ b/blivet/formats/disklabel.py
@@ -353,20 +353,7 @@ class DiskLabel(DeviceFormat):
@property
def partitions(self):
- try:
- parts = self.partedDisk.partitions
- except Exception: # pylint: disable=broad-except
- log_exception_info()
- parts = []
- if flags.testing:
- sys_block_root = "/sys/class/block/"
-
- # FIXME: /dev/mapper/foo won't work without massaging
- disk_name = self.device.split("/")[-1]
-
- disk_root = sys_block_root + disk_name
- parts = [n for n in os.listdir(disk_root) if n.startswith(disk_name)]
- return parts
+ return self.partedDisk.partitions
@property
def alignment(self):
@@ -410,32 +397,8 @@ class DiskLabel(DeviceFormat):
@property
def free(self):
- def read_int_from_sys(path):
- return int(open(path).readline().strip())
-
- try:
- free = sum(Size(f.getLength(unit="B"))
- for f in self.partedDisk.getFreeSpacePartitions())
- except Exception: # pylint: disable=broad-except
- log_exception_info()
- sys_block_root = "/sys/class/block/"
-
- # FIXME: /dev/mapper/foo won't work without massaging
- disk_name = self.device.split("/")[-1]
-
- disk_root = sys_block_root + disk_name
- disk_length = read_int_from_sys("%s/size" % disk_root)
- sector_size = read_int_from_sys("%s/queue/logical_block_size" % disk_root)
- partition_names = [n for n in os.listdir(disk_root) if n.startswith(disk_name)]
- used_sectors = 0
- for partition_name in partition_names:
- partition_root = sys_block_root + partition_name
- partition_length = read_int_from_sys("%s/size" % partition_root)
- used_sectors += partition_length
-
- free = Size((disk_length - used_sectors) * sector_size)
-
- return free
+ return Size(sum(f.getLength(unit="B")
+ for f in self.partedDisk.getFreeSpacePartitions()))
@property
def magicPartitionNumber(self):
--
1.9.3
More information about the anaconda-patches
mailing list