[PATCH 17/47] Removed partedUtils.get_partition_by_name()

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

 



Now provided by pyparted as parted.getPartitionByName()
---
 autopart.py             |   10 +++++-----
 bootloader.py           |    3 +--
 fsset.py                |    2 +-
 iscsi.py                |    3 +--
 iw/raid_dialog_gui.py   |    3 +--
 partIntfHelpers.py      |    9 ++++-----
 partRequests.py         |    2 +-
 partedUtils.py          |   21 ---------------------
 textw/partition_text.py |    2 +-
 9 files changed, 15 insertions(+), 40 deletions(-)

diff --git a/autopart.py b/autopart.py
index 02923b9..10c9a91 100644
--- a/autopart.py
+++ b/autopart.py
@@ -70,7 +70,7 @@ else:
 def bootRequestCheck(req, diskset):
     if not req.device or req.ignoreBootConstraints:
         return PARTITION_SUCCESS
-    part = partedUtils.get_partition_by_name(diskset.disks, req.device)
+    part = parted.getPartitionByName(req.device)
     if not part:
         return PARTITION_SUCCESS
 
@@ -85,7 +85,7 @@ def bootRequestCheck(req, diskset):
         return bootAlphaCheckRequirements(part)
     elif (iutil.getPPCMachine() == "pSeries" or
           iutil.getPPCMachine() == "iSeries"):
-        part = partedUtils.get_partition_by_name(diskset.disks, req.device)
+        part = parted.getPartitionByName(req.device)
         if part and ((part.geom.end * part.geom.dev.sector_size /
                       (1024.0 * 1024)) > 4096):
             return BOOTIPSERIES_TOO_HIGH
@@ -130,7 +130,7 @@ def printNewRequestsCyl(diskset, newRequest):
         if req.type != REQUEST_NEW:
             continue
         
-        part = partedUtils.get_partition_by_name(diskset.disks, req.device)
+        part = parted.getPartitionByName(req.device)
 ##         print(req)
 ##         print("Start Cyl:%s    End Cyl: %s" % (part.geom.dev.startSectorToCylinder(part.geom.start),
 ##                                  part.geom.dev.endSectorToCylinder(part.geom.end),))
@@ -737,7 +737,7 @@ def growParts(diskset, requests, newParts):
                 donegrowing = 0
 
                 # get amount of space actually used by current allocation
-                part = partedUtils.get_partition_by_name(diskset.disks, request.device)
+                part = parted.getPartitionByName(request.device)
                 startSize = part.geometry.length
 
                 # compute fraction of freespace which to give to this
@@ -1025,7 +1025,7 @@ def processPartitioning(diskset, requests, newParts):
         elif request.preexist:
             # we need to keep track of the max size of preexisting partitions
             # FIXME: we should also get the max size for LVs at some point
-            part = partedUtils.get_partition_by_name(diskset.disks, request.device)
+            part = parted.getPartitionByName(request.device)
             request.maxResizeSize = part.getMaxAvailableSize(unit="MB")
 
 ##     print("disk layout after everything is done")
diff --git a/bootloader.py b/bootloader.py
index 259eaec..5c495cf 100644
--- a/bootloader.py
+++ b/bootloader.py
@@ -129,8 +129,7 @@ def bootloaderSetupChoices(anaconda):
     bootDev = anaconda.id.fsset.getEntryByMountPoint("/")
     if not bootDev:
         bootDev = anaconda.id.fsset.getEntryByMountPoint("/boot")
-    part = partedUtils.get_partition_by_name(anaconda.id.diskset.disks,
-                                              bootDev.device.getDevice())
+    part = parted.getPartitionByName(bootDev.device.getDevice())
     if part and part.geom.dev.endSectorToCylinder(part.geom.end) >= 1024:
         anaconda.id.bootloader.above1024 = 1
     
diff --git a/fsset.py b/fsset.py
index 3ba24e4..31e4f91 100644
--- a/fsset.py
+++ b/fsset.py
@@ -1646,7 +1646,7 @@ MAILADDR root
         bootDev = dev.device
 
         if dev.getName() != "RAIDDevice":
-            part = partedUtils.get_partition_by_name(diskset.disks, bootDev)
+            part = parted.getPartitionByName(bootDev)
             drive = part.geometry.device.path[5:]
 
             # on EFI systems, *only* /boot/efi should be marked bootable
diff --git a/iscsi.py b/iscsi.py
index 7fa8d40..2886279 100644
--- a/iscsi.py
+++ b/iscsi.py
@@ -579,8 +579,7 @@ class iscsi(object):
             root_requests = anaconda.id.partitions.getUnderlyingRequests(req)
             for req in root_requests:
                 # req.drive is unreliable <sigh> so figure it out ourselves
-                part = partedUtils.get_partition_by_name(anaconda.id.diskset.disks,
-                                                         req.device)
+                part = parted.getPartitionByName(req.device)
                 if not part:
                     continue
                 drive = part.geometry.device.path[5:]
diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py
index 8e905cf..21cb2bc 100644
--- a/iw/raid_dialog_gui.py
+++ b/iw/raid_dialog_gui.py
@@ -494,8 +494,7 @@ class RaidCloneDialog:
         requests = []
         for req in allrequests:
             try:
-                part = partedUtils.get_partition_by_name(self.diskset.disks,
-                                                         req.device)
+                part = parted.getPartitionByName(req.device)
             except:
                 part = None
 
diff --git a/partIntfHelpers.py b/partIntfHelpers.py
index 021b84b..bf89829 100644
--- a/partIntfHelpers.py
+++ b/partIntfHelpers.py
@@ -254,7 +254,7 @@ def doDeletePartitionsByDevice(intf, requestlist, diskset, device,
     # get list of unique IDs of these requests
     reqIDs = []
     for req in requests:
-	part = partedUtils.get_partition_by_name(diskset.disks, req.device)
+	part = parted.getPartitionByName(req.device)
 	if part.type & parted.PARTITION_FREESPACE or part.type & parted.PARTITION_METADATA or part.type & parted.PARTITION_PROTECTED:
 	    continue
 	reqIDs.append(req.uniqueID)
@@ -265,7 +265,7 @@ def doDeletePartitionsByDevice(intf, requestlist, diskset, device,
 	    req = requestlist.getRequestByID(id)
 	    if req is None:
 		continue
-            part = partedUtils.get_partition_by_name(diskset.disks, req.device)
+            part = parted.getPartitionByName(req.device)
             rc = doDeletePartitionByRequest(intf, requestlist, part,
                                             confirm=0, quiet=1)
             if not rc:
@@ -280,7 +280,7 @@ def doDeletePartitionsByDevice(intf, requestlist, diskset, device,
 	# get list of unique IDs of these requests
 	leftIDs = []
 	for req in left_requests:
-	    part = partedUtils.get_partition_by_name(diskset.disks, req.device)
+	    part = parted.getPartitionByName(req.device)
 	    if part.type & parted.PARTITION_FREESPACE or part.type & parted.PARTITION_METADATA or part.type & parted.PARTITION_PROTECTED:
 		continue
 	    leftIDs.append(req.uniqueID)
@@ -380,8 +380,7 @@ def checkForSwapNoMatch(anaconda):
         if not request.device or not request.fstype:
             continue
         
-        part = partedUtils.get_partition_by_name(anaconda.id.diskset.disks,
-                                                 request.device)
+        part = parted.getPartitionByName(request.device)
         if (part and (not part.type & parted.PARTITION_FREESPACE)
             and (part.native_type == 0x82)
             and (request.fstype and request.fstype.getName() != "swap")
diff --git a/partRequests.py b/partRequests.py
index fc108f2..d768bd3 100644
--- a/partRequests.py
+++ b/partRequests.py
@@ -517,7 +517,7 @@ class PartitionSpec(RequestSpec):
 
     def getActualSize(self, partitions, diskset):
         """Return the actual size allocated for the request in megabytes."""
-        part = partedUtils.get_partition_by_name(diskset.disks, self.device)
+        part = parted.getPartitionByName(self.device)
         if not part:
             # XXX kickstart might still call this before allocating the partitions
             raise RuntimeError, "Checking the size of a partition which hasn't been allocated yet"
diff --git a/partedUtils.py b/partedUtils.py
index 0639dff..7802d4c 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -48,27 +48,6 @@ log = logging.getLogger("anaconda")
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
 
-def get_partition_by_name(disks, partname):
-    """Return the parted part object associated with partname.  
-
-    Arguments:
-    disks -- Dictionary of diskname->PedDisk objects
-    partname -- Name of partition to find
-
-    Return:
-    PedPartition object with name partname.  None if no such partition.
-    """
-    for diskname in disks.keys():
-        disk = disks[diskname]
-        part = disk.next_partition()
-        while part:
-            if part.getDeviceNodeName() == partname:
-                return part
-
-            part = disk.next_partition(part)
-
-    return None
-
 def get_partition_file_system_type(part):
     """Return the file system type of the PedPartition part.
 
diff --git a/textw/partition_text.py b/textw/partition_text.py
index 9ab2258..6b529f6 100644
--- a/textw/partition_text.py
+++ b/textw/partition_text.py
@@ -571,7 +571,7 @@ class PartitionWindow:
 	subgrid.setField(typeLbl, 0, srow, (0,0,0,1), anchorLeft = 1)
 	ptype = origrequest.fstype.getName()
 	if ptype == "foreign":
-	    part = get_partition_by_name(self.diskset.disks, origrequest.device)
+	    part = parted.getPartitionByName(origrequest.device)
             if part is not None:
                 ptype = map_foreign_to_fsname(part.native_type)
             else:
-- 
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