All of lore.kernel.org
 help / color / mirror / Atom feed
From: kupcevic@sourceware.org <kupcevic@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci/modules/cluster ClusterConf.cpp Cl ...
Date: 15 Aug 2006 00:16:31 -0000	[thread overview]
Message-ID: <20060815001631.22539.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-08-15 00:16:31

Modified files:
	ricci/modules/cluster: ClusterConf.cpp ClusterStatus.cpp 
	                       Clusvcadm.cpp 

Log message:
	cluster module: add CS5 support

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterConf.cpp.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterStatus.cpp.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Clusvcadm.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4

--- conga/ricci/modules/cluster/ClusterConf.cpp	2006/08/10 22:53:08	1.4
+++ conga/ricci/modules/cluster/ClusterConf.cpp	2006/08/15 00:16:30	1.5
@@ -38,7 +38,11 @@
 #define CLUSTER_CONF_PATH    (CLUSTER_CONF_DIR + CLUSTER_CONF_NAME)
 
 #define CCS_TOOL_PATH        "/sbin/ccs_tool"
-#define CMAN_TOOL_PATH       "/sbin/cman_tool"
+
+
+static void 
+set_CMAN_TOOL_PATH();
+static String CMAN_TOOL_PATH;
 
 
 
@@ -69,6 +73,8 @@
 ClusterConf::set(const XMLObject& xml,
 		 bool propagate)
 {
+  set_CMAN_TOOL_PATH();
+  
   // sanity check
   if (xml.tag() != "cluster")
     throw String("invalid cluster.conf");
@@ -110,13 +116,7 @@
       if (status != 0)
 	throw String("ccs_tool failed");
       
-      bool cman = false;
-      for (list<XMLObject>::const_iterator iter = xml.children().begin();
-	   iter != xml.children().end();
-	   iter++)
-	if (iter->tag() == "cman")
-	  cman = true;
-      if (cman) {
+      if (is_cman(xml)) {
 	args.clear();
 	args.push_back("version");
 	args.push_back("-r");
@@ -143,18 +143,30 @@
 bool
 ClusterConf::is_gulm(const XMLObject& cluster_conf)
 {
-  return !is_cman(cluster_conf);
-}
-
-bool
-ClusterConf::is_cman(const XMLObject& cluster_conf)
-{
   for (list<XMLObject>::const_iterator iter = cluster_conf.children().begin();
        iter != cluster_conf.children().end();
        iter++)
-    if (iter->tag() == "cman")
+    if (iter->tag() == "gulm")
       return true;
   return false;
 }
 
+bool
+ClusterConf::is_cman(const XMLObject& cluster_conf)
+{
+  return !is_gulm(cluster_conf);
+}
+
 
+
+void 
+set_CMAN_TOOL_PATH()
+{
+  static bool path_set = false;
+  if (!path_set) {
+    CMAN_TOOL_PATH = "/sbin/cman_tool";
+    if (access(CMAN_TOOL_PATH.c_str(), X_OK)) 
+      CMAN_TOOL_PATH = "/usr/sbin/cman_tool";
+    path_set = true;
+  }
+}
--- conga/ricci/modules/cluster/ClusterStatus.cpp	2006/08/10 22:53:08	1.10
+++ conga/ricci/modules/cluster/ClusterStatus.cpp	2006/08/15 00:16:30	1.11
@@ -34,9 +34,11 @@
 using namespace std;
 
 
+static void 
+set_CMAN_TOOL_PATH();
+static String CMAN_TOOL_PATH;
 
 #define INITD_DIR_PATH        "/etc/init.d/"
-#define CMAN_TOOL_PATH        "/sbin/cman_tool"
 #define LSMOD_PATH            "/sbin/lsmod"
 #define MODPROBE_PATH         "/sbin/modprobe"
 #define CHKCONFIG_PATH        "/sbin/chkconfig"
@@ -109,87 +111,174 @@
 void 
 Cluster::start_node(bool cluster_startup)
 {
-  run_initd("ccsd", true, false);
-  if (ClusterConf::is_cman(ClusterConf::get()))
+  XMLObject stat = status();
+  
+  if (stat.get_attr("cluster_version") == "4") {
+    XMLObject cluster_conf(ClusterConf::get());
+    run_initd("ccsd", true, false);
+    if (ClusterConf::is_cman(cluster_conf))
+      try {
+	run_initd("cman", true, true);
+      } catch ( ... ) {
+	// try again
+	run_initd("cman", true, true);
+      }
+    else
+      run_initd("lock_gulmd", true, true);
+    
+    if (cluster_startup) {
+      // wait for all nodes to join -> avoid fencing
+      bool all_in = false;
+      while (all_in == false) {
+	all_in = true;
+	XMLObject stat = status();
+	for (list<XMLObject>::const_iterator iter = stat.children().begin();
+	     iter != stat.children().end();
+	     iter++)
+	  if (iter->tag() == "node")
+	    if (iter->get_attr("clustered") == "false")
+	      all_in = false;
+	if (all_in == false)
+	  sleep_sec(CLUMON_SYNC_TIME);
+      }
+    }
+    
+    run_initd("fenced", true, false);
+    run_initd("clvmd", true, false);
+    run_initd("gfs", true, false);
+    run_initd("rgmanager", true, true);
+    
+    // enable them on boot
+    
+    run_chkconfig("ccsd", true);
+    if (ClusterConf::is_cman(cluster_conf)) {
+      run_chkconfig("cman", true);
+      run_chkconfig("lock_gulmd", false);
+    } else {
+      run_chkconfig("cman", false);
+      run_chkconfig("lock_gulmd", true);
+    }
+    run_chkconfig("fenced", true);
+    run_chkconfig("clvmd", true);
+    run_chkconfig("gfs", true);
+    run_chkconfig("rgmanager", true);
+    
+  } else if (stat.get_attr("cluster_version") == "5") {
     try {
       run_initd("cman", true, true);
     } catch ( ... ) {
       // try again
       run_initd("cman", true, true);
     }
-  else
-    run_initd("lock_gulmd", true, true);
-  
-  if (cluster_startup) {
-    // wait for all nodes to join -> avoid fencing
-    bool all_in = false;
-    while (all_in == false) {
-      all_in = true;
-      XMLObject stat = status();
-      for (list<XMLObject>::const_iterator iter = stat.children().begin();
-	   iter != stat.children().end();
-	   iter++)
-	if (iter->tag() == "node")
-	  if (iter->get_attr("clustered") == "false")
-	    all_in = false;
-      if (all_in == false)
-	sleep_sec(CLUMON_SYNC_TIME);
+    
+    if (cluster_startup) {
+      // wait for all nodes to join -> avoid fencing
+      // trouble: fenced started from within cman!!!
+      /*
+      bool all_in = false;
+      while (all_in == false) {
+	all_in = true;
+	XMLObject stat = status();
+	for (list<XMLObject>::const_iterator iter = stat.children().begin();
+	     iter != stat.children().end();
+	     iter++)
+	  if (iter->tag() == "node")
+	    if (iter->get_attr("clustered") == "false")
+	      all_in = false;
+	if (all_in == false)
+	  sleep_sec(CLUMON_SYNC_TIME);
+      }
+      */
     }
-  }
-  
-  run_initd("fenced", true, false);
-  run_initd("clvmd", true, false);
-  run_initd("gfs", true, false);
-  run_initd("rgmanager", true, true);
-  
-  // enable them on boot
-  
-  run_chkconfig("ccsd", true);
-  if (ClusterConf::is_cman(ClusterConf::get()))
+    
+    bool use_qdisk = false;
+    XMLObject cluster_conf(ClusterConf::get()); // ccsd should bring newest cluster.conf
+    for (list<XMLObject>::const_iterator iter = cluster_conf.children().begin();
+	 iter != cluster_conf.children().end();
+	 iter++)
+      if (iter->tag() == "quorumd")
+	use_qdisk = true;
+    if (use_qdisk)
+      run_initd("qdiskd", true, false);
+    
+    run_initd("clvmd", true, false);
+    run_initd("gfs", true, false);
+    run_initd("gfs2", true, false);
+    run_initd("rgmanager", true, true);
+    
+    // enable them on boot
+    
     run_chkconfig("cman", true);
-  else
-    run_chkconfig("lock_gulmd", true);
-  run_chkconfig("fenced", true);
-  run_chkconfig("clvmd", true);
-  run_chkconfig("gfs", true);
-  run_chkconfig("rgmanager", true);
+    if (use_qdisk)
+      run_chkconfig("qdiskd", true);
+    else
+      run_chkconfig("qdiskd", false);
+    run_chkconfig("clvmd", true);
+    run_chkconfig("gfs", true);
+    run_chkconfig("gfs2", true);
+    run_chkconfig("rgmanager", true);
+  } else {
+    throw String("unsupported cluster version ") + stat.get_attr("cluster_version");
+  }
 }
 
 void 
 Cluster::stop_node(bool cluster_shutdown)
 {
+  XMLObject stat = status();
+  
   if (cluster_shutdown) {
     // stop all services, so they don't bounce around
-    XMLObject stat = status();
     for (list<XMLObject>::const_iterator iter = stat.children().begin();
 	 iter != stat.children().end();
 	 iter++)
       if (iter->tag() == "service")
 	if (iter->get_attr("running") == "true")
-	  Clusvcadm::stop(iter->get_attr("name"));
+	  try {
+	    Clusvcadm::stop(iter->get_attr("name"));
+	  } catch ( ... ) {}
   }
   
-  run_initd("rgmanager", false, true);
-  run_initd("gfs", false, false);
-  run_initd("clvmd", false, false);
-  run_initd("fenced", false, false);
-  if (ClusterConf::is_cman(ClusterConf::get()))
-    cman_leave();
-  else
-    gulm_leave();
-  run_initd("ccsd", false, false);
-  
-  // disable them on boot
-  
-  run_chkconfig("ccsd", false);
-  if (ClusterConf::is_cman(ClusterConf::get()))
+  if (stat.get_attr("cluster_version") == "4") {
+    run_initd("rgmanager", false, true);
+    run_initd("gfs", false, false);
+    run_initd("clvmd", false, false);
+    run_initd("fenced", false, false);
+    if (ClusterConf::is_cman(ClusterConf::get()))
+      cman_leave();
+    else
+      gulm_leave();
+    run_initd("ccsd", false, false);
+    
+    // disable them on boot
+    
+    run_chkconfig("ccsd", false);
     run_chkconfig("cman", false);
-  else
     run_chkconfig("lock_gulmd", false);
-  run_chkconfig("fenced", false);
-  run_chkconfig("clvmd", false);
-  run_chkconfig("gfs", false);
-  run_chkconfig("rgmanager", false);
+    run_chkconfig("fenced", false);
+    run_chkconfig("clvmd", false);
+    run_chkconfig("gfs", false);
+    run_chkconfig("rgmanager", false);
+    
+  } else if (stat.get_attr("cluster_version") == "5") {
+    run_initd("rgmanager", false, true);
+    run_initd("gfs2", false, false);
+    run_initd("gfs", false, false);
+    run_initd("clvmd", false, false);
+    run_initd("qdiskd", false, false);
+    run_initd("cman", false, true);
+    
+    // disable them on boot
+    
+    run_chkconfig("cman", false);
+    run_chkconfig("qdiskd", false);
+    run_chkconfig("clvmd", false);
+    run_chkconfig("gfs", false);
+    run_chkconfig("gfs2", false);
+    run_chkconfig("rgmanager", false);
+  } else {
+    throw String("unsupported cluster version ") + stat.get_attr("cluster_version");
+  }
 }
 
 
@@ -235,6 +324,8 @@
 void 
 cman_leave()
 {
+  set_CMAN_TOOL_PATH();
+  
   // when bz179627 gets fixed, just call service cman stop, but for now ...
   String out, err;
   int status;
@@ -276,3 +367,17 @@
   
   run_initd("lock_gulmd", false, true);
 }
+
+
+
+void 
+set_CMAN_TOOL_PATH()
+{
+  static bool path_set = false;
+  if (!path_set) {
+    CMAN_TOOL_PATH = "/sbin/cman_tool";
+    if (access(CMAN_TOOL_PATH.c_str(), X_OK)) 
+      CMAN_TOOL_PATH = "/usr/sbin/cman_tool";
+    path_set = true;
+  }
+}
--- conga/ricci/modules/cluster/Clusvcadm.cpp	2006/08/10 22:53:08	1.3
+++ conga/ricci/modules/cluster/Clusvcadm.cpp	2006/08/15 00:16:30	1.4
@@ -201,6 +201,17 @@
   String out, err;
   int status;
   vector<String> args;
+  
+  bool fast_available = false;  // clustat -f ?
+  args.push_back("-h");
+  if (utils::execute(CLUSTAT_TOOL_PATH, args, out, err, status, false))
+    throw String("missing clustat");
+  if (out.find("-f") != out.npos)
+    fast_available = true;
+  
+  args.clear();
+  if (fast_available)
+    args.push_back("-f");
   args.push_back("-x");
   if (utils::execute(CLUSTAT_TOOL_PATH, args, out, err, status, false))
     throw String("execute failed");
@@ -222,6 +233,7 @@
     else if (iter->tag() == "quorum")
       quorum_xml = *iter;
   
+  // TODO: groupmember missing in CS5
   if (quorum_xml.get_attr("groupmember") != "1")
     throw NoServiceManager();
   



             reply	other threads:[~2006-08-15  0:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-15  0:16 kupcevic [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-08-22 18:47 [Cluster-devel] conga/ricci/modules/cluster ClusterConf.cpp Cl rmccabe
2007-08-23 15:30 rmccabe
2007-09-18 20:17 rmccabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060815001631.22539.qmail@sourceware.org \
    --to=kupcevic@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.