[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/ricci/modules/service ServiceManager.cpp



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic sourceware org	2006-08-15 00:03:28

Modified files:
	ricci/modules/service: ServiceManager.cpp 

Log message:
	service module: add CS5 support

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4

--- conga/ricci/modules/service/ServiceManager.cpp	2006/08/10 22:53:09	1.3
+++ conga/ricci/modules/service/ServiceManager.cpp	2006/08/15 00:03:27	1.4
@@ -39,15 +39,24 @@
 #define DESC_SIG            String("# description:")
 
 
+static bool 
+RHEL4=false, RHEL5=false, FC5=false, FC6=false;
+static void
+set_release();
+
+
 
 
 Service::Service()
-{}
+{
+  set_release();
+}
 
 Service::Service(const String& name, bool enabled) :
   _name(counting_auto_ptr<String>(new String(name))),
   _enabled(counting_auto_ptr<bool>(new bool(enabled)))
 {
+  set_release();
   if (_name->empty())
     throw String("noname service???");
 }
@@ -117,7 +126,7 @@
       for (vector<String>::const_iterator iter = lines.begin();
 	   iter != lines.end();
 	   iter++) {
-	String line(*iter);
+	String line(utils::strip(*iter));
 	if (line.empty())
 	  continue;
 	if (line.find(DESC_SIG) != 0)
@@ -143,11 +152,6 @@
 	desc += s;
       }
       
-      // remove " from desc
-      String::size_type i;
-      while ((i = desc.find('"')) != desc.npos)
-	desc[i] = '\'';
-      
       _descr = counting_auto_ptr<String>(new String(desc));
       
       delete [] buff;
@@ -261,13 +265,16 @@
 
 
 ServiceSet::ServiceSet()
-{}
+{
+  set_release();
+}
 
 ServiceSet::ServiceSet(const String& name,
 		       const String& description) :
   _name(counting_auto_ptr<String>(new String(name))),
   _descr(counting_auto_ptr<String>(new String(description)))
 {
+  set_release();
   if (_name->empty())
     throw String("noname ServiceSet???");
 }
@@ -386,9 +393,10 @@
 
 
 
-
 ServiceManager::ServiceManager()
 {
+  set_release();
+  
   String out, err;
   int status;
   vector<String> args;
@@ -401,7 +409,7 @@
   for (vector<String>::const_iterator iter = lines.begin();
        iter != lines.end();
        iter++) {
-    vector<String> words = utils::split(*iter);
+    vector<String> words = utils::split(utils::strip(*iter));
     if (words.size() != 8)
       continue;
     String name = words[0];
@@ -424,30 +432,35 @@
 map<String, ServiceSet>
 ServiceManager::generate_sets()
 {
-  // TODO: set descriptions
-  
   map<String, ServiceSet> sets;
   
   list<String> servs;
   String name = "Cluster Base";
   String descr = "Cluster infrastructure: ccs, cman, fence";
+  if (RHEL4 || FC5) {
+    servs.push_back("ccsd");
+    servs.push_back("cman");
+    servs.push_back("fenced");
+  } else if (RHEL5 || FC6) {
+    servs.push_back("cman");
+    servs.push_back("qdiskd");
+  }
   ServiceSet s(name, descr);
-  servs.push_back("ccsd");
-  servs.push_back("cman");
-  servs.push_back("fenced");
   if (populate_set(s, servs))
     sets[name] = s;
   
   
-  servs.clear();
-  name = "Cluster Base - Gulm";
-  descr = "Cluster infrastructure: ccs, gulm, fence";
-  s = ServiceSet(name, descr);
-  servs.push_back("ccsd");
-  servs.push_back("lock_gulmd");
-  servs.push_back("fenced");
-  if (populate_set(s, servs))
-    sets[name] = s;
+  if (RHEL4 || FC5) {
+    servs.clear();
+    name = "Cluster Base - Gulm";
+    descr = "Cluster infrastructure: ccs, gulm, fence";
+    s = ServiceSet(name, descr);
+    servs.push_back("ccsd");
+    servs.push_back("lock_gulmd");
+    servs.push_back("fenced");
+    if (populate_set(s, servs))
+      sets[name] = s;
+  }
   
   
   servs.clear();
@@ -461,10 +474,17 @@
   
   servs.clear();
   name = "Clustered Storage";
-  descr = "Shared Storage: clvmd, gfs";
+  if (RHEL4 || FC5) {
+    descr = "Shared Storage: clvmd, gfs";
+    servs.push_back("clvmd");
+    servs.push_back("gfs");
+  } else if (RHEL5 || FC6) {
+    descr = "Shared Storage: clvmd, gfs, gfs2";
+    servs.push_back("clvmd");
+    servs.push_back("gfs");
+    servs.push_back("gfs2");
+  }
   s = ServiceSet(name, descr);
-  servs.push_back("clvmd");
-  servs.push_back("gfs");
   if (populate_set(s, servs))
     sets[name] = s;
   
@@ -649,3 +669,48 @@
     if (_sets.find(*iter) != _sets.end())
       sets.push_back(_sets[*iter]);
 }
+
+
+
+
+
+
+
+void
+set_release()
+{
+  static bool release_set = false;
+  if (!release_set) {
+    char* buff = 0;
+    String release;
+    try {
+      ifstream is("/etc/redhat-release");
+      is.seekg(0, ios::end);
+      unsigned int length = is.tellg();
+      is.seekg(0, ios::beg);
+      buff = new char[length];
+      is.read(buff, length);
+      
+      String rel(buff, length);
+      delete [] buff;
+      buff = 0;
+      
+      release = utils::strip(rel);
+    } catch ( ... ) {
+      delete [] buff;
+      throw;
+    }
+    
+    if (release.find("Nahant") != release.npos)
+      RHEL4 = true;
+    else if (release.find("Bordeaux") != release.npos)
+      FC5 = true;
+    else if (release.find("Fedora Core") != release.npos &&
+	     release.find("6") != release.npos)
+      // TODO: detect FC6
+      FC6 = true;
+    // TODO: detect RHEL5
+    
+    release_set = true;
+  }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]