[blivet][PATCH] Remove redundant check for parents in Blivet.newBTRFS.

David Lehman dlehman at redhat.com
Mon Sep 29 18:15:36 UTC 2014


We already check parent type in BTRFSSubVolumeDevice, but we should be
using BTRFSValueError if those checks fail.

Resolves: rhbz#1072285
---
 blivet/__init__.py | 5 -----
 blivet/devices.py  | 4 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/blivet/__init__.py b/blivet/__init__.py
index bde0120..cf1e426 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -1205,11 +1205,6 @@ class Blivet(object):
 
         if kwargs.pop("subvol", False):
             dev_class = BTRFSSubVolumeDevice
-            # make sure there's a valid parent device
-            parents = kwargs.get("parents", [])
-            if not parents or len(parents) != 1 or \
-               not isinstance(parents[0], BTRFSVolumeDevice):
-                raise ValueError("new btrfs subvols require a parent volume")
 
             # set up the subvol name, using mountpoint if necessary
             if not name:
diff --git a/blivet/devices.py b/blivet/devices.py
index 6e723d0..03d7e90 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -5463,10 +5463,10 @@ class BTRFSSubVolumeDevice(BTRFSDevice):
         super(BTRFSSubVolumeDevice, self).__init__(*args, **kwargs)
 
         if len(self.parents) != 1:
-            raise errors.DeviceError("%s %s must have exactly one parent." % (self.type, self.name))
+            raise errors.BTRFSValueError("%s must have exactly one parent." % self.type)
 
         if not isinstance(self.parents[0], BTRFSDevice):
-            raise errors.DeviceError("%s %s's unique parent must be a BTRFSDevice." % (self.type, self.name))
+            raise errors.BTRFSValueError("%s unique parent must be a BTRFSDevice." % self.type)
 
         self.volume._addSubVolume(self)
 
-- 
1.9.3



More information about the anaconda-patches mailing list