Modify gnt-node add to call external script
[ganeti-local] / daemons / ganeti-confd
index 958e1a1..d19157e 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 #
 
-# Copyright (C) 2009, Google Inc.
+# Copyright (C) 2009, 2010 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
@@ -48,6 +48,7 @@ from ganeti.confd import server as confd_server
 from ganeti import constants
 from ganeti import errors
 from ganeti import daemon
+from ganeti import netutils
 
 
 class ConfdAsyncUDPServer(daemon.AsyncUDPSocket):
@@ -58,14 +59,15 @@ class ConfdAsyncUDPServer(daemon.AsyncUDPSocket):
     """Constructor for ConfdAsyncUDPServer
 
     @type bind_address: string
-    @param bind_address: socket bind address ('' for all)
+    @param bind_address: socket bind address
     @type port: int
     @param port: udp port
     @type processor: L{confd.server.ConfdProcessor}
     @param processor: ConfdProcessor to use to handle queries
 
     """
-    daemon.AsyncUDPSocket.__init__(self)
+    family = netutils.IPAddress.GetAddressFamily(bind_address)
+    daemon.AsyncUDPSocket.__init__(self, family)
     self.bind_address = bind_address
     self.port = port
     self.processor = processor
@@ -117,7 +119,8 @@ class ConfdConfigurationReloader(object):
     self.inotify_handler = asyncnotifier.SingleFileEventHandler(self.wm,
                                                                 self.OnInotify,
                                                                 cfg_file)
-    self.notifier = asyncnotifier.AsyncNotifier(self.wm, self.inotify_handler)
+    notifier_class = asyncnotifier.ErrorLoggingAsyncNotifier
+    self.notifier = notifier_class(self.wm, self.inotify_handler)
 
     self.timer_handle = None
     self._EnableTimer()
@@ -250,6 +253,10 @@ def CheckConfd(_, args):
     print >> sys.stderr, "Need HMAC key %s to run" % constants.CONFD_HMAC_KEY
     sys.exit(constants.EXIT_FAILURE)
 
+  # TODO: once we have a cluster param specifying the address family
+  # preference, we need to check if the requested options.bind_address does not
+  # conflict with that. If so, we might warn or EXIT_FAILURE.
+
 
 def ExecConfd(options, _):
   """Main confd function, executed with PID file held