[PATCH] Check if disklabel is set (#1007683)

Martin Kolman mkolman at redhat.com
Mon Oct 14 14:32:36 UTC 2013


The disklabel variable, needed by the partition slot check
might not be set if multipath & custom partitioning is used.
Therefore make sure the partition slot check is done only
if disklabel is set.

Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
 storage/partitioning.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index 1e7f583..79d2cc0 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -1061,6 +1061,13 @@ def allocatePartitions(storage, disks, partitions, freespace):
         use_disk = None
         part_type = None
         growth = 0
+        # initialize the disklabel variable to None,
+        # so we can safely check if the variable was set or not
+        # (req_disks can be empty if using multipath with custom
+        # partitioning, in this case disklabel will not be set by the
+        # for loop and we need to check for that, as there are
+        # some check working with disklabel after the loop)
+        disklabel = None
         # loop through disks
         for _disk in req_disks:
             disklabel = disklabels[_disk.path]
@@ -1213,7 +1220,9 @@ def allocatePartitions(storage, disks, partitions, freespace):
                 log.debug("found free space for bootable request")
                 break
 
-        if getNextPartitionType(disklabel.partedDisk) is None:
+        # check if disklabel is set and if it is, check if the disk is
+        # out of partition slots (None = out of partition slots)
+        if disklabel is not None and getNextPartitionType(disklabel.partedDisk) is None:
             raise PartitioningError("no free partition slots on %s" % 
                                     _disk.name)
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list