HTools/Types.hs: more auto-repair types
[ganeti-local] / lib / daemon.py
index 66239fc..62ea1f4 100644 (file)
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2006, 2007, 2008, 2010, 2011 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -420,7 +420,7 @@ class AsyncAwaker(GanetiBaseAsyncoreDispatcher):
 
     """
     GanetiBaseAsyncoreDispatcher.__init__(self)
-    assert signal_fn == None or callable(signal_fn)
+    assert signal_fn is None or callable(signal_fn)
     (self.in_socket, self.out_socket) = socket.socketpair(socket.AF_UNIX,
                                                           socket.SOCK_STREAM)
     self.in_socket.setblocking(0)
@@ -621,6 +621,7 @@ def _VerifyDaemonUser(daemon_name):
     constants.NODED: getents.noded_uid,
     constants.CONFD: getents.confd_uid,
     }
+  assert daemon_name in daemon_uids, "Invalid daemon %s" % daemon_name
 
   return (daemon_uids[daemon_name] == running_uid, running_uid,
           daemon_uids[daemon_name])
@@ -777,15 +778,16 @@ def GenericMain(daemon_name, optionparser,
   if check_fn is not None:
     check_fn(options, args)
 
+  log_filename = constants.DAEMONS_LOGFILES[daemon_name]
+
   if options.fork:
     utils.CloseFDs()
-    (wpipe, stdio_reopen_fn) = \
-      utils.Daemonize(logfile=constants.DAEMONS_LOGFILES[daemon_name])
+    (wpipe, stdio_reopen_fn) = utils.Daemonize(logfile=log_filename)
   else:
     (wpipe, stdio_reopen_fn) = (None, None)
 
   log_reopen_fn = \
-    utils.SetupLogging(constants.DAEMONS_LOGFILES[daemon_name], daemon_name,
+    utils.SetupLogging(log_filename, daemon_name,
                        debug=options.debug,
                        stderr_logging=not options.fork,
                        multithreaded=multithreaded,