Add --enable-rapi parameter to configure
[ganeti-local] / daemons / ganeti-watcher
index 78de6c9..8b2b183 100755 (executable)
@@ -122,8 +122,8 @@ class WatcherState(object):
     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"] = {}
@@ -349,6 +349,7 @@ class Watcher(object):
     notepad = WatcherState()
     self.CheckInstances(notepad)
     self.CheckDisks(notepad)
+    self.VerifyDisks()
     notepad.Save()
 
   def CheckDisks(self, notepad):
@@ -367,9 +368,8 @@ class Watcher(object):
       # 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)))
@@ -402,9 +402,8 @@ class Watcher(object):
                                        (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)))
@@ -416,10 +415,17 @@ class Watcher(object):
       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.