On Mon, 2013-10-14 at 16:32 +0200, Martin Kolman wrote:
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@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
req_disks cannot be empty unless there are no disks available. See the else around line 1035, which sets req_disks to the full set of available disks if it was initially empty.
# 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)
If we arrive here and disklabel is not set we have bigger problems. Unfortunately this function is a huge mess, so this is not clear.