Merge branch 'devel-2.1' into stable-2.1
[ganeti-local] / daemons / ganeti-confd
index 421e73c..b7198d0 100755 (executable)
@@ -26,12 +26,16 @@ It uses UDP+HMAC for authentication with a global cluster key.
 
 """
 
+# pylint: disable-msg=C0103
+# C0103: Invalid name ganeti-confd
+
 import os
 import sys
 import logging
 import time
 
 try:
+  # pylint: disable-msg=E0611
   from pyinotify import pyinotify
 except ImportError:
   import pyinotify
@@ -44,7 +48,6 @@ from ganeti.confd import server as confd_server
 from ganeti import constants
 from ganeti import errors
 from ganeti import daemon
-from ganeti import ssconf
 
 
 class ConfdAsyncUDPServer(daemon.AsyncUDPSocket):
@@ -102,6 +105,8 @@ class ConfdInotifyEventHandler(pyinotify.ProcessEvent):
     # no need to call the parent's constructor
     self.watch_manager = watch_manager
     self.callback = callback
+    # pylint: disable-msg=E1103
+    # pylint for some reason doesn't see the below constants
     self.mask = pyinotify.EventsCodes.IN_IGNORED | \
                 pyinotify.EventsCodes.IN_MODIFY
     self.file = filename
@@ -319,10 +324,14 @@ class ConfdConfigurationReloader(object):
     self._ResetTimer()
 
 
-def CheckConfd(options, args):
+def CheckConfd(_, args):
   """Initial checks whether to run exit with a failure.
 
   """
+  if args: # confd doesn't take any arguments
+    print >> sys.stderr, ("Usage: %s [-f] [-d] [-b ADDRESS]" % sys.argv[0])
+    sys.exit(constants.EXIT_FAILURE)
+
   # TODO: collapse HMAC daemons handling in daemons GenericMain, when we'll
   # have more than one.
   if not os.path.isfile(constants.HMAC_CLUSTER_KEY):
@@ -330,10 +339,13 @@ def CheckConfd(options, args):
     sys.exit(constants.EXIT_FAILURE)
 
 
-def ExecConfd(options, args):
+def ExecConfd(options, _):
   """Main confd function, executed with PID file held
 
   """
+  # TODO: clarify how the server and reloader variables work (they are
+  # not used)
+  # pylint: disable-msg=W0612
   mainloop = daemon.Mainloop()
 
   # Asyncronous confd UDP server
@@ -344,7 +356,7 @@ def ExecConfd(options, args):
     # If enabling the processor has failed, we can still go on, but confd will
     # be disabled
     logging.warning("Confd is starting in disabled mode")
-    pass
+
   server = ConfdAsyncUDPServer(options.bind_address, options.port, processor)
 
   # Configuration reloader