If asked on the command line we'll update the mc list file with fresh
data from the cluster

Signed-off-by: Guido Trotter <[email protected]>
---
 daemons/ganeti-nld |   10 +++++++++-
 lib/config.py      |    1 +
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/daemons/ganeti-nld b/daemons/ganeti-nld
index 9ee0444..f1bed06 100755
--- a/daemons/ganeti-nld
+++ b/daemons/ganeti-nld
@@ -100,7 +100,9 @@ class NLDConfdCallback(object):
     mc_list = up.server_reply.answer
     logging.debug("Updating confd peers: %s" % mc_list)
     up.client.UpdatePeerList(mc_list)
-    # TODO: save updates list, but only on endpoints
+    if self.nld_config.out_mc_file:
+      utils.WriteFile(self.nld_config.out_mc_file,
+                      data="\n".join(mc_list))
 
   def UpdateInstanceIPList(self, up):
     for ip in up.server_reply.answer:
@@ -254,6 +256,9 @@ class NetworkLookupDaemon(object):
       print >> sys.stderr, "Configuration error: %s" % err
       sys.exit(gnt_constants.EXIT_FAILURE)
 
+    if options.update_mc_file:
+      self.config.out_mc_file = options.mc_file
+
   def ExecNld(self, options, args):
     """Main confd function, executed with PID file held
 
@@ -286,6 +291,9 @@ def main():
   parser.add_option("--mc-list", dest="mc_file",
                     help="Master Candidates addresses file",
                     default=default_mclist, type="string")
+  parser.add_option("--update-mc-file", dest="update_mc_file",
+                    help="Periodically update the MC file"
+                    default=False, action="store_true")
 
   dirs = [(val, gnt_constants.RUN_DIRS_MODE)
           for val in gnt_constants.SUB_RUN_DIRS]
diff --git a/lib/config.py b/lib/config.py
index 57eb715..8768cbb 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -81,6 +81,7 @@ class 
BashFragmentConfigParser(objects.SerializableConfigParser):
 class NLDConfig(objects.ConfigObject):
   __slots__ = objects.ConfigObject.__slots__ + [
     "endpoints",
+    "out_mc_file",
     ]
 
   @staticmethod
-- 
1.6.5

Reply via email to