From: "David Lehman" <dlehman(a)redhat.com>
To: anaconda-patches(a)lists.fedorahosted.org
Sent: Tuesday, September 23, 2014 11:32:17 AM
Subject: [PATCH 1/2] Handle failures to instantiate storage devices when parsing
kickstart.
Resolves: rhbz#1072285
---
pyanaconda/kickstart.py | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index c0cb61c..f4fc6d8 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -26,7 +26,7 @@ from blivet.devicelibs import swap as swap_lib
from blivet.formats import getFormat
from blivet.partitioning import doPartitioning
from blivet.partitioning import growLVM
-from blivet.errors import PartitioningError
+from blivet.errors import PartitioningError, StorageError
from blivet.size import Size
from blivet import udev
from blivet.platform import platform
@@ -34,7 +34,6 @@ import blivet.iscsi
import blivet.fcoe
import blivet.zfcp
import blivet.arch
-import blivet.errors
import glob
from pyanaconda import iutil
@@ -469,7 +468,7 @@ class BTRFSData(commands.btrfs.F17_BTRFSData):
metaDataLevel=self.metaDataLevel,
dataLevel=self.dataLevel,
parents=members)
- except blivet.errors.BTRFSValueError as e:
+ except (StorageError, ValueError) as e:
raise KickstartValueError(formatErrorMsg(self.lineno,
msg=e.message))
storage.createDevice(request)
@@ -942,7 +941,8 @@ class LogVolData(commands.logvol.F20_LogVolData):
else:
maxsize = None
- request = storage.newLV(fmt=fmt,
+ try:
+ request = storage.newLV(fmt=fmt,
name=self.name,
parents=parents,
size=size,
@@ -952,6 +952,8 @@ class LogVolData(commands.logvol.F20_LogVolData):
maxsize=maxsize,
percent=self.percent,
**pool_args)
+ except (StorageError, ValueError) as e:
+ raise KickstartValueError(formatErrorMsg(self.lineno,
msg=e.message))
storage.createDevice(request)
if ty == "swap":
@@ -1234,7 +1236,10 @@ class PartitionData(commands.partition.F18_PartData):
# tmpfs mounts are not disks and don't occupy a disk partition,
# so handle them here
elif self.fstype == "tmpfs":
- request = storage.newTmpFS(**kwargs)
+ try:
+ request = storage.newTmpFS(**kwargs)
+ except (StorageError, ValueError) as e:
+ raise KickstartValueError(formatErrorMsg(self.lineno,
msg=e.message))
storage.createDevice(request)
else:
# If a previous device has claimed this mount point, delete the
@@ -1246,7 +1251,11 @@ class PartitionData(commands.partition.F18_PartData):
except KeyError:
pass
- request = storage.newPartition(**kwargs)
+ try:
+ request = storage.newPartition(**kwargs)
+ except (StorageError, ValueError) as e:
+ raise KickstartValueError(formatErrorMsg(self.lineno,
msg=e.message))
+
storage.createDevice(request)
if ty == "swap":
storage.addFstabSwap(request)
@@ -1416,8 +1425,8 @@ class RaidData(commands.raid.F18_RaidData):
try:
request = storage.newMDArray(**kwargs)
- except ValueError as e:
- raise KickstartValueError(formatErrorMsg(self.lineno,
msg=str(e)))
+ except (StorageError, ValueError) as e:
+ raise KickstartValueError(formatErrorMsg(self.lineno,
msg=e.message))
storage.createDevice(request)
@@ -1640,9 +1649,12 @@ class
VolGroupData(commands.volgroup.F21_VolGroupData):
raise KickstartValueError(formatErrorMsg(self.lineno,
msg=_("The volume group name \"%s\" is already in
use.")
% self.vgname))
else:
- request = storage.newVG(parents=pvs,
+ try:
+ request = storage.newVG(parents=pvs,
name=self.vgname,
peSize=pesize)
+ except (StorageError, ValueError) as e:
+ raise KickstartValueError(formatErrorMsg(self.lineno,
msg=e.message))
storage.createDevice(request)
if self.reserved_space:
--
1.9.3
_______________________________________________
anaconda-patches mailing list
anaconda-patches(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
I introduced BTRFSValueError in part so we could distinguish between
us stupidly dividing by zero and the kickstart asking for unacceptable
metadata.
With this change we lose the distinction, which feels like a step back.
- mulhern