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

[Cluster-devel] conga/ricci/modules/rpm PackageHandler.cpp Pac ...



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

Modified files:
	ricci/modules/rpm: PackageHandler.cpp PackageHandler.h 

Log message:
	rpm module: add RHEL5 support, update rpm list to include CS5 rpms

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

--- conga/ricci/modules/rpm/PackageHandler.cpp	2006/08/10 22:53:08	1.4
+++ conga/ricci/modules/rpm/PackageHandler.cpp	2006/08/15 00:06:48	1.5
@@ -37,40 +37,20 @@
 #define UNAME_PATH     "/bin/uname"
 
 
+static bool 
+RHEL4=false, RHEL5=false, FC5=false, FC6=false;
+static void
+set_release();
+
 
 
 // class PackageInstaller
 
 
 
-PackageInstaller::PackageInstaller() :
-  RHEL4(false),
-  FC5(false)
-{
-  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;
+PackageInstaller::PackageInstaller()
+{
+  set_release();
 }
 
 PackageInstaller::~PackageInstaller()
@@ -80,7 +60,7 @@
 bool
 PackageInstaller::available()
 {
-  if (RHEL4) {
+  if (RHEL4 || RHEL5) {
     bool rhn_available = true;
     // check existance of /etc/sysconfig/rhn/systemid
     if (access("/etc/sysconfig/rhn/systemid", F_OK))
@@ -97,7 +77,7 @@
 	rhn_available = false;
     }
     return rhn_available;
-  } else if (FC5) {
+  } else if (FC5 || FC6) {
     // nothing to check for, maybe ping repository???
     return true;
   } else
@@ -116,7 +96,7 @@
   int status;
   vector<String> args;
   
-  if (RHEL4) {
+  if (RHEL4 || RHEL5) {
     out = err = "";
     args.clear();
     args.push_back("--showall");
@@ -139,7 +119,7 @@
       rpms[name] = version;
     }
     
-  } else if (FC5) {
+  } else if (FC5 || FC6) {
     out = err = "";
     args.clear();
     args.push_back("-y");
@@ -183,7 +163,7 @@
   int status;
   vector<String> args;
   
-  if (RHEL4) {
+  if (RHEL4 || RHEL5) {
     out = err = "";
     args.clear();
     for (vector<String>::size_type i=0; i<rpms.size(); i++)
@@ -194,7 +174,7 @@
       throw String(UP2DATE_PATH) + " failed";
     return true;
     
-  } else if (FC5) {
+  } else if (FC5 || FC6) {
     // install
     vector<String> rpms_to_install;
     out = err = "";
@@ -262,12 +242,14 @@
 
 
 Package::Package()
-{}
+{
+  set_release();
+}
 
 Package::Package(const String& name) :
   name(name)
 {
-  
+  set_release();
 }
 
 Package::~Package()
@@ -293,14 +275,18 @@
   installed(false),
   in_repo(false),
   upgradeable(false)
-{}
+{
+  set_release();
+}
 
 PackageSet::PackageSet(const String& name) :
   name(name),
   installed(false),
   in_repo(false),
   upgradeable(false)
-{}
+{
+  set_release();
+}
 
 PackageSet::~PackageSet()
 {}
@@ -327,6 +313,8 @@
 
 PackageHandler::PackageHandler()
 {
+  set_release();
+  
   
   // get installed packages
   
@@ -356,7 +344,7 @@
     _packages[name] = pack;
   }
   
-  // probe RHN
+  // probe repositories
   if (repo_available()) {
     map<String, String> avail_rpms = _pi.available_rpms();
     for (map<String, String>::const_iterator iter = avail_rpms.begin();
@@ -404,8 +392,10 @@
   PackageSet set = build_cluster_base_set();
   sets[set.name] = set;
   
-  set = build_cluster_base_gulm_set();
-  sets[set.name] = set;
+  if (RHEL4 || FC5) {
+    set = build_cluster_base_gulm_set();
+    sets[set.name] = set;
+  }
   
   set = build_cluster_services_set();
   sets[set.name] = set;
@@ -423,30 +413,36 @@
 PackageHandler::build_cluster_base_set()
 {
   PackageSet set("Cluster Base");
-  set.packages.push_back("ccs");
-  set.packages.push_back("cman");
-  set.packages.push_back("dlm");
-  set.packages.push_back("fence");
   
-  // find kernel type
-  String out, err;
-  int status;
-  vector<String> args;
-  args.push_back("-r");
-  if (utils::execute(UNAME_PATH, args, out, err, status, true))
-    throw String("execute failed");
-  if (status != 0)
-    throw String("uname -r failed");
-  if (out.find("smp") != out.npos) {
-    set.packages.push_back("cman-kernel-smp");
-    set.packages.push_back("dlm-kernel-smp");
-  } else if (out.find("hugemem") != out.npos) {
-    set.packages.push_back("cman-kernel-hugemen");
-    set.packages.push_back("dlm-kernel-hugemem");
-  } else {
-    set.packages.push_back("cman-kernel");
-    set.packages.push_back("dlm-kernel");
+  if (RHEL4 || FC5) {
+    set.packages.push_back("ccs");
+    set.packages.push_back("cman");
+    set.packages.push_back("dlm");
+    set.packages.push_back("fence");
+    
+    // find kernel type
+    String out, err;
+    int status;
+    vector<String> args;
+    args.push_back("-r");
+    if (utils::execute(UNAME_PATH, args, out, err, status, true))
+      throw String("execute failed");
+    if (status != 0)
+      throw String("uname -r failed");
+    if (out.find("smp") != out.npos) {
+      set.packages.push_back("cman-kernel-smp");
+      set.packages.push_back("dlm-kernel-smp");
+    } else if (out.find("hugemem") != out.npos) {
+      set.packages.push_back("cman-kernel-hugemen");
+      set.packages.push_back("dlm-kernel-hugemem");
+    } else {
+      set.packages.push_back("cman-kernel");
+      set.packages.push_back("dlm-kernel");
+    }
+  } else if (RHEL5 || FC6) {
+    set.packages.push_back("cman");
   }
+  
   return set;
 }
 
@@ -454,9 +450,14 @@
 PackageHandler::build_cluster_base_gulm_set()
 {
   PackageSet set("Cluster Base - Gulm");
-  set.packages.push_back("ccs");
-  set.packages.push_back("gulm");
-  set.packages.push_back("fence");
+  
+  if (RHEL4 || FC5) {
+    set.packages.push_back("ccs");
+    set.packages.push_back("gulm");
+    set.packages.push_back("fence");
+  } else
+    throw String("GULM not available in CS5");
+  
   return set;
 }
 
@@ -465,8 +466,10 @@
 {
   PackageSet set("Cluster Service Manager");
   set.packages.push_back("rgmanager");
-  set.packages.push_back("magma");
-  set.packages.push_back("magma-plugins");
+  if (RHEL4 || FC5) {
+    set.packages.push_back("magma");
+    set.packages.push_back("magma-plugins");
+  }
   return set;
 }
 
@@ -474,25 +477,34 @@
 PackageHandler::build_cluster_storage_set()
 {
   PackageSet set("Clustered Storage");
-  set.packages.push_back("GFS");
   set.packages.push_back("lvm2-cluster");
-  
-  // find kernel type
-  String out, err;
-  int status;
-  vector<String> args;
-  args.push_back("-r");
-  if (utils::execute(UNAME_PATH, args, out, err, status, true))
-    throw String("execute failed");
-  if (status != 0)
-    throw String("uname -r failed");
-  if (out.find("smp") != out.npos) {
-    set.packages.push_back("GFS-kernel-smp");
-  } else if (out.find("hugemem") != out.npos) {
-    set.packages.push_back("GFS-kernel-hugemem");
-  } else {
-    set.packages.push_back("GFS-kernel");
+
+  if (RHEL4 || FC5) {
+    set.packages.push_back("GFS");
+    
+    // find kernel type
+    String out, err;
+    int status;
+    vector<String> args;
+    args.push_back("-r");
+    if (utils::execute(UNAME_PATH, args, out, err, status, true))
+      throw String("execute failed");
+    if (status != 0)
+      throw String("uname -r failed");
+    if (out.find("smp") != out.npos) {
+      set.packages.push_back("GFS-kernel-smp");
+    } else if (out.find("hugemem") != out.npos) {
+      set.packages.push_back("GFS-kernel-hugemem");
+    } else {
+      set.packages.push_back("GFS-kernel");
+    }
+  } else if (RHEL5 || FC6) {
+    set.packages.push_back("gfs2-utils");
+    
+    // TODO: implement GFS1
+    
   }
+  
   return set;
 }
 
@@ -592,3 +604,46 @@
 {
   return _pi.available();
 }
+
+
+
+
+
+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;
+  }
+}
--- conga/ricci/modules/rpm/PackageHandler.h	2006/08/10 22:53:08	1.3
+++ conga/ricci/modules/rpm/PackageHandler.h	2006/08/15 00:06:48	1.4
@@ -83,11 +83,6 @@
   std::map<String, String> available_rpms();
   bool install(std::vector<String> rpm_names);
   
- private:
-  
-  bool RHEL4;
-  bool FC5;
-  
 };
 
 


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