From cb91d46e65af89484bf1f017e39730594fed836e Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 25 Jul 2007 11:46:06 +0000
Subject: [PATCH] Since the watcher can run on all nodes, let's get rid of the
 cron file handling, as it can be static and outside of ganeti.

This also means we can get rid of a lot of infrastructure too:
  - the master/node config files checkers
  - one rpc function
---
 daemons/ganeti-noded |  3 ---
 lib/backend.py       | 21 ---------------------
 lib/cmdlib.py        | 41 ++++-------------------------------------
 lib/constants.py     | 27 ---------------------------
 lib/rpc.py           | 11 -----------
 5 files changed, 4 insertions(+), 99 deletions(-)

diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index ede5e79cc..f9016e35f 100755
--- a/daemons/ganeti-noded
+++ b/daemons/ganeti-noded
@@ -243,9 +243,6 @@ class ServerObject(pb.Avatar):
   def perspective_version(self, params):
     return constants.PROTOCOL_VERSION
 
-  def perspective_configfile_list(self, params):
-    return backend.ListConfigFiles()
-
   def perspective_upload_file(self, params):
     return backend.UploadFile(*params)
 
diff --git a/lib/backend.py b/lib/backend.py
index 3064f21e3..46b104786 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -43,23 +43,6 @@ from ganeti import objects
 from ganeti import ssconf
 
 
-def ListConfigFiles():
-  """Return a list of the config files present on the local node.
-  """
-
-  configfiles = []
-
-  for testfile in constants.MASTER_CONFIGFILES:
-    if os.path.exists(testfile):
-      configfiles.append(testfile)
-
-  for testfile in constants.NODE_CONFIGFILES:
-    if os.path.exists(testfile):
-      configfiles.append(testfile)
-
-  return configfiles
-
-
 def StartMaster():
   """Activate local node as master node.
 
@@ -75,8 +58,6 @@ def StartMaster():
                  " error: '%s'" % (result.cmd, result.output))
     return False
 
-  utils.RemoveFile(constants.MASTER_CRON_LINK)
-  os.symlink(constants.MASTER_CRON_FILE, constants.MASTER_CRON_LINK)
   return True
 
 
@@ -95,8 +76,6 @@ def StopMaster():
                  " error: '%s'" % (result.cmd, result.output))
     return False
 
-  utils.RemoveFile(constants.MASTER_CRON_LINK)
-
   return True
 
 
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 618998b9d..b9cf8986c 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -738,7 +738,6 @@ class LUVerifyCluster(NoHooksLU):
           bad = True
     return bad
 
-
   def _VerifyOrphanInstances(self, instancelist, node_instance, feedback_fn):
     """Verify the list of running instances.
 
@@ -754,28 +753,6 @@ class LUVerifyCluster(NoHooksLU):
           bad = True
     return bad
 
-  def _VerifyNodeConfigFiles(self, ismaster, node, file_list, feedback_fn):
-    """Verify the list of node config files"""
-
-    bad = False
-    for file_name in constants.MASTER_CONFIGFILES:
-      if ismaster and file_name not in file_list:
-        feedback_fn("  - ERROR: master config file %s missing from master"
-                    " node %s" % (file_name, node))
-        bad = True
-      elif not ismaster and file_name in file_list:
-        feedback_fn("  - ERROR: master config file %s should not exist"
-                    " on non-master node %s" % (file_name, node))
-        bad = True
-
-    for file_name in constants.NODE_CONFIGFILES:
-      if file_name not in file_list:
-        feedback_fn("  - ERROR: config file %s missing from node %s" %
-                    (file_name, node))
-        bad = True
-
-    return bad
-
   def CheckPrereq(self):
     """Check prerequisites.
 
@@ -801,11 +778,12 @@ class LUVerifyCluster(NoHooksLU):
 
     # FIXME: verify OS list
     # do local checksums
-    file_names = constants.CLUSTER_CONF_FILES
+    file_names = list(self.sstore.GetFileList())
+    file_names.append(constants.SSL_CERT_FILE)
+    file_names.append(constants.CLUSTER_CONF_FILE)
     local_checksums = utils.FingerprintFiles(file_names)
 
     feedback_fn("* Gathering data (%d nodes)" % len(nodelist))
-    all_configfile = rpc.call_configfile_list(nodelist)
     all_volumeinfo = rpc.call_volume_list(nodelist, vg_name)
     all_instanceinfo = rpc.call_instance_list(nodelist)
     all_vglist = rpc.call_vg_list(nodelist)
@@ -823,16 +801,6 @@ class LUVerifyCluster(NoHooksLU):
                                 all_vglist[node], all_nvinfo[node],
                                 all_rversion[node], feedback_fn)
       bad = bad or result
-      # node_configfile
-      nodeconfigfile = all_configfile[node]
-
-      if not nodeconfigfile:
-        feedback_fn("  - ERROR: connection to %s failed" % (node))
-        bad = True
-        continue
-
-      bad = bad or self._VerifyNodeConfigFiles(node==master, node,
-                                               nodeconfigfile, feedback_fn)
 
       # node_volume
       volumeinfo = all_volumeinfo[node]
@@ -1452,8 +1420,7 @@ class LUAddNode(LogicalUnit):
           logger.Error("copy of file %s to node %s failed" %
                        (fname, to_node))
 
-    to_copy = [constants.MASTER_CRON_FILE]
-    to_copy.extend(ss.GetFileList())
+    to_copy = ss.GetFileList()
     for fname in to_copy:
       if not ssh.CopyFileToNode(node, fname):
         logger.Error("could not copy file %s to node %s" % (fname, node))
diff --git a/lib/constants.py b/lib/constants.py
index c68506bc0..4477a4325 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -33,15 +33,9 @@ EXPORT_VERSION = 0
 DATA_DIR = "/var/lib/ganeti"
 CLUSTER_CONF_FILE = DATA_DIR + "/config.data"
 SSL_CERT_FILE = DATA_DIR + "/server.pem"
-HYPERCONF_FILE = DATA_DIR + "/hypervisor"
 WATCHER_STATEFILE = DATA_DIR + "/restart_state"
 
-ETC_DIR = "/etc/ganeti"
-
-MASTER_CRON_FILE = ETC_DIR + "/master-cron"
-MASTER_CRON_LINK = "/etc/cron.d/ganeti-master-cron"
 NODE_INITD_SCRIPT = "/etc/init.d/ganeti"
-NODE_INITD_NAME = "ganeti"
 DEFAULT_NODED_PORT = 1811
 FIRST_DRBD_PORT = 11000
 LAST_DRBD_PORT = 14999
@@ -84,27 +78,6 @@ INSTANCE_IMPORT = "import"
 DISK_TEMPLATES = frozenset([DT_DISKLESS, DT_PLAIN,
                             DT_LOCAL_RAID1, DT_REMOTE_RAID1])
 
-# file groups
-CLUSTER_CONF_FILES = ["/etc/hosts",
-                      "/etc/ssh/ssh_known_hosts",
-                      "/etc/ssh/ssh_host_dsa_key",
-                      "/etc/ssh/ssh_host_dsa_key.pub",
-                      "/etc/ssh/ssh_host_rsa_key",
-                      "/etc/ssh/ssh_host_rsa_key.pub",
-                      "/root/.ssh/authorized_keys",
-                      "/root/.ssh/id_dsa",
-                      "/root/.ssh/id_dsa.pub",
-                      CLUSTER_CONF_FILE,
-                      SSL_CERT_FILE,
-                      MASTER_CRON_FILE,
-                      ]
-
-MASTER_CONFIGFILES = [MASTER_CRON_LINK,]
-
-NODE_CONFIGFILES = [NODE_INITD_SCRIPT,
-                    "/etc/rc2.d/S20%s" % NODE_INITD_NAME,
-                    "/etc/rc0.d/K80%s" % NODE_INITD_NAME]
-
 # import/export config options
 INISECT_EXP = "export"
 INISECT_INS = "instance"
diff --git a/lib/rpc.py b/lib/rpc.py
index ce4d7872f..e632e49d5 100644
--- a/lib/rpc.py
+++ b/lib/rpc.py
@@ -451,17 +451,6 @@ def call_version(node_list):
   return c.getresult()
 
 
-def call_configfile_list(node_list):
-  """Return list of existing configuration files.
-
-  This is a multi-node call.
-
-  """
-  c = Client("configfile_list", [])
-  c.connect_list(node_list)
-  c.run()
-  return c.getresult()
-
 def call_blockdev_create(node, bdev, size, on_primary):
   """Request creation of a given block device.
 
-- 
GitLab