[blivet:rhel7/master 4/4] Separate sanityCheck-ing from doAutoPartition (#1060255)
mulhern
amulhern at redhat.com
Mon Feb 10 15:21:12 UTC 2014
Related: rhbz#1060255
Moves the sanityCheck call into a separate method. The separate method
doesn't do much but allows to throw a PartitioningError in some cases where
that is expected.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/partitioning.py | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index abaf1b3..26f1606 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -285,6 +285,8 @@ def _scheduleVolumes(storage, devs):
storage.createDevice(dev)
def doAutoPartition(storage, data):
+ """Calculates a partition scheme.
+ """
log.debug("doAutoPart: %s" % storage.doAutoPart)
log.debug("encryptedAutoPart: %s" % storage.encryptedAutoPart)
log.debug("autoPartType: %s" % storage.autoPartType)
@@ -325,14 +327,25 @@ def doAutoPartition(storage, data):
storage.setUpBootLoader()
- # now do a full check of the requests
- (errors, warnings) = storage.sanityCheck()
+def sanityCheck(storage):
+ """Do a sanity check in a partitioning context.
+
+ :param storage: an instance of the Blivet class
+
+ Logs all SanityErrors and SanityWarnings, SanityErrors first.
+
+ Raises a partitioning error on SanityErrors.
+ """
+ exns = storage.sanityCheck()
+ errors = [exc for exc in exns if isinstance(exc, SanityError)]
+ warnings = [exc for exc in exns if isinstance(exc, SanityWarning)]
for error in errors:
- log.error(error)
+ log.error(error.message)
for warning in warnings:
- log.warning(warning)
+ log.warning(warning.message)
+
if errors:
- raise PartitioningError("\n".join(errors))
+ raise PartitioningError("\n".join(error.message for error in errors))
def partitionCompare(part1, part2):
""" More specifically defined partitions come first.
--
1.8.3.1
More information about the anaconda-patches
mailing list