[blivet 08/13] Robustify use of defaultSubVolumeID field.
mulhern
amulhern at redhat.com
Fri Dec 6 16:50:08 UTC 2013
* Set it to None in the constructor to avoid an attribute error
if defaultSubVolume is called before _getDefaultSubVolumeID is called.
* Give it an underscore, to emphasize that it is private.
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/devices.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py
index b22cb38..b5435cc 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -4367,6 +4367,8 @@ class BTRFSVolumeDevice(BTRFSDevice):
mountopts="subvolid=%d" % self.vol_id)
self.originalFormat = copy.copy(self.format)
+ self._defaultSubVolumeID = None
+
def _setFormat(self, format):
""" Set the Device's format. """
super(BTRFSVolumeDevice, self)._setFormat(format)
@@ -4497,19 +4499,19 @@ class BTRFSVolumeDevice(BTRFSDevice):
except BTRFSError as e:
log.debug("failed to get default subvolume id: %s" % e)
- self.defaultSubVolumeID = subvolid
+ self._defaultSubVolumeID = subvolid
@property
def defaultSubVolume(self):
default = None
- if self.defaultSubVolumeID is None:
+ if self._defaultSubVolumeID is None:
return None
- if self.defaultSubVolumeID == self.vol_id:
+ if self._defaultSubVolumeID == self.vol_id:
return self
for sv in self.subvolumes:
- if sv.vol_id == self.defaultSubVolumeID:
+ if sv.vol_id == self._defaultSubVolumeID:
default = sv
break
--
1.8.3.1
More information about the anaconda-patches
mailing list