[blivet 07/13] Check that a BTRFS subvolume has exactly one parent in constructor.

mulhern amulhern at redhat.com
Fri Dec 6 16:50:07 UTC 2013


Signed-off-by: mulhern <amulhern at redhat.com>
---
 blivet/devices.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/blivet/devices.py b/blivet/devices.py
index 8a1c4a6..b22cb38 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -4549,8 +4549,15 @@ class BTRFSSubVolumeDevice(BTRFSDevice):
 
     def __init__(self, *args, **kwargs):
         self.vol_id = kwargs.pop("vol_id", None)
+
         super(BTRFSSubVolumeDevice, self).__init__(*args, **kwargs)
 
+        if len(self.parents) != 1:
+            raise DeviceError("%s %s must have exactly one parent." % (self.type, self.name))
+
+        if not isinstance(self.parents[0], BTRFSDevice):
+            raise DeviceError("%s %s's unique parent must be a BTRFSDevice." % (self.type, self.name))
+
         self.volume._addSubVolume(self)
 
     @property
-- 
1.8.3.1



More information about the anaconda-patches mailing list