[PATCH 10/47] Removed partedUtils.get_partition_name()

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

 



Now provided by parted.Partition.getDeviceNodeName()
---
 autopart.py             |   20 ++++++++++----------
 bootloader.py           |    4 ++--
 fsset.py                |    4 ++--
 iw/osbootwidget.py      |    2 +-
 iw/partition_gui.py     |    6 +++---
 partIntfHelpers.py      |    6 +++---
 partedUtils.py          |   33 ++++++---------------------------
 partitions.py           |   14 +++++++-------
 raid.py                 |    2 +-
 textw/partition_text.py |    6 +++---
 10 files changed, 38 insertions(+), 59 deletions(-)

diff --git a/autopart.py b/autopart.py
index 83a66d4..6f2e720 100644
--- a/autopart.py
+++ b/autopart.py
@@ -136,7 +136,7 @@ def printNewRequestsCyl(diskset, newRequest):
 ##                                  part.geom.dev.endSectorToCylinder(part.geom.end),))
 
 def printFreespaceitem(part):
-    return partedUtils.get_partition_name(part), part.geom.start, part.geom.end, part.getSize(unit="MB")
+    return part.getDeviceNodeName(), part.geom.start, part.geom.end, part.getSize(unit="MB")
 
 def printFreespace(free):
     print("Free Space Summary:")
@@ -179,7 +179,7 @@ class partlist:
     def __str__(self):
         retval = ""
         for p in self.parts:
-            retval = retval + "\t%s %s %s\n" % (partedUtils.get_partition_name(p), partedUtils.get_partition_file_system_type(p), p.getSize(unit="MB"))
+            retval = retval + "\t%s %s %s\n" % (p.getDeviceNodeName(), partedUtils.get_partition_file_system_type(p), p.getSize(unit="MB"))
 
         return retval
 
@@ -887,13 +887,13 @@ def setPreexistParts(diskset, requests):
                         constraint = g.constraint_exact()
                         part.set_geometry(constraint, startSec, endSec)
                     except parted.error, msg:
-                        log.error("error setting geometry for partition %s: %s" %(partedUtils.get_partition_name(part), msg))
-                        raise PartitioningError, _("Error resizing partition %s.\n\n%s") %(partedUtils.get_partition_name(part), msg)
+                        log.error("error setting geometry for partition %s: %s" %(part.getDeviceNodeName(), msg))
+                        raise PartitioningError, _("Error resizing partition %s.\n\n%s") %(part.getDeviceNodeName(), msg)
 
                     if startSec != part.geom.start:
-                        raise PartitioningError, _("Start of partition %s was moved when resizing") %(partedUtils.get_partition_name(part),)
+                        raise PartitioningError, _("Start of partition %s was moved when resizing") %(part.getDeviceNodeName(),)
 
-                request.device = partedUtils.get_partition_name(part)
+                request.device = part.getDeviceNodeName()
                 if request.fstype:
                     if request.fstype.getName() != request.origfstype.getName():
                         if part.is_flag_available(parted.PARTITION_RAID):
@@ -1151,7 +1151,7 @@ def doClearPartAction(anaconda, partitions, diskset):
                  ((part.is_flag_available(parted.PARTITION_RAID) and part.get_flag(parted.PARTITION_RAID)) or  # this is a RAID
                   (part.is_flag_available(parted.PARTITION_LVM) and part.get_flag(parted.PARTITION_LVM)) or # or an LVM
                   (iutil.isMactel() and not ptype)))): # or we're on a mactel and have a blank partition from bootcamp #FIXME: this could be dangerous...
-                old = partitions.getRequestByDeviceName(partedUtils.get_partition_name(part))
+                old = partitions.getRequestByDeviceName(part.getDeviceNodeName())
                 if old.getProtected():
                     part = disk.next_partition(part)
                     continue
@@ -1172,7 +1172,7 @@ def doClearPartAction(anaconda, partitions, diskset):
             # doesn't apply on kickstart installs or if no boot flag
             if iutil.isEfi() and linuxOnly == 1 and (not anaconda.isKickstart):
                 if partedUtils.isEfiSystemPartition(part):
-                    req = partitions.getRequestByDeviceName(partedUtils.get_partition_name(part))
+                    req = partitions.getRequestByDeviceName(part.getDeviceNodeName())
                     other = partitions.getRequestByMountPoint("/boot/efi")
 
                     if not other:
@@ -1195,7 +1195,7 @@ def doClearPartAction(anaconda, partitions, diskset):
                   part.is_flag_available(parted.PARTITION_BOOT) and
                   (part.native_type == 0x41) and
                   part.get_flag(parted.PARTITION_BOOT)):
-                req = partitions.getRequestByDeviceName(partedUtils.get_partition_name(part))                
+                req = partitions.getRequestByDeviceName(part.getDeviceNodeName())
                 req.mountpoint = None
                 req.format = 0
                 request = None
@@ -1225,7 +1225,7 @@ def doClearPartAction(anaconda, partitions, diskset):
         if ext and len(partedUtils.get_logical_partitions(disk)) == 0:
             delete = partRequests.DeleteSpec(drive, ext.geom.start,
                                              ext.geom.end)
-            old = partitions.getRequestByDeviceName(partedUtils.get_partition_name(ext))
+            old = partitions.getRequestByDeviceName(ext.getDeviceNodeName())
             partitions.removeRequest(old)
             partitions.addDelete(delete)
             deletePart(diskset, delete)
diff --git a/bootloader.py b/bootloader.py
index c88b8ed..259eaec 100644
--- a/bootloader.py
+++ b/bootloader.py
@@ -68,7 +68,7 @@ def bootloaderSetupChoices(anaconda):
             part = disk.next_partition()
             while part:
                 if part.is_active() and partedUtils.isEfiSystemPartition(part):
-                    bootPart = partedUtils.get_partition_name(part)
+                    bootPart = part.getDeviceNodeName()
                     break
                 part = disk.next_partition(part)
             if bootPart:
@@ -89,7 +89,7 @@ def bootloaderSetupChoices(anaconda):
             part = disk.next_partition()
             while part:
                 if part.is_active() and part.native_type == 0x41:
-                    bootPart = partedUtils.get_partition_name(part)
+                    bootPart = part.getDeviceNodeName()
                     break
                 part = disk.next_partition(part)
             if bootPart:
diff --git a/fsset.py b/fsset.py
index 18b8fe2..3ba24e4 100644
--- a/fsset.py
+++ b/fsset.py
@@ -1685,7 +1685,7 @@ MAILADDR root
                 if not bootPart:
                     bootPart = part
 
-                if partedUtils.get_partition_name(part) == bootDev:
+                if part.getDeviceNodeName() == bootDev:
                     bootPart = part
 
                 part = disk.next_partition(part)
@@ -2686,7 +2686,7 @@ class PartedPartitionDevice(PartitionDevice):
         if not self.partition:
             return self.device
 
-        return partedUtils.get_partition_name(self.partition)
+        return self.partition.getDeviceNodeName()
 
     def solidify(self):
         # drop reference on the parted partition object and note
diff --git a/iw/osbootwidget.py b/iw/osbootwidget.py
index d4a2942..481267d 100644
--- a/iw/osbootwidget.py
+++ b/iw/osbootwidget.py
@@ -163,7 +163,7 @@ class OSBootWidget:
             for drive in disks.keys():
                 pedparts.extend(partedUtils.filter_partitions(disks[drive], func))
             for part in pedparts:
-                parts.append(partedUtils.get_partition_name(part))
+                parts.append(part.getDeviceNodeName())
             del pedparts
             parts.sort()
 
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 7e1aadd..2d161c8 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -145,12 +145,12 @@ class DiskStripeSlice:
         if self.partition.type & parted.PARTITION_FREESPACE:
             rc = "Free\n"
         else:
-            rc = "%s\n" % (get_partition_name(self.partition),)
+            rc = "%s\n" % (self.partition.getDeviceNodeName(),)
         rc = rc + "%Ld MB" % (self.partition.getSize(unit="MB"),)
         return rc
 
     def getDeviceName(self):
-        return get_partition_name(self.partition)
+        return self.partition.getDeviceNodeName()
 
     def update(self):
         disk = self.parent.getDisk()
@@ -841,7 +841,7 @@ class PartitionWindow(InstallWindow):
                         continue
 
                 stripe.add(part)
-                device = get_partition_name(part)
+                device = part.getDeviceNodeName()
                 request = self.partitions.getRequestByDeviceName(device)
 
                 if part.type == parted.PARTITION_EXTENDED:
diff --git a/partIntfHelpers.py b/partIntfHelpers.py
index dfebc33..021b84b 100644
--- a/partIntfHelpers.py
+++ b/partIntfHelpers.py
@@ -163,7 +163,7 @@ def doDeletePartitionByRequest(intf, requestlist, partition,
 			   custom_icon="error")
         return 0
     else:
-        device = partedUtils.get_partition_name(partition)
+        device = partition.getDeviceNodeName()
 
     ret = requestlist.containsImmutablePart(partition)
     if ret:
@@ -359,7 +359,7 @@ def doEditPartitionByRequest(intf, requestlist, part):
                              "which contains %s") %(ret), custom_icon="error")
         return (None, None)
 
-    name = partedUtils.get_partition_name(part)
+    name = part.getDeviceNodeName()
     request = requestlist.getRequestByDeviceName(name)
     if request:
 	state = isNotChangable(request, requestlist)
@@ -371,7 +371,7 @@ def doEditPartitionByRequest(intf, requestlist, part):
         return ("PARTITION", request)
     else: # shouldn't ever happen
         raise ValueError, ("Trying to edit non-existent partition %s"
-                           % (partedUtils.get_partition_name(part)))
+                           % (part.getDeviceNodeName(),))
 
 
 def checkForSwapNoMatch(anaconda):
diff --git a/partedUtils.py b/partedUtils.py
index 4653792..cd8a08d 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -84,34 +84,13 @@ def get_partition_by_name(disks, partname):
         disk = disks[diskname]
         part = disk.next_partition()
         while part:
-            if get_partition_name(part) == partname:
+            if part.getDeviceNodeName() == partname:
                 return part
 
             part = disk.next_partition(part)
 
     return None
 
-def get_partition_name(partition):
-    """Return the device name for the PedPartition partition."""
-    if (partition.geom.dev.type == parted.DEVICE_DAC960
-        or partition.geom.dev.type == parted.DEVICE_CPQARRAY):
-        return "%sp%d" % (partition.geom.dev.path[5:],
-                          partition.num)
-    if (parted.__dict__.has_key("DEVICE_SX8") and
-        partition.geom.dev.type == parted.DEVICE_SX8):
-        return "%sp%d" % (partition.geom.dev.path[5:],
-                          partition.num)
-
-    drive = partition.geom.dev.path[5:]
-    if (drive.startswith("cciss") or drive.startswith("ida") or
-            drive.startswith("rd") or drive.startswith("sx8") or
-            drive.startswith("mapper") or drive.startswith("mmcblk")):
-        sep = "p"
-    else:
-        sep = ""
-    return "%s%s%d" % (partition.geom.dev.path[5:], sep, partition.num)
-
-
 def get_partition_file_system_type(part):
     """Return the file system type of the PedPartition part.
 
@@ -241,7 +220,7 @@ def isEfiSystemPartition(part):
             part.get_name() == "EFI System Partition" and
             part.get_flag(parted.PARTITION_BOOT) == 1 and
             part.fs_type.name in ("fat16", "fat32") and
-            isys.readFSLabel(get_partition_name(part)) != "ANACONDA")
+            isys.readFSLabel(part.getDeviceNodeName()) != "ANACONDA")
 
 def labelDisk(deviceFile, forceLabelType=None):
     dev = parted.PedDevice.get(deviceFile)
@@ -610,7 +589,7 @@ class DiskSet:
                                       or part.get_flag(parted.PARTITION_LVM)))
             parts = filter_partitions(disk, func)
             for part in parts:
-                node = get_partition_name(part)
+                node = part.getDeviceNodeName()
                 crypto = encryptedDevices.get(node)
                 if crypto and not crypto.openDevice():
                     node = crypto.getDevice()
@@ -777,7 +756,7 @@ class DiskSet:
             disk = self.disks[drive]
             part = disk.next_partition ()
             while part:
-                node = get_partition_name(part)
+                node = part.getDeviceNodeName()
                 crypto = self.anaconda.id.partitions.encryptedDevices.get(node)
                 if (part.is_active()
                     and (part.get_flag(parted.PARTITION_RAID)
@@ -1208,7 +1187,7 @@ class DiskSet:
             while part:
                 if part.type in (parted.PARTITION_PRIMARY,
                                  parted.PARTITION_LOGICAL):
-                    device = get_partition_name(part)
+                    device = part.getDeviceNodeName()
                     if part.fs_type:
                         ptype = part.fs_type.name
                     else:
@@ -1240,7 +1219,7 @@ class DiskSet:
                     device = ""
                     fs_type_name = ""
                     if part.num > 0:
-                        device = get_partition_name(part)
+                        device = part.getDeviceNodeName()
                     if part.fs_type:
                         fs_type_name = part.fs_type.name
                     partFlags = part.getFlags()
diff --git a/partitions.py b/partitions.py
index 97c3271..5f4ace9 100644
--- a/partitions.py
+++ b/partitions.py
@@ -310,7 +310,7 @@ class Partitions:
                     part = disk.next_partition(part)
                     continue
 
-                device = partedUtils.get_partition_name(part)
+                device = part.getDeviceNodeName()
                 fs = isys.readFSType("/dev/%s" % (device,))
                 if fs and fs.endswith("raid"):
                     part = disk.next_partition(part)
@@ -396,7 +396,7 @@ class Partitions:
                     if ptype is None:
                         ptype = fsset.fileSystemTypeGet("foreign")
 
-                device = partedUtils.get_partition_name(part)
+                device = part.getDeviceNodeName()
 
                 # parted doesn't tell ext4 from ext3
                 if ptype == fsset.fileSystemTypeGet("ext3"): 
@@ -663,7 +663,7 @@ class Partitions:
         disk = diskset.disks[device]
         part = disk.next_partition()
         while part:
-            dev = partedUtils.get_partition_name(part)
+            dev = part.getDeviceNodeName()
             request = self.getRequestByDeviceName(dev)
 
             if request:
@@ -789,7 +789,7 @@ class Partitions:
         for drive in drives:
             disk = diskset.disks[drive]
             for part in partedUtils.get_raid_partitions(disk):
-                partname = partedUtils.get_partition_name(part)
+                partname = part.getDeviceNodeName()
                 used = 0
                 for raid in raiddevs:
                     if raid.raidmembers:
@@ -899,7 +899,7 @@ class Partitions:
         for drive in drives:
             disk = diskset.disks[drive]
             for part in partedUtils.get_lvm_partitions(disk):
-                partname = partedUtils.get_partition_name(part)
+                partname = part.getDeviceNodeName()
                 partrequest = self.getRequestByDeviceName(partname)
                 if partrequest.encryption is None and \
                    cryptodev.isLuks("/dev/%s" % partname) and \
@@ -1694,7 +1694,7 @@ class Partitions:
     def deleteAllLogicalPartitions(self, part):
         """Add delete specs for all logical partitions in part."""
         for partition in partedUtils.get_logical_partitions(part.disk):
-            partName = partedUtils.get_partition_name(partition)
+            partName = partition.getDeviceNodeName()
             request = self.getRequestByDeviceName(partName)
             self.removeRequest(request)
             if request.preexist:
@@ -1717,7 +1717,7 @@ class Partitions:
                 part = disk.next_partition(part)
                 continue
 
-            device = partedUtils.get_partition_name(part)
+            device = part.getDeviceNodeName()
             request = self.getRequestByDeviceName(device)
 
             if request:
diff --git a/raid.py b/raid.py
index 117ca6f..0ff211c 100644
--- a/raid.py
+++ b/raid.py
@@ -79,7 +79,7 @@ def scanForRaid(drives):
             raidParts = partedUtils.get_raid_partitions(disk)
             for part in raidParts:
                 # if the part is encrypted, add the mapped dev instead
-                pname = partedUtils.get_partition_name(part)
+                pname = part.getDeviceNodeName()
                 cryptoDev = partitions.Partitions.encryptedDevices.get(pname)
                 if cryptoDev and not cryptoDev.openDevice():
                     dev = cryptoDev.getDevice()
diff --git a/textw/partition_text.py b/textw/partition_text.py
index 0d9b162..9ab2258 100644
--- a/textw/partition_text.py
+++ b/textw/partition_text.py
@@ -141,7 +141,7 @@ class PartitionWindow:
             part = disk.next_partition()
             while part:
                 if part.type & parted.PARTITION_METADATA:
-#                    print("partition %s has type %d" %(get_partition_name(part), part.type))
+#                    print("partition %s has type %d" %(part.getDeviceNodeName(), part.type))
                     part = disk.next_partition(part)
                     continue
                 # ignore the tiny < 1 MB partitions (#119479)
@@ -150,7 +150,7 @@ class PartitionWindow:
                         part = disk.next_partition(part)                    
                         continue
 
-                device = get_partition_name(part)
+                device = part.getDeviceNodeName()
                 request = self.partitions.getRequestByDeviceName(device)
                 if request and request.mountpoint:
                     mount = request.mountpoint
@@ -206,7 +206,7 @@ class PartitionWindow:
                                    [LEFT, RIGHT, RIGHT, RIGHT, LEFT, LEFT])
                                     
                 else:
-                    dev = devify(get_partition_name(part))
+                    dev = devify(part.getDeviceNodeName())
                     # save some space per #90838
                     if dev.startswith("/dev/iseries/"):
                         dev = dev[13:]
-- 
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