Previously the constructed raised an IndexError when calling the super
class constructor and trying to access its first parent to discover its
own path. Raising the exception earlier makes the constructor's
requirements more clear.
Note that the exception is raised if the "parents" keyword argument does not
exists. Checking that the parents field has been set to an acceptable value
by the superconstructor leaves it too late, the IndexError will have already
occurrred by then.
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
blivet/devices.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/blivet/devices.py b/blivet/devices.py
index f8bc836..fe3bb1c 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -4252,6 +4252,9 @@ class BTRFSDevice(StorageDevice):
if not args or not args[0]:
args = ("btrfs.%d" % Device._id,)
+ if "parents" not in kwargs or kwargs["parents"] is None:
+ raise ValueError("BTRFSDevice must have at least one parent")
+
self.req_size = kwargs.pop("size", None)
super(BTRFSDevice, self).__init__(*args, **kwargs)
--
1.8.3.1