summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-07-14 22:36:54 +0200
committerJoel Andres Granados <jgranado@redhat.com>2008-07-14 23:10:31 +0200
commitb52801801b20a7ddc65918fdafdfdb1ff7eacc98 (patch)
tree80a903faa6b2b9065c3e51bea4498da89054aecf /plugins
parentc99167e6d3fa4619b07a22ee8c6863c873adddb5 (diff)
downloadfirstaidkit-b52801801b20a7ddc65918fdafdfdb1ff7eacc98.tar.gz
firstaidkit-b52801801b20a7ddc65918fdafdfdb1ff7eacc98.tar.xz
firstaidkit-b52801801b20a7ddc65918fdafdfdb1ff7eacc98.zip
General fixes to plugin_mdadmcong.py
Diffstat (limited to 'plugins')
-rw-r--r--plugins/plugin_mdadmconf.py35
1 files changed, 23 insertions, 12 deletions
diff --git a/plugins/plugin_mdadmconf.py b/plugins/plugin_mdadmconf.py
index 9344c94..55bb6be 100644
--- a/plugins/plugin_mdadmconf.py
+++ b/plugins/plugin_mdadmconf.py
@@ -56,6 +56,7 @@ class MdadmConfig(Plugin):
if "ARRAY" in splitline:
self.currentFileDict[splitline[1]] = splitline
fd.close()
+
else:
self._reporting.info("File %s was not found."%
self.configFile, level = PLUGIN, origin = self)
@@ -74,7 +75,7 @@ class MdadmConfig(Plugin):
splitline = line.strip("\n").split(" ")
if "ARRAY" in splitline:
self.scannedFileDict[splitline[1]] = splitline
- self.scannedFileDict = out
+ self.scannedFile = out
else:
# This should make the flow go to clean. If there is an error we
# should not trust what mdadm tells us.
@@ -95,17 +96,22 @@ class MdadmConfig(Plugin):
"mdadm command.... Nothing to do.", level = PLUGIN,
origin = self)
self._result = ReturnSuccess
+ self._issue.set(checked=True, happened=False,
+ reporting=self._reporting, level=PLUGIN, origin=self)
return
+ # If nothing is detected the result is successfull.
+ self._result = ReturnSuccess
+
# If there is one difference between the configs, regarding the
# ARRAYS. We replace the config file. Lets check for missing arrays
# in the curren config file.
for key, value in self.scannedFileDict.iteritems():
if not self.currentFileDict.has_key(key):
self._reporting.info("Found that the current mdadm.conf is " \
- "missing %s."%value, level = PLUGIN, origin = self)
+ "missing: %s."%value, level = PLUGIN, origin = self)
self._result = ReturnFailure
- return
+
# Lets check for additional ARRAYS that should not be there.
for key, value in self.currentFileDict.iteritems():
if not self.scannedFileDict.has_key(key):
@@ -113,26 +119,26 @@ class MdadmConfig(Plugin):
"config file but was not detected by mdadm."%value,
level = PLUGIN, origin = self)
self._result = ReturnFailure
- return
- self._reporting.info("There was no problem found with the current " \
- "mdadm.conf file.", level = PLUGIN, origin = self)
+ if self._result == ReturnSuccess:
+ self._reporting.info("There was no problem found with the " \
+ "current mdadm.conf file.", level = PLUGIN, origin = self)
+
self._issue.set(checked = True,
happened = (self._result == ReturnFailure),
reporting = self._reporting, level = PLUGIN, origin = self)
- self._result = ReturnSuccess
def backup(self):
if os.path.isfile(self.configFile):
self._reporting.info("Making a backup of %s."%
self.configFile, level = PLUGIN, origin = self)
self.backupSpace.backupPath(self.configFile)
+
else:
self._reporting.info("It appears that the file %s does not "\
"exist. No backup attempt will be made."%self.configFile,
level = PLUGIN, origin = self)
- self._reporting.info("%s does not exist."%self.configFile,
- level = PLUGIN, origin = self)
+
self._result = ReturnSuccess
def fix(self):
@@ -140,19 +146,24 @@ class MdadmConfig(Plugin):
self._reporting.info("Going to write configuration to %s."%
self.configFile, level = PLUGIN, origin = self)
fd = open(self.configFile, "w")
+ fd.write("# File created by Firstaidkit.\n")
+ fd.write("# DEVICE partitions\n")
+ fd.write("# MAILADDR root\n")
fd.write(self.scannedFile)
fd.close()
self._reporting.info("Configuration file writen.", level = PLUGIN,
origin = self)
+
# The original mdadm.conf will be restore to
# mdadm.conf.firstaidkit, just in case.
self._reporting.info("Will put the old mdadm.conf in %s."%
os.path.join(Config.system.root,
- "etc/mdadm.conf.firstaidkit"),
- level = PLUGIN, origin = self)
+ self.configFile+".firstaidkit"), level=PLUGIN,
+ origin=self)
self.backupSpace.restoreName(self.configFile,
path = self.configFile+".firstaidkit")
- self.result = ReturnSuccess
+ self._result = ReturnSuccess
+
except IOError:
fd.close()
self._reporting.info("Error occurred while writing %s."%