except Exception, msg:
# Ignore errors while loading the file and treat it as empty
self.data = {}
- sys.stderr.write("Empty or invalid state file. "
- "Using defaults. Error message: %s\n" % msg)
+ sys.stderr.write("Empty or invalid state file."
+ " Using defaults. Error message: %s\n" % msg)
if "instance" not in self.data:
self.data["instance"] = {}
notepad = WatcherState()
self.CheckInstances(notepad)
self.CheckDisks(notepad)
+ self.VerifyDisks()
notepad.Save()
def CheckDisks(self, notepad):
# secondary node.
for instance in GetInstanceList(with_secondaries=check_nodes):
try:
- self.messages.append(Message(NOTICE,
- "Activating disks for %s." %
- instance.name))
+ self.messages.append(Message(NOTICE, ("Activating disks for %s." %
+ instance.name)))
instance.ActivateDisks()
except Error, x:
self.messages.append(Message(ERROR, str(x)))
(instance.name, MAXTRIES)))
continue
try:
- self.messages.append(Message(NOTICE,
- "Restarting %s%s." %
- (instance.name, last)))
+ self.messages.append(Message(NOTICE, ("Restarting %s%s." %
+ (instance.name, last))))
instance.Restart()
except Error, x:
self.messages.append(Message(ERROR, str(x)))
else:
if notepad.NumberOfRestartAttempts(instance):
notepad.RemoveInstance(instance)
- msg = Message(NOTICE,
- "Restart of %s succeeded." % instance.name)
+ msg = Message(NOTICE, "Restart of %s succeeded." % instance.name)
self.messages.append(msg)
+ def VerifyDisks(self):
+ """Run gnt-cluster verify-disks.
+
+ """
+ result = DoCmd(['gnt-cluster', 'verify-disks', '--lock-retries=15'])
+ if result.output:
+ self.messages.append(Message(NOTICE, result.output))
+
def WriteReport(self, logfile):
"""Log all messages to file.