[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:	rmccabe sourceware org	2007-09-11 18:59:42

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

Log message:
	- More cleanup
	- Recognize F7 by name ("Moonshine") as having the RHEL5 cluster bits.

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

--- conga/ricci/modules/rpm/PackageHandler.cpp	2007/09/11 02:45:28	1.15
+++ conga/ricci/modules/rpm/PackageHandler.cpp	2007/09/11 18:59:42	1.16
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2006
+  Copyright Red Hat, Inc. 2006-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -28,222 +28,244 @@
 #include <unistd.h>
 #include <sys/utsname.h>
 
-
 using namespace std;
 
+#define RPM_PATH		"/bin/rpm"
+#define UP2DATE_PATH	"/usr/sbin/up2date-nox"
+#define YUM_PATH		"/usr/bin/yum"
 
-#define RPM_PATH       "/bin/rpm"
-#define UP2DATE_PATH   "/usr/sbin/up2date-nox"
-#define YUM_PATH       "/usr/bin/yum"
-
-
-static bool
-RHEL4=false, RHEL5=false, FC5=false, FC6=false;
-static void
-set_release();
-
-
+static bool RHEL4=false, RHEL5=false, FC5=false, FC6=false;
+static void set_release();
 
 // class PackageInstaller
 
-
-
 PackageInstaller::PackageInstaller()
 {
-  set_release();
+	set_release();
 }
 
 PackageInstaller::~PackageInstaller()
 {}
 
-
 bool
 PackageInstaller::available()
 {
-  if (RHEL4) {
-    bool rhn_available = true;
-    // check existence of /etc/sysconfig/rhn/systemid
-    if (access("/etc/sysconfig/rhn/systemid", F_OK))
-      rhn_available = false;
-    // check for subscribed channels
-    if (rhn_available) {
-      String out, err;
-      int status;
-      vector<String> args;
-      args.push_back("--show-channels");
-      if (utils::execute(UP2DATE_PATH, args, out, err, status, false))
-	throw command_not_found_error_msg(UP2DATE_PATH);
-      if (status != 0)
-	rhn_available = false;
-    }
-    return rhn_available;
-  } else if (FC5 || FC6 || RHEL5) {
-    // nothing to check for, maybe ping repositories???
-    return true;
-  } else
-    return false;
+	if (RHEL4) {
+		bool rhn_available = true;
+		// check existence of /etc/sysconfig/rhn/systemid
+		if (access("/etc/sysconfig/rhn/systemid", F_OK))
+			rhn_available = false;
+
+		// check for subscribed channels
+		if (rhn_available) {
+			String out, err;
+			int status;
+			vector<String> args;
+
+			args.push_back("--show-channels");
+			if (utils::execute(UP2DATE_PATH, args, out, err, status, false))
+				throw command_not_found_error_msg(UP2DATE_PATH);
+			if (status != 0)
+				rhn_available = false;
+		}
+		return rhn_available;
+	} else if (FC5 || FC6 || RHEL5) {
+		// use yum
+		// nothing to check for, maybe ping repositories?
+		return true;
+	} else
+		return false;
 }
 
 map<String, String>
 PackageInstaller::available_rpms()
 {
-  map<String, String> rpms;
+	map<String, String> rpms;
 
-  if (!available())
-    return rpms;
+	if (!available())
+		return rpms;
 
-  if (RHEL4) {
-    String out, err;
-    int status;
-    vector<String> args;
-    args.push_back("--showall");
-    if (utils::execute(UP2DATE_PATH, args, out, err, status, false))
-      throw command_not_found_error_msg(UP2DATE_PATH);
-    vector<String> lines = utils::split(utils::strip(out), "\n");
-    for (vector<String>::const_iterator iter = lines.begin();
-	 iter != lines.end();
-	 iter++) {
-      String line(*iter);
-      line = utils::strip(line);
-      vector<String> words = utils::split(line, "-");
-      vector<String>::size_type l = words.size();
-      if (l < 3)
-	continue;
-      String name = words[0];
-      for (unsigned int i=1; i<l-2; i++)
-	name += "-" + words[i];
-      String version = words[l-2] + "-" + words[l-1].substr(0, words[l-1].rfind("."));
-      rpms[name] = version;
-    }
-
-  } else if (FC5 || FC6 || RHEL5) {
-    String out, err;
-    int status;
-    vector<String> args;
-    args.push_back("-y");
-    args.push_back("list");
-    args.push_back("all");
-    if (utils::execute(YUM_PATH, args, out, err, status, false))
-      throw command_not_found_error_msg(YUM_PATH);
-    vector<String> lines = utils::split(utils::strip(out), "\n");
-    for (vector<String>::const_iterator iter = lines.begin();
-	 iter != lines.end();
-	 iter++) {
-      String line(*iter);
-      line = utils::strip(line);
-      vector<String> words = utils::split(line);
-      vector<String>::size_type l = words.size();
-      if (l < 3)
-	continue;
-      String name = words[0];
-      String::size_type idx = name.rfind('.');
-      if (idx == String::npos)
-	continue;
-      name = name.substr(0, idx);
-      String version = words[1];
-      rpms[name] = version;
-    }
-  }
+	if (RHEL4) {
+		String out, err;
+		int status;
+		vector<String> args;
+
+		args.push_back("--showall");
+		if (utils::execute(UP2DATE_PATH, args, out, err, status, false))
+			throw command_not_found_error_msg(UP2DATE_PATH);
+		vector<String> lines = utils::split(utils::strip(out), "\n");
+
+		for (vector<String>::const_iterator
+				iter = lines.begin() ;
+				iter != lines.end() ;
+				iter++)
+		{
+			String line(*iter);
+			line = utils::strip(line);
+			vector<String> words = utils::split(line, "-");
+			vector<String>::size_type l = words.size();
+			if (l < 3)
+				continue;
+
+			String name = words[0];
+			for (unsigned int i = 1 ; i < l - 2 ; i++)
+				name += "-" + words[i];
+			String version = words[l - 2] + "-" + words[l - 1].substr(0, words[l - 1].rfind("."));
+			rpms[name] = version;
+		}
+	} else if (FC5 || FC6 || RHEL5) {
+		String out, err;
+		int status;
+		vector<String> args;
+
+		args.push_back("-y");
+		args.push_back("list");
+		args.push_back("all");
+
+		if (utils::execute(YUM_PATH, args, out, err, status, false))
+			throw command_not_found_error_msg(YUM_PATH);
+
+		vector<String> lines = utils::split(utils::strip(out), "\n");
+
+		for (vector<String>::const_iterator
+				iter = lines.begin() ;
+				iter != lines.end() ;
+				iter++)
+		{
+			String line(*iter);
+			line = utils::strip(line);
+			vector<String> words = utils::split(line);
+			vector<String>::size_type l = words.size();
+			if (l < 3)
+				continue;
+
+			String name = words[0];
+			String::size_type idx = name.rfind('.');
+			if (idx == String::npos)
+				continue;
+			name = name.substr(0, idx);
+			String version = words[1];
+			rpms[name] = version;
+		}
+	}
 
-  return rpms;
+	return rpms;
 }
 
 bool
 PackageInstaller::install(vector<String> rpms)
 {
-  if (rpms.empty())
-    return true;
+	if (rpms.empty())
+		return true;
 
-  if (RHEL4) {
-    String out, err;
-    int status;
-    vector<String> args;
-    for (vector<String>::size_type i=0; i<rpms.size(); i++)
-      args.push_back(rpms[i]);
-    if (utils::execute(UP2DATE_PATH, args, out, err, status, true))
-      throw command_not_found_error_msg(UP2DATE_PATH);
-    if (status != 0)
-      throw String(UP2DATE_PATH) + " failed";
-    return true;
-
-  } else if (FC5 || FC6 || RHEL5) {
-    vector<String> rpms_to_install, rpms_to_upgrade;
-    String out, err;
-    int status;
-    vector<String> args;
-    args.push_back("-y");
-    args.push_back("list");
-    args.push_back("installed");
-    if (utils::execute(YUM_PATH, args, out, err, status, false))
-      throw command_not_found_error_msg(YUM_PATH);
-    if (status)
-      return false;
-    vector<String> lines = utils::split(utils::strip(out), "\n");
-    for (vector<String>::const_iterator rpm = rpms.begin();
-	 rpm != rpms.end();
-	 rpm++) {
-      bool install = true;
-      for (vector<String>::const_iterator iter = lines.begin();
-	   iter != lines.end();
-	   iter++) {
-	String line(*iter);
-	line = utils::strip(line);
-	if (line.find(*rpm + ".") == 0)
-	  install = false;
-      }
-      if (install)
-	rpms_to_install.push_back(*rpm);
-      else
-	rpms_to_upgrade.push_back(*rpm);
-    }
-    if (!rpms_to_install.empty()) {
-      out = err = "";
-      args.clear();
-      args.push_back("-y");
-      args.push_back("install");
-      for (vector<String>::const_iterator rpm = rpms_to_install.begin();
-	   rpm != rpms_to_install.end();
-	   rpm++)
-	args.push_back(*rpm);
-      if (utils::execute(YUM_PATH, args, out, err, status, false))
-	throw command_not_found_error_msg(YUM_PATH);
-      if (status)
-	return false;
-    }
-    if (!rpms_to_upgrade.empty()) {
-      out = err = "";
-      args.clear();
-      args.push_back("-y");
-      args.push_back("update");
-      for (vector<String>::const_iterator rpm = rpms_to_upgrade.begin();
-	   rpm != rpms_to_upgrade.end();
-	   rpm++)
-	args.push_back(*rpm);
-      if (utils::execute(YUM_PATH, args, out, err, status, false))
-	throw command_not_found_error_msg(YUM_PATH);
-      if (status)
-	return false;
-    }
-    return true;
-  } else
-    return false;
+	if (RHEL4) {
+		String out, err;
+		int status;
+		vector<String> args;
+
+		for (vector<String>::size_type i = 0 ; i < rpms.size() ; i++)
+			args.push_back(rpms[i]);
+
+		if (utils::execute(UP2DATE_PATH, args, out, err, status, true))
+			throw command_not_found_error_msg(UP2DATE_PATH);
+
+		if (status != 0)
+			throw String(UP2DATE_PATH) + " failed: " + err;
+		return true;
+	} else if (FC5 || FC6 || RHEL5) {
+		vector<String> rpms_to_install, rpms_to_upgrade;
+		String out, err;
+		int status;
+		vector<String> args;
+
+		args.push_back("-y");
+		args.push_back("list");
+		args.push_back("installed");
+
+		if (utils::execute(YUM_PATH, args, out, err, status, false))
+			throw command_not_found_error_msg(YUM_PATH);
+		if (status)
+			return false;
+
+		vector<String> lines = utils::split(utils::strip(out), "\n");
+		for (vector<String>::const_iterator
+				rpm = rpms.begin() ;
+				rpm != rpms.end() ;
+				rpm++)
+		{
+			bool install = true;
+			for (vector<String>::const_iterator
+					iter = lines.begin() ;
+					iter != lines.end() ;
+					iter++)
+			{
+				String line(*iter);
+				line = utils::strip(line);
+				if (line.find(*rpm + ".") == 0)
+					install = false;
+			}
+
+			if (install)
+				rpms_to_install.push_back(*rpm);
+			else
+				rpms_to_upgrade.push_back(*rpm);
+		}
+
+		if (!rpms_to_install.empty()) {
+			out = err = "";
+			args.clear();
+
+			args.push_back("-y");
+			args.push_back("install");
+			for (vector<String>::const_iterator
+					rpm = rpms_to_install.begin() ;
+					rpm != rpms_to_install.end() ;
+					rpm++)
+			{
+				args.push_back(*rpm);
+			}
+
+			if (utils::execute(YUM_PATH, args, out, err, status, false))
+				throw command_not_found_error_msg(YUM_PATH);
+			if (status)
+				return false;
+		}
+
+		if (!rpms_to_upgrade.empty()) {
+			out = err = "";
+			args.clear();
+
+			args.push_back("-y");
+			args.push_back("update");
+			for (vector<String>::const_iterator
+					rpm = rpms_to_upgrade.begin() ;
+					rpm != rpms_to_upgrade.end() ;
+					rpm++)
+			{
+				args.push_back(*rpm);
+			}
+
+			if (utils::execute(YUM_PATH, args, out, err, status, false))
+				throw command_not_found_error_msg(YUM_PATH);
+			if (status)
+				return false;
+		}
+		return true;
+	} else
+		return false;
 }
 
-
-
-
 // #### class Package ####
 
-
 Package::Package()
 {
-  set_release();
+	set_release();
 }
 
 Package::Package(const String& name) :
-  name(name)
+	name(name)
 {
-  set_release();
+	set_release();
 }
 
 Package::~Package()
@@ -252,34 +274,32 @@
 XMLObject
 Package::xml() const
 {
-  XMLObject xml("rpm");
-  xml.set_attr("name", name);
-  xml.set_attr("summary", summary);
-  xml.set_attr("description", description);
-  xml.set_attr("version", version);
-  xml.set_attr("repo_version", repo_version);
-  return xml;
+	XMLObject xml("rpm");
+	xml.set_attr("name", name);
+	xml.set_attr("summary", summary);
+	xml.set_attr("description", description);
+	xml.set_attr("version", version);
+	xml.set_attr("repo_version", repo_version);
+	return xml;
 }
 
-
 // #### class PackageSet ####
 
-
 PackageSet::PackageSet() :
-  installed(false),
-  in_repo(false),
-  upgradeable(false)
+	installed(false),
+	in_repo(false),
+	upgradeable(false)
 {
-  set_release();
+	set_release();
 }
 
 PackageSet::PackageSet(const String& name) :
-  name(name),
-  installed(false),
-  in_repo(false),
-  upgradeable(false)
+	name(name),
+	installed(false),
+	in_repo(false),
+	upgradeable(false)
 {
-  set_release();
+	set_release();
 }
 
 PackageSet::~PackageSet()
@@ -288,358 +308,381 @@
 XMLObject
 PackageSet::xml() const
 {
-  XMLObject xml("set");
-  xml.set_attr("name", name);
-  xml.set_attr("summary", summary);
-  xml.set_attr("description", description);
-  xml.set_attr("installed", installed?"true":"false");
-  xml.set_attr("in_repository", in_repo?"true":"false");
-  xml.set_attr("installable", upgradeable?"true":"false");
-  return xml;
+	XMLObject xml("set");
+	xml.set_attr("name", name);
+	xml.set_attr("summary", summary);
+	xml.set_attr("description", description);
+	xml.set_attr("installed", installed ? "true" : "false");
+	xml.set_attr("in_repository", in_repo ? "true" : "false");
+	xml.set_attr("installable", upgradeable ? "true" : "false");
+	return xml;
 }
 
-
-
 // #### class PackageHandler ####
 
-
 PackageInstaller PackageHandler::_pi;
 
 PackageHandler::PackageHandler()
 {
-  set_release();
+	set_release();
 
-  // get installed packages
+	// get installed packages
+	String out, err;
+	int status;
+	vector<String> args;
+
+	args.push_back("-qa");
+	if (utils::execute(RPM_PATH, args, out, err, status, false))
+		throw command_not_found_error_msg(RPM_PATH);
+	if (status != 0)
+		throw String("rpm -qa failed: " + err);
+
+	vector<String> lines = utils::split(out, "\n");
+	for (vector<String>::const_iterator
+			iter = lines.begin() ;
+			iter != lines.end() ;
+			iter++)
+	{
+		String line(*iter);
+		line = utils::strip(line);
+
+		vector<String> words = utils::split(line, "-");
+		vector<String>::size_type l = words.size();
+		if (l < 3)
+			continue;
+		String name = words[0];
+
+		for (unsigned int i = 1; i < l - 2 ; i++)
+			name += "-" + words[i];
+
+		Package pack(name);
+		pack.version = words[l - 2] + "-" + words[l - 1];
+		_packages[name] = pack;
+	}
+
+	// probe repositories
+	if (repo_available()) {
+		map<String, String> avail_rpms = _pi.available_rpms();
+		for (map<String, String>::const_iterator
+			iter = avail_rpms.begin() ;
+			iter != avail_rpms.end() ;
+			iter++)
+		{
+			String name = iter->first;
+			String version = iter->second;
+			Package& pack = _packages[name];
+			pack.name = name;
+			pack.repo_version = version;
+		}
+	}
 
-  String out, err;
-  int status;
-  vector<String> args;
-  args.push_back("-qa");
-  if (utils::execute(RPM_PATH, args, out, err, status, false))
-    throw command_not_found_error_msg(RPM_PATH);
-  if (status != 0)
-    throw String("rpm -qa failed");
-  vector<String> lines = utils::split(out, "\n");
-  for (vector<String>::const_iterator iter = lines.begin();
-       iter != lines.end();
-       iter++) {
-    String line(*iter);
-    line = utils::strip(line);
-    vector<String> words = utils::split(line, "-");
-    vector<String>::size_type l = words.size();
-    if (l < 3)
-      continue;
-    String name = words[0];
-    for (unsigned int i=1; i<l-2; i++)
-      name += "-" + words[i];
-    Package pack(name);
-    pack.version = words[l-2] + "-" + words[l-1];
-    _packages[name] = pack;
-  }
-
-  // probe repositories
-  if (repo_available()) {
-    map<String, String> avail_rpms = _pi.available_rpms();
-    for (map<String, String>::const_iterator iter = avail_rpms.begin();
-	 iter != avail_rpms.end();
-	 iter++) {
-      String name = iter->first;
-      String version = iter->second;
-      Package& pack = _packages[name];
-      pack.name = name;
-      pack.repo_version = version;
-    }
-  }
-
-
-  // build sets
-  _sets = build_sets();
-  for (map<String, PackageSet>::iterator iter = _sets.begin();
-       iter != _sets.end();
-       iter++)
-    populate_set(iter->second);
+	// build sets
+	_sets = build_sets();
+	for (map<String, PackageSet>::iterator
+			iter = _sets.begin() ;
+			iter != _sets.end() ;
+			iter++)
+	{
+		populate_set(iter->second);
+	}
 }
 
 PackageHandler::~PackageHandler()
 {}
 
-
 std::map<String, Package>&
 PackageHandler::packages()
 {
-  return _packages;
+	return _packages;
 }
 
 std::map<String, PackageSet>&
 PackageHandler::sets()
 {
-  return _sets;
+	return _sets;
 }
 
-
 std::map<String, PackageSet>
 PackageHandler::build_sets()
 {
-  map<String, PackageSet> sets;
+	map<String, PackageSet> sets;
 
-  PackageSet set = build_cluster_base_set();
-  sets[set.name] = set;
+	PackageSet set = build_cluster_base_set();
+	sets[set.name] = set;
 
-  if (RHEL4 || FC5) {
-    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;
+	set = build_cluster_services_set();
+	sets[set.name] = set;
 
-  set = build_cluster_storage_set();
-  sets[set.name] = set;
+	set = build_cluster_storage_set();
+	sets[set.name] = set;
 
-  set = build_linux_virtual_server_set();
-  sets[set.name] = set;
+	set = build_linux_virtual_server_set();
+	sets[set.name] = set;
 
-  return sets;
+	return sets;
 }
 
 PackageSet
 PackageHandler::build_cluster_base_set()
 {
-  PackageSet set("Cluster Base");
+	PackageSet set("Cluster Base");
 
-  if (RHEL4 || FC5) {
-    set.packages.push_back("ccs");
-    set.packages.push_back("cman");
-    set.packages.push_back("dlm");
-    set.packages.push_back("fence");
-
-    struct utsname uts;
-    uname(&uts);
-    String kernel(uts.release);
-    if (kernel.find("smp") != kernel.npos) {
-      set.packages.push_back("cman-kernel-smp");
-      set.packages.push_back("dlm-kernel-smp");
-    } else if (kernel.find("hugemem") != kernel.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");
-  }
+	if (RHEL4 || FC5) {
+		set.packages.push_back("ccs");
+		set.packages.push_back("cman");
+		set.packages.push_back("dlm");
+		set.packages.push_back("fence");
+
+		struct utsname uts;
+		uname(&uts);
+		String kernel(uts.release);
+
+		if (kernel.find("smp") != kernel.npos) {
+			set.packages.push_back("cman-kernel-smp");
+			set.packages.push_back("dlm-kernel-smp");
+		} else if (kernel.find("hugemem") != kernel.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;
+	return set;
 }
 
 PackageSet
 PackageHandler::build_cluster_base_gulm_set()
 {
-  PackageSet set("Cluster Base - Gulm");
+	PackageSet set("Cluster Base - Gulm");
 
-  if (RHEL4 || FC5) {
-    set.packages.push_back("ccs");
-    set.packages.push_back("gulm");
-  } else
-    throw String("GULM not available in CS5");
+	if (RHEL4 || FC5) {
+		set.packages.push_back("ccs");
+		set.packages.push_back("gulm");
+	} else
+		throw String("GULM is not available in Red Hat Cluster Suite 5");
 
-  return set;
+	return set;
 }
 
 PackageSet
 PackageHandler::build_cluster_services_set()
 {
-  PackageSet set("Cluster Service Manager");
-  set.packages.push_back("rgmanager");
-  if (RHEL4 || FC5) {
-    set.packages.push_back("magma");
-    set.packages.push_back("magma-plugins");
-  }
-  return set;
+	PackageSet set("Cluster Service Manager");
+	set.packages.push_back("rgmanager");
+	if (RHEL4 || FC5) {
+		set.packages.push_back("magma");
+		set.packages.push_back("magma-plugins");
+	}
+	return set;
 }
 
 PackageSet
 PackageHandler::build_cluster_storage_set()
 {
-  struct utsname uts;
-  uname(&uts);
-  String kernel(uts.release);
-
-  PackageSet set("Clustered Storage");
-  set.packages.push_back("lvm2-cluster");
-
-  if (RHEL4 || FC5) {
-    set.packages.push_back("GFS");
-    if (kernel.find("smp") != kernel.npos) {
-      set.packages.push_back("GFS-kernel-smp");
-    } else if (kernel.find("hugemem") != kernel.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");
-    if (RHEL5) {
-      set.packages.push_back("gfs-utils");
-      if (kernel.find("xen") == kernel.npos)
-	set.packages.push_back("kmod-gfs");
-      else
-	set.packages.push_back("kmod-gfs-xen");
-    }
-  }
+	struct utsname uts;
+	uname(&uts);
+	String kernel(uts.release);
+
+	PackageSet set("Clustered Storage");
+	set.packages.push_back("lvm2-cluster");
+
+	if (RHEL4 || FC5) {
+		set.packages.push_back("GFS");
+		if (kernel.find("smp") != kernel.npos) {
+			set.packages.push_back("GFS-kernel-smp");
+		} else if (kernel.find("hugemem") != kernel.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");
+		if (RHEL5) {
+			set.packages.push_back("gfs-utils");
+			if (kernel.find("xen") == kernel.npos)
+				set.packages.push_back("kmod-gfs");
+			else
+				set.packages.push_back("kmod-gfs-xen");
+		}
+	}
 
-  return set;
+	return set;
 }
 
 PackageSet
 PackageHandler::build_linux_virtual_server_set()
 {
-  PackageSet set("Linux Virtual Server");
-  set.packages.push_back("ipvsadm");
-  set.packages.push_back("piranha");
-  return set;
+	PackageSet set("Linux Virtual Server");
+	set.packages.push_back("ipvsadm");
+	set.packages.push_back("piranha");
+	return set;
 }
 
-
 void
 PackageHandler::populate_set(PackageSet& set)
 {
-  set.installed = true;
-  set.in_repo = true;
-  set.upgradeable = false;
-
-  for (list<String>::const_iterator name_iter = set.packages.begin();
-       name_iter != set.packages.end();
-       name_iter++) {
-    const String& name = *name_iter;
-    map<String, Package>::const_iterator iter = _packages.find(name);
-    if (iter == _packages.end()) {
-      set.installed = false;
-      set.in_repo = false;
-      set.upgradeable = false;
-      break;
-    } else {
-      const Package& pack = iter->second;
-      if (pack.version.empty())
-	set.installed = false;
-      if (pack.repo_version.empty())
-	set.in_repo = false;
-      else if (pack.repo_version > pack.version)
-	set.upgradeable = true;
-    }
-  }
-  if (set.in_repo == false)
-    set.upgradeable = false;
+	set.installed = true;
+	set.in_repo = true;
+	set.upgradeable = false;
+
+	for (list<String>::const_iterator
+			name_iter = set.packages.begin() ;
+			name_iter != set.packages.end() ;
+			name_iter++)
+	{
+		const String& name = *name_iter;
+		map<String, Package>::const_iterator iter = _packages.find(name);
+		if (iter == _packages.end()) {
+			set.installed = false;
+			set.in_repo = false;
+			set.upgradeable = false;
+			break;
+		} else {
+			const Package& pack = iter->second;
+			if (pack.version.empty())
+				set.installed = false;
+			if (pack.repo_version.empty())
+				set.in_repo = false;
+			else if (pack.repo_version > pack.version)
+				set.upgradeable = true;
+		}
+	}
+
+	if (set.in_repo == false)
+		set.upgradeable = false;
 }
 
 void
 PackageHandler::install(const std::list<Package>& packages,
-			const std::list<PackageSet>& sets,
-			bool upgrade)
+						const std::list<PackageSet>& sets,
+						bool upgrade)
 {
-  vector<String> rpms;
+	vector<String> rpms;
 
-  PackageHandler h_pre;
-  for (list<Package>::const_iterator iter = packages.begin();
-       iter != packages.end();
-       iter++) {
-    String name(iter->name);
-    map<String, Package>::iterator pack_iter = h_pre.packages().find(name);
-    if (pack_iter == h_pre.packages().end())
-      throw String("package ") + name + " present neither locally nor in repository";
-    else {
-      String curr_ver(pack_iter->second.version);
-      String repo_ver(pack_iter->second.repo_version);
-      if (curr_ver.empty()) {
-	// not installed
-	if (repo_ver.empty())
-	  throw String("package ") + name + " not present in repository";
-	else
-	  rpms.push_back(name);
-      } else {
-	// already installed
-	if (upgrade) {
-	  if (repo_ver.empty())
-	    throw String("package ") + name + " not present in repository";
-	  else if (repo_ver > curr_ver)
-	    rpms.push_back(name);
-	}
-      }
-    }
-  }
-
-  for (list<PackageSet>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++) {
-    String name(iter->name);
-    map<String, PackageSet>::iterator set_iter = h_pre.sets().find(name);
-    if (set_iter == h_pre.sets().end())
-      throw String("packages of set ") + name + " present neither locally nor in repository";
-    else {
-      PackageSet& p_set = set_iter->second;
-      if (p_set.installed) {
-	// already installed
-	if (upgrade) {
-	  if (p_set.in_repo) {
-	    if (p_set.upgradeable)
-	      for (list<String>::const_iterator name_iter = p_set.packages.begin();
-		   name_iter != p_set.packages.end();
-		   name_iter++)
-		rpms.push_back(*name_iter);
-	  } else
-	    throw String("packages of set ") + name + " not present in repository";
-	}
-      } else {
-	// not installed
-	if (p_set.in_repo)
-	  for (list<String>::const_iterator name_iter = p_set.packages.begin();
-	       name_iter != p_set.packages.end();
-	       name_iter++)
-	    rpms.push_back(*name_iter);
-	else
-	  throw String("packages of set ") + name + " not present in repository";
-      }
-    }
-  }
-
-  if (!_pi.install(rpms)) {
-    String msg("Failed to install packages");
-    if (!repo_available())
-      msg += ": System not configured to use repositories";
-    throw msg;
-  }
-}
+	PackageHandler h_pre;
+	for (list<Package>::const_iterator
+			iter = packages.begin() ;
+			iter != packages.end() ;
+			iter++)
+	{
+		String name(iter->name);
+		map<String, Package>::iterator pack_iter = h_pre.packages().find(name);
+		if (pack_iter == h_pre.packages().end()) {
+			throw String("package ") + name
+					+ " is present neither locally nor in repository";
+		} else {
+			String curr_ver(pack_iter->second.version);
+			String repo_ver(pack_iter->second.repo_version);
+			if (curr_ver.empty()) {
+				// not installed
+				if (repo_ver.empty()) {
+					throw String("package ") + name
+							+ " is not present in repository";
+				} else
+					rpms.push_back(name);
+			} else {
+				// already installed
+				if (upgrade) {
+					if (repo_ver.empty()) {
+						throw String("package ") + name
+								+ " is not present in repository";
+					} else if (repo_ver > curr_ver)
+						rpms.push_back(name);
+				}
+			}
+		}
+	}
+
+	for (list<PackageSet>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		String name(iter->name);
+		map<String, PackageSet>::iterator set_iter = h_pre.sets().find(name);
+
+		if (set_iter == h_pre.sets().end())
+			throw String("packages of set ") + name + " present neither locally nor in repository";
+		else {
+			PackageSet& p_set = set_iter->second;
+			if (p_set.installed) {
+				// already installed
+				if (upgrade) {
+					if (p_set.in_repo) {
+						if (p_set.upgradeable) {
+							for (list<String>::const_iterator
+									name_iter = p_set.packages.begin() ;
+									name_iter != p_set.packages.end() ;
+									name_iter++)
+							{
+								rpms.push_back(*name_iter);
+							} else {
+								throw String("packages of set ") + name + " are not present in any available repository";
+							}
+						}
+					}
+				}
+			} else {
+				// not installed
+				if (p_set.in_repo) {
+					for (list<String>::const_iterator
+						name_iter = p_set.packages.begin() ;
+						name_iter != p_set.packages.end() ;
+						name_iter++)
+					{
+						rpms.push_back(*name_iter);
+					}
+				} else {
+					throw String("packages of set ") + name +
+						" are not present in any available repository";
+				}
+			}
+		}
+	}
 
+	if (!_pi.install(rpms)) {
+		String msg("Failed to install packages");
+		if (!repo_available())
+			msg += ": System not configured to use repositories";
+		throw msg;
+	}
+}
 
 bool
 PackageHandler::repo_available()
 {
-  return _pi.available();
+	return _pi.available();
 }
 
-
-
-
-
 void
 set_release()
 {
-  static bool release_set = false;
-  if (!release_set) {
-    String release(utils::strip(File::open("/etc/redhat-release")));
-
-    if (release.find("Nahant") != release.npos)
-      RHEL4 = true;
-    else if (release.find("Bordeaux") != release.npos)
-      FC5 = true;
-    else if (release.find("Zod") != release.npos)
-      FC6 = true;
-    else if (release.find("Tikanga") != release.npos)
-      RHEL5 = true;
-    else
-      throw String("Unsupported OS");
+	static bool release_set = false;
+	if (!release_set) {
+		String release(utils::strip(File::open("/etc/redhat-release")));
+
+		if (release.find("Nahant") != release.npos)
+			RHEL4 = true;
+		else if (release.find("Bordeaux") != release.npos)
+			FC5 = true;
+		else if (release.find("Zod") != release.npos)
+			FC6 = true;
+		else if (release.find("Moonshine") != release.npos)
+			FC6 = true;
+		else if (release.find("Tikanga") != release.npos)
+			RHEL5 = true;
+		else
+			throw String("Unsupported OS: " + release);
 
-    release_set = true;
-  }
+		release_set = true;
+	}
 }
--- conga/ricci/modules/rpm/PackageHandler.h	2007/09/11 02:45:28	1.6
+++ conga/ricci/modules/rpm/PackageHandler.h	2007/09/11 18:59:42	1.7
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2006
+  Copyright Red Hat, Inc. 2006-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -21,105 +21,92 @@
  */
 
 
-#ifndef PackageHandler_h
-#define PackageHandler_h
+#ifndef __CONGA_MODRPM_PACKAGEHANDLER_H
+#define __CONGA_MODRPM_PACKAGEHANDLER_H
 
 #include "XML.h"
 #include "String.h"
 #include <map>
 #include <vector>
 
-
 class Package
 {
- public:
-  Package();
-  Package(const String& name);
-  virtual ~Package();
-
-  String name;
-  String summary;
-  String description;
-  String version;
-  String repo_version;
-
-  XMLObject xml() const;
-
- private:
+	public:
+		Package();
+		Package(const String& name);
+		virtual ~Package();
+
+		String name;
+		String summary;
+		String description;
+		String version;
+		String repo_version;
 
-};  // class Package
+		XMLObject xml() const;
 
+	private:
+};
 
 class PackageSet
 {
- public:
-  PackageSet();
-  PackageSet(const String& name);
-  virtual ~PackageSet();
-
-  String name;
-  String summary;
-  String description;
-  bool installed;
-  bool in_repo;
-  bool upgradeable;
-
-  std::list<String> packages;
+	public:
+		PackageSet();
+		PackageSet(const String& name);
+		virtual ~PackageSet();
+
+		String name;
+		String summary;
+		String description;
+		bool installed;
+		bool in_repo;
+		bool upgradeable;
 
-  XMLObject xml() const;
+		std::list<String> packages;
 
- private:
-
-};  // class PackageSet
+		XMLObject xml() const;
 
+	private:
+};
 
 class PackageInstaller
 {
- public:
-  PackageInstaller();
-  virtual ~PackageInstaller();
-
-  bool available();
-  std::map<String, String> available_rpms();
-  bool install(std::vector<String> rpm_names);
-
+	public:
+		PackageInstaller();
+		virtual ~PackageInstaller();
+
+		bool available();
+		std::map<String, String> available_rpms();
+		bool install(std::vector<String> rpm_names);
 };
 
-
 class PackageHandler
 {
- public:
-  PackageHandler();
-  virtual ~PackageHandler();
-
-  std::map<String, Package>& packages();
-  std::map<String, PackageSet>& sets();
-
-  void populate_set(PackageSet& set);
-
-
-  static bool repo_available();
-
-  static std::map<String, PackageSet> build_sets();
-  static PackageSet build_cluster_base_set();
-  static PackageSet build_cluster_base_gulm_set();
-  static PackageSet build_cluster_services_set();
-  static PackageSet build_cluster_storage_set();
-  static PackageSet build_linux_virtual_server_set();
-
-  static void install(const std::list<Package>& packages,
-		      const std::list<PackageSet>& sets,
-		      bool upgrade=true);
-
- private:
-
-  std::map<String, Package>     _packages;
-  std::map<String, PackageSet>  _sets;
-
-  static PackageInstaller _pi;
-
-
-};  // class PackageHandler
-
+	public:
+		PackageHandler();
+		virtual ~PackageHandler();
+
+		std::map<String, Package>& packages();
+		std::map<String, PackageSet>& sets();
+
+		void populate_set(PackageSet& set);
+
+		static bool repo_available();
+
+		static std::map<String, PackageSet> build_sets();
+		static PackageSet build_cluster_base_set();
+		static PackageSet build_cluster_base_gulm_set();
+		static PackageSet build_cluster_services_set();
+		static PackageSet build_cluster_storage_set();
+		static PackageSet build_linux_virtual_server_set();
+
+		static void install(const std::list<Package>& packages,
+							const std::list<PackageSet>& sets,
+							bool upgrade=true);
+
+	private:
+		std::map<String, Package> _packages;
+		std::map<String, PackageSet> _sets;
+		static PackageInstaller _pi;
+};
 
-#endif  // PackageHandler_h
+#endif
--- conga/ricci/modules/rpm/RpmModule.cpp	2007/09/11 02:45:28	1.4
+++ conga/ricci/modules/rpm/RpmModule.cpp	2007/09/11 18:59:42	1.5
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2006
+  Copyright Red Hat, Inc. 2006-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -24,10 +24,8 @@
 #include "RpmModule.h"
 #include "PackageHandler.h"
 
-
 using namespace std;
 
-
 static VarMap lists(const VarMap& args);
 static VarMap query(const VarMap& args);
 static VarMap repository_configured(const VarMap& args);
@@ -35,224 +33,253 @@
 
 static ApiFcnMap build_fcn_map();
 
-
 RpmModule::RpmModule() :
-  Module(build_fcn_map())
+	Module(build_fcn_map())
 {}
 
 RpmModule::~RpmModule()
 {}
 
-
 ApiFcnMap
 build_fcn_map()
 {
-  FcnMap   api_1_0;
-  api_1_0["list"]                     = lists;
-  api_1_0["query"]                    = query;
-  api_1_0["install"]                  = install;
-  api_1_0["repository_configured"]    = repository_configured;
+	FcnMap api_1_0;
 
-  ApiFcnMap   api_fcn_map;
-  api_fcn_map["1.0"] = api_1_0;
-
-  return api_fcn_map;
+	api_1_0["list"] = lists;
+	api_1_0["query"] = query;
+	api_1_0["install"] = install;
+	api_1_0["repository_configured"] = repository_configured;
+
+	ApiFcnMap api_fcn_map;
+	api_fcn_map["1.0"] = api_1_0;
+	return api_fcn_map;
 }
 
 
 VarMap
 install(const VarMap& args)
 {
-  list<XMLObject> rpms_list, sets_list;
-  bool upgrade;
-  try{
-    VarMap::const_iterator iter = args.find("rpms");
-    if (iter != args.end())
-      rpms_list = iter->second.get_list_XML();
-
-    iter = args.find("sets");
-    if (iter != args.end())
-      sets_list = iter->second.get_list_XML();
-
-    upgrade = true;
-    iter = args.find("upgrade");
-    if (iter != args.end())
-      upgrade = iter->second.get_bool();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  // command
-  list<Package> rpms;
-  for (list<XMLObject>::const_iterator iter = rpms_list.begin();
-       iter != rpms_list.end();
-       iter++)
-    if (iter->tag() == "rpm") {
-      String name(iter->get_attr("name"));
-      if (name.size()) {
-	Package pack(name);
-	rpms.push_back(pack);
-      }
-    }
-
-  list<PackageSet> sets;
-  for (list<XMLObject>::const_iterator iter = sets_list.begin();
-       iter != sets_list.end();
-       iter++)
-    if (iter->tag() == "set") {
-      String name(iter->get_attr("name"));
-      if (name.size()) {
-	PackageSet set(name);
-	sets.push_back(set);
-      }
-    }
+	list<XMLObject> rpms_list, sets_list;
+	bool upgrade;
+
+	try {
+		VarMap::const_iterator iter = args.find("rpms");
+		if (iter != args.end())
+			rpms_list = iter->second.get_list_XML();
+
+		iter = args.find("sets");
+		if (iter != args.end())
+			sets_list = iter->second.get_list_XML();
+
+		upgrade = true;
+		iter = args.find("upgrade");
+		if (iter != args.end())
+			upgrade = iter->second.get_bool();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	// command
+	list<Package> rpms;
+	for (list<XMLObject>::const_iterator
+		iter = rpms_list.begin() ;
+		iter != rpms_list.end() ;
+		iter++)
+	{
+		if (iter->tag() == "rpm") {
+			String name(iter->get_attr("name"));
+			if (name.size()) {
+				Package pack(name);
+				rpms.push_back(pack);
+			}
+		}
+
+		list<PackageSet> sets;
+		for (list<XMLObject>::const_iterator
+				iter = sets_list.begin() ;
+				iter != sets_list.end() ;
+				iter++)
+		{
+			if (iter->tag() == "set") {
+				String name(iter->get_attr("name"));
+				if (name.size()) {
+					PackageSet set(name);
+					sets.push_back(set);
+				}
+			}
+		}
 
-  PackageHandler::install(rpms, sets, upgrade);
-  return VarMap();
+	PackageHandler::install(rpms, sets, upgrade);
+	return VarMap();
 }
 
 VarMap
 repository_configured(const VarMap& args)
 {
-  Variable var("repository_configured", PackageHandler::repo_available());
+	Variable var("repository_configured", PackageHandler::repo_available());
 
-  VarMap ret;
-  ret.insert(pair<String, Variable>(var.name(), var));
-  return ret;
+	VarMap ret;
+	ret.insert(pair<String, Variable>(var.name(), var));
+	return ret;
 }
 
 VarMap
 lists(const VarMap& args)
 {
-  bool rpms, sets, installed, installable, upgradeable;
-  try {
-    rpms = false;
-    VarMap::const_iterator iter = args.find("rpms");
-    if (iter != args.end())
-      rpms = iter->second.get_bool();
-
-    sets = false;
-    iter = args.find("sets");
-    if (iter != args.end())
-      sets = iter->second.get_bool();
-
-    installed = false;
-    iter = args.find("installed");
-    if (iter != args.end())
-      installed = iter->second.get_bool();
-
-    installable = false;
-    iter = args.find("installable");
-    if (iter != args.end())
-      installable = iter->second.get_bool();
-
-    upgradeable = false;
-    iter = args.find("upgradeable");
-    if (iter != args.end())
-      upgradeable = iter->second.get_bool();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-
-  VarMap ret;
-
-  if (sets || rpms) {
-    PackageHandler handler;
-
-    if (rpms) {
-      list<XMLObject> rpm_list;
-      for (map<String, Package>::const_iterator iter = handler.packages().begin();
-	   iter != handler.packages().end();
-	   iter++ ) {
-	const Package& pack = iter->second;
-	bool add = false;
-	if (installed)
-	  if (pack.version.size())
-	    add = true;
-	if (installable)
-	  if (pack.repo_version > pack.version &&
-	      pack.version.empty())
-	    add = true;
-	if (upgradeable)
-	  if (pack.repo_version > pack.version &&
-	      pack.version.size())
-	    add = true;
-	if (add)
-	  rpm_list.push_back(pack.xml());
-      }
-      Variable var("rpms", rpm_list);
-      ret.insert(pair<String, Variable>(var.name(), var));
-    }
-
-    if (sets) {
-      list<XMLObject> set_list;
-      for (map<String, PackageSet>::const_iterator iter = handler.sets().begin();
-	   iter != handler.sets().end();
-	   iter++ ) {
-	const PackageSet& set = iter->second;
-	bool add = false;
-	if (installed)
-	  if (set.installed)
-	    add = true;
-	if (installable)
-	  if (!set.installed &&
-	      set.in_repo)
-	    add = true;
-	if (upgradeable)
-	  if (set.installed &&
-	      set.upgradeable)
-	    add = true;
-	if (add)
-	  set_list.push_back(set.xml());
-      }
-      Variable var("sets", set_list);
-      ret.insert(pair<String, Variable>(var.name(), var));
-    }
-  }
+	bool rpms, sets, installed, installable, upgradeable;
 
-  return ret;
+	try {
+		rpms = false;
+		VarMap::const_iterator iter = args.find("rpms");
+
+		if (iter != args.end())
+			rpms = iter->second.get_bool();
+
+		sets = false;
+		iter = args.find("sets");
+		if (iter != args.end())
+			sets = iter->second.get_bool();
+
+		installed = false;
+		iter = args.find("installed");
+
+		if (iter != args.end())
+			installed = iter->second.get_bool();
+
+		installable = false;
+		iter = args.find("installable");
+		if (iter != args.end())
+			installable = iter->second.get_bool();
+
+		upgradeable = false;
+		iter = args.find("upgradeable");
+		if (iter != args.end())
+			upgradeable = iter->second.get_bool();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	VarMap ret;
+
+	if (sets || rpms) {
+		PackageHandler handler;
+
+		if (rpms) {
+			list<XMLObject> rpm_list;
+			for (map<String, Package>::const_iterator
+				iter = handler.packages().begin() ;
+				iter != handler.packages().end() ;
+				iter++)
+			{
+				const Package& pack = iter->second;
+				bool add = false;
+
+				if (installed) {
+					if (pack.version.size())
+						add = true;
+				}
+
+				if (installable) {
+					if (pack.repo_version > pack.version &&
+						pack.version.empty())
+					{
+						add = true;
+					}
+				}
+
+				if (upgradeable) {
+					if (pack.repo_version > pack.version &&
+						pack.version.size())
+					{
+						add = true;
+					}
+				}
+
+				if (add)
+					rpm_list.push_back(pack.xml());
+			}
+
+			Variable var("rpms", rpm_list);
+			ret.insert(pair<String, Variable>(var.name(), var));
+		}
+
+		if (sets) {
+			list<XMLObject> set_list;
+			for (map<String, PackageSet>::const_iterator
+					iter = handler.sets().begin() ;
+					iter != handler.sets().end() ;
+					iter++)
+			{
+				const PackageSet& set = iter->second;
+				bool add = false;
+
+				if (installed) {
+					if (set.installed)
+						add = true;
+				}
+
+				if (installable) {
+					if (!set.installed && set.in_repo)
+						add = true;
+				}
+
+				if (upgradeable) {
+					if (set.installed && set.upgradeable)
+						add = true;
+				}
+
+				if (add)
+					set_list.push_back(set.xml());
+			}
+
+			Variable var("sets", set_list);
+			ret.insert(pair<String, Variable>(var.name(), var));
+		}
+	}
+
+	return ret;
 }
 
 VarMap
 query(const VarMap& args)
 {
-  list<XMLObject> search_list;
-  try {
-    VarMap::const_iterator iter = args.find("search");
-    if (iter == args.end())
-      throw APIerror("missing search variable");
-    search_list = iter->second.get_list_XML();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-
-  list<XMLObject> result_list;
-  PackageHandler handler;
-  for (list<XMLObject>::const_iterator iter = search_list.begin();
-       iter != search_list.end();
-       iter++) {
-    if (iter->tag() == "rpm") {
-      String name(iter->get_attr("name"));
-      if (name.size()) {
-	Package& pack = handler.packages()[name];
-	pack.name = name;
-	result_list.push_back(pack.xml());
-      }
-    } else if (iter->tag() == "set") {
-      String name(iter->get_attr("name"));
-      if (name.size()) {
-	PackageSet& set = handler.sets()[name];
-	set.name = name;
-	result_list.push_back(set.xml());
-      }
-    }
-  }
-
-  Variable var("result", result_list);
-
-  VarMap ret;
-  ret.insert(pair<String, Variable>(var.name(), var));
-  return ret;
+	list<XMLObject> search_list;
+
+	try {
+		VarMap::const_iterator iter = args.find("search");
+		if (iter == args.end())
+			throw APIerror("missing search variable");
+		search_list = iter->second.get_list_XML();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	list<XMLObject> result_list;
+	PackageHandler handler;
+	for (list<XMLObject>::const_iterator
+			iter = search_list.begin() ;
+			iter != search_list.end() ;
+			iter++)
+	{
+		if (iter->tag() == "rpm") {
+			String name(iter->get_attr("name"));
+			if (name.size()) {
+				Package& pack = handler.packages()[name];
+				pack.name = name;
+				result_list.push_back(pack.xml());
+			}
+		} else if (iter->tag() == "set") {
+			String name(iter->get_attr("name"));
+			if (name.size()) {
+				PackageSet& set = handler.sets()[name];
+				set.name = name;
+				result_list.push_back(set.xml());
+			}
+		}
+	}
+
+	Variable var("result", result_list);
+	VarMap ret;
+	ret.insert(pair<String, Variable>(var.name(), var));
+	return ret;
 }
--- conga/ricci/modules/rpm/RpmModule.h	2007/09/11 02:45:28	1.2
+++ conga/ricci/modules/rpm/RpmModule.h	2007/09/11 18:59:42	1.3
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2006
+  Copyright Red Hat, Inc. 2006-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -20,22 +20,18 @@
  * Author: Stanko Kupcevic <kupcevic redhat com>
  */
 
-
-#ifndef RpmModule_h
-#define RpmModule_h
+#ifndef __CONGA_MODRPM_RPMMODULE_H
+#define __CONGA_MODRPM_RPMMODULE_H
 
 #include "Module.h"
 
-
 class RpmModule : public Module
 {
- public:
-  RpmModule();
-  virtual ~RpmModule();
-
- private:
+	public:
+		RpmModule();
+		virtual ~RpmModule();
 
+	private:
 };
 
-
-#endif  // RpmModule_h
+#endif
--- conga/ricci/modules/rpm/main.cpp	2007/09/11 02:45:28	1.5
+++ conga/ricci/modules/rpm/main.cpp	2007/09/11 18:59:42	1.6
@@ -1,5 +1,5 @@
 /*
-  Copyright Red Hat, Inc. 2005
+  Copyright Red Hat, Inc. 2005-2007
 
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
@@ -24,18 +24,22 @@
 #include "RpmModule.h"
 
 #include <iostream>
+
 using namespace std;
 
 int
-main(int argc, char** argv)
+main(int argc, char **argv)
 {
-  try {
-    RpmModule m;
-    return stdin_out_module_driver(m,
-				   argc,
-				   argv);
-  } catch (String e) {
-    cerr << e << endl;
-    return 1;
-  }
+	try {
+		RpmModule m;
+		return stdin_out_module_driver(m, argc, argv);
+	} catch (String e) {
+		cerr << e << endl;
+		return 1;
+	} catch (...) {
+		cerr << "unknown error" << endl;
+		return 1;
+	}
+
+	return 0;
 }


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