Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove an old legacy function from anaconda's partedUtils.py (#41)
This function is invalid and should not be used.  It does not reflect
the current actual limits imposed by the kernel across different
platforms and disk labels.  Going forward, users should simply try to
add another logical partition and if it fails, handle the error
appropriately.  There is no way exposed in libparted to provide this
information, so pyparted will stop lying.
  • Loading branch information
dcantrell committed Jun 22, 2017
1 parent 16ef58e commit 5cdc96a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
32 changes: 0 additions & 32 deletions src/parted/disk.py
Expand Up @@ -351,38 +351,6 @@ def getPartitionBySector(self, sector):
returned (not the extended partition)."""
return parted.Partition(disk=self, PedPartition=self.__disk.get_partition_by_sector(sector))

def getMaxLogicalPartitions(self):
"""Return the maximum number of logical partitions this Disk
will hold. Returns 0 if there is no extended partition on
the disk, returns 11 when all else fails."""
if not self.supportsFeature(parted.DISK_TYPE_EXTENDED):
return 0

# maximum number of logical partitions per device type
maxLogicalPartitionCount = {
"hd": 59,
"sd": 11,
"ataraid/": 11,
"rd/": 3,
"cciss/": 11,
"i2o/": 11,
"iseries/vd": 3,
"ida/": 11,
"sx8/": 11,
"xvd": 11,
"vd": 11,
"mmcblk": 5
}

dev = self.device.path[5:]
for key in maxLogicalPartitionCount.keys():
if dev.startswith(key):
return maxLogicalPartitionCount[key]

# XXX: if we don't know about it, should we pretend it can't have
# logicals? probably safer to just use something reasonable
return 11

@localeC
def getExtendedPartition(self):
"""Return the extended Partition, if any, on this Disk."""
Expand Down
11 changes: 0 additions & 11 deletions tests/test_parted_disk.py
Expand Up @@ -150,17 +150,6 @@ def runTest(self):
# TODO
self.fail("Unimplemented test case.")

class DiskGetMaxLogicalPartitionsTestCase(RequiresDisk):
"""
getMaxLogicalPartitions return int values based on which type of disk
is used. It search for occurrence of keys in device path(e.g. /dev/sda)
and compare it with predefined values("sd": 11). As unittest
environment is using file with generic name(e.g.
/tmp/temp-device-C64w78), test focus only on type of returned value
"""
def runTest(self):
self.assertIsInstance(self.disk.getMaxLogicalPartitions(), int)

class DiskGetMaxSupportedPartitionCountTestCase(RequiresDisk):
"""
maxSupportedPartitionCount should return value 64, based on default
Expand Down

0 comments on commit 5cdc96a

Please sign in to comment.