[master 1/1] Move definition of _level attribute above super-constructor call.

mulkieran installerbot-noreply at redhat.com
Thu Apr 23 21:47:00 UTC 2015


From: mulhern <amulhern at redhat.com>

The basic problem is that level is a very important concept for md
so a lot of log messages log this information. Some of these
log messages are executed as a result of running the parent constructor.
The particular problem I saw is that self.updateSize() is called by
StorageDevice.__init__, which understandably logs the size,
and the size() methods logs its result, along with the level, leading to
an AttributeError. Now there will be no AttributeError, but the RAID
level will be displayed as None when this happens.

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

diff --git a/blivet/devices/md.py b/blivet/devices/md.py
index 95e3a86..82b5ec8 100644
--- a/blivet/devices/md.py
+++ b/blivet/devices/md.py
@@ -84,14 +84,14 @@ def __init__(self, name, level=None, major=None, minor=None, size=None,
         self._memberDevices = 0     # the number of active (non-spare) members
         self._totalDevices = 0      # the total number of members
 
+        # avoid attribute-defined-outside-init pylint warning
+        self._level = None
+
         super(MDRaidArrayDevice, self).__init__(name, fmt=fmt, uuid=uuid,
                                                 exists=exists, size=size,
                                                 parents=parents,
                                                 sysfsPath=sysfsPath)
 
-        # avoid attribute-defined-outside-init pylint warning
-        self._level = None
-
         try:
             self.level = level
         except errors.DeviceError as e:


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/9e42acc233249b7f02e1640834acbe5687145552


More information about the anaconda-patches mailing list