[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:	rmccabe sourceware org	2007-09-11 13:53:19

Modified files:
	ricci/modules/service: ServiceManager.cpp ServiceManager.h 
	                       ServiceModule.cpp ServiceModule.h 
	                       main.cpp 

Log message:
	- Detect FC6 and F7 as supporting RHEL5 clusters.
	- Default to RHEL5 cluster type if an unknown release name appears in /etc/redhat-release.
	- Cleanup

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.cpp.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.h.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceModule.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceModule.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/main.cpp.diff?cvsroot=cluster&r1=1.5&r2=1.6

--- conga/ricci/modules/service/ServiceManager.cpp	2007/09/11 02:45:28	1.12
+++ conga/ricci/modules/service/ServiceManager.cpp	2007/09/11 13:53:19	1.13
@@ -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
@@ -27,714 +27,817 @@
 
 #include <vector>
 
-
 using namespace std;
 
+#define CHKCONFIG_PATH		"/sbin/chkconfig"
+#define SERVICE_PATH		"/sbin/service"
 
-#define CHKCONFIG_PATH      "/sbin/chkconfig"
-#define SERVICE_PATH        "/sbin/service"
-
-#define INITD_DIR_PATH      "/etc/init.d/"
-
-#define DESC_SIG            String("# description:")
-
-
-static bool
-RHEL4=false, RHEL5=false, FC5=false, FC6=false;
-static void
-set_release();
-
+#define INITD_DIR_PATH		"/etc/init.d/"
 
+#define DESC_SIG			String("# description:")
 
+static bool RHEL4=false, RHEL5=false, FC5=false, FC6=false;
+static void set_release();
 
 Service::Service()
 {
-  set_release();
+	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)))
+	_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???");
+	set_release();
+	if (_name->empty())
+		throw String("no service name given");
 }
 
 Service::~Service()
 {}
 
-
 XMLObject
 Service::xml(bool descr) const
 {
-  if (!_name.get())
-    throw String("internal: service not initialized");
+	if (!_name.get())
+		throw String("internal: service not initialized");
+
+	XMLObject xml("service");
+	xml.set_attr("name", name());
+	xml.set_attr("enabled", enabled() ? "true" : "false");
+	xml.set_attr("running", running() ? "true" : "false");
+	xml.set_attr("description", descr ? description() : "");
 
-  XMLObject xml("service");
-  xml.set_attr("name", name());
-  xml.set_attr("enabled", enabled()?"true":"false");
-  xml.set_attr("running", running()?"true":"false");
-  xml.set_attr("description", descr?description():"");
-  return xml;
+	return xml;
 }
 
 String
 Service::name() const
 {
-  if (!_name.get())
-    throw String("internal: service not initialized");
-  return *_name;
+	if (!_name.get())
+		throw String("internal: service not initialized");
+	return *_name;
 }
 
 bool
 Service::enabled() const
 {
-  if (!_enabled.get())
-    throw String("internal: service not initialized");
-  return *_enabled;
+	if (!_enabled.get())
+		throw String("internal: service not initialized");
+	return *_enabled;
 }
 
 bool
 Service::running() const
 {
-  if (!_running.get())
-    _running = counting_auto_ptr<bool>(new bool(service_running(name())));
-  return *_running;
+	if (!_running.get())
+		_running = counting_auto_ptr<bool>(new bool(service_running(name())));
+	return *_running;
 }
 
 String
 Service::description() const
 {
-  if (!_descr.get()) {
-    String path(INITD_DIR_PATH);
-    path += name();
-
-    String initd(File::open(path));
-
-    list<String> desc_lines;
-
-    vector<String> lines = utils::split(initd, "\n");
-    for (vector<String>::const_iterator iter = lines.begin();
-	 iter != lines.end();
-	 iter++) {
-      String line(utils::strip(*iter));
-      if (line.empty())
-	continue;
-      if (line.find(DESC_SIG) != 0)
-	continue;
-      desc_lines.push_back(line);
-      while (desc_lines.back()[desc_lines.back().size()-1] == '\\' &&
-	     ++iter != lines.end())
-	if (iter->size())
-	  desc_lines.push_back(*iter);
-	else
-	  break;
-      break;
-    }
-
-    String desc;
-    for (list<String>::const_iterator l_iter = desc_lines.begin();
-	 l_iter != desc_lines.end();
-	 l_iter++) {
-      String s = utils::rstrip(*l_iter, "\\");
-      s = utils::lstrip(s, DESC_SIG);
-      s = utils::lstrip(s, "#");
-      s = utils::lstrip(s);
-      desc += s;
-    }
+	if (!_descr.get()) {
+		String path(INITD_DIR_PATH);
+		path += name();
+
+		String initd(File::open(path));
+
+		list<String> desc_lines;
+
+		vector<String> lines = utils::split(initd, "\n");
+		for (vector<String>::const_iterator
+				iter = lines.begin() ;
+				iter != lines.end() ;
+				iter++)
+		{
+			String line(utils::strip(*iter));
+			if (line.empty())
+				continue;
+			if (line.find(DESC_SIG) != 0)
+				continue;
+
+			desc_lines.push_back(line);
+			while (desc_lines.back()[desc_lines.back().size() - 1] == '\\' && ++iter != lines.end())
+			{
+				if (iter->size())
+					desc_lines.push_back(*iter);
+				else
+					break;
+			}
+
+			break;
+		}
+
+		String desc;
+		for (list<String>::const_iterator
+				l_iter = desc_lines.begin() ;
+				l_iter != desc_lines.end() ;
+				l_iter++)
+		{
+			String s = utils::rstrip(*l_iter, "\\");
+			s = utils::lstrip(s, DESC_SIG);
+			s = utils::lstrip(s, "#");
+			s = utils::lstrip(s);
+			desc += s;
+		}
 
-    _descr = counting_auto_ptr<String>(new String(desc));
-  }
+		_descr = counting_auto_ptr<String>(new String(desc));
+	}
 
-  return *_descr;
+	return *_descr;
 }
 
 void
 Service::enable()
 {
-  if (!enabled()) {
-    enable_service(name(), true);
-    *_enabled = true;
-  }
+	if (!enabled()) {
+		enable_service(name(), true);
+		*_enabled = true;
+	}
 }
 
 void
 Service::disable()
 {
-  if (enabled()) {
-    enable_service(name(), false);
-    *_enabled = false;
-  }
+	if (enabled()) {
+		enable_service(name(), false);
+		*_enabled = false;
+	}
 }
 
 void
 Service::start()
 {
-  running();
-  run_service(name(), START);
-  *_running = true;
+	running();
+	run_service(name(), START);
+	*_running = true;
 }
 
 void
 Service::restart()
 {
-  running();
-  run_service(name(), RESTART);
-  *_running = true;
+	running();
+	run_service(name(), RESTART);
+	*_running = true;
 }
 
 void
 Service::stop()
 {
-  running();
-  run_service(name(), STOP);
-  *_running = false;
+	running();
+	run_service(name(), STOP);
+	*_running = false;
 }
 
 void
 Service::enable_service(const String& name, bool on)
 {
-  String out, err;
-  int status;
-  vector<String> args;
-  args.push_back(name);
-  if (on)
-    args.push_back("on");
-  else
-    args.push_back("off");
-  if (utils::execute(CHKCONFIG_PATH, args, out, err, status, false))
-    throw command_not_found_error_msg(CHKCONFIG_PATH);
-  if (status != 0)
-    throw String("chkconfig failed for service ") + name;
+	String out, err;
+	int status;
+	vector<String> args;
+
+	args.push_back(name);
+
+	if (on)
+		args.push_back("on");
+	else
+		args.push_back("off");
+
+	if (utils::execute(CHKCONFIG_PATH, args, out, err, status, false))
+		throw command_not_found_error_msg(CHKCONFIG_PATH);
+	if (status != 0)
+		throw String("chkconfig failed for service ") + name + ": " + err;
 }
 
 bool
 Service::service_running(const String& name)
 {
-  String path(INITD_DIR_PATH);
-  path += name;
+	String path(INITD_DIR_PATH);
+	path += name;
 
-  String out, err;
-  int status;
-  vector<String> args;
-  args.push_back("status");
-  if (utils::execute(path, args, out, err, status, false) != 0)
-    throw command_not_found_error_msg(path);
-  return status == 0;
+	String out, err;
+	int status;
+	vector<String> args;
+
+	args.push_back("status");
+	if (utils::execute(path, args, out, err, status, false) != 0)
+		throw command_not_found_error_msg(path);
+	return status == 0;
 }
 
 void
 Service::run_service(const String& name, ActionState state)
 {
-  String path(INITD_DIR_PATH);
-  path += name;
+	String path(INITD_DIR_PATH);
+	path += name;
 
-  String out, err;
-  int status;
-  vector<String> args;
-  switch (state) {
-    case START:
-      args.push_back("start");
-      break;
-    case STOP:
-      args.push_back("stop");
-      break;
-    case RESTART:
-      args.push_back("restart");
-      break;
-  }
-  if (utils::execute(path, args, out, err, status, false) != 0)
-    throw command_not_found_error_msg(path);
-  if (status) {
-    bool running = service_running(name);
-    if (state == START || state == RESTART) {
-      if (!running)
-	throw String("service ") + name + " " + String(state == START ? "start" : "restart") + " failed";
-    } else {
-      if (running)
-	throw String("service ") + name + " stop failed";
-    }
-  }
+	String out, err;
+	int status;
+	vector<String> args;
+
+	switch (state) {
+		case START:
+			args.push_back("start");
+			break;
+
+		case STOP:
+			args.push_back("stop");
+			break;
+
+		case RESTART:
+			args.push_back("restart");
+			break;
+	}
+
+	if (utils::execute(path, args, out, err, status, false) != 0)
+		throw command_not_found_error_msg(path);
+
+	if (status) {
+		bool running = service_running(name);
+		if (state == START || state == RESTART) {
+			if (!running) {
+				throw String("service ") + name + " "
+						+ String(state == START ? "start" : "restart")
+						+ " failed: " + err;
+			}
+		} else {
+			if (running)
+				throw String("service ") + name + " stop failed: " + err;
+		}
+	}
 }
 
-
-
-
-
-
-
-
-
 ServiceSet::ServiceSet()
 {
-  set_release();
+	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)))
+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???");
+	set_release();
+
+	if (_name->empty())
+		throw String("no ServiceSet name");
 }
 
 ServiceSet::~ServiceSet()
 {}
 
-
 XMLObject
 ServiceSet::xml(bool descr) const
 {
-  XMLObject xml("set");
-  xml.set_attr("name", name());
-  xml.set_attr("enabled", enabled()?"true":"false");
-  xml.set_attr("running", running()?"true":"false");
-  xml.set_attr("description", descr?description():"");
-  return xml;
+	XMLObject xml("set");
+	xml.set_attr("name", name());
+	xml.set_attr("enabled", enabled() ? "true" : "false");
+	xml.set_attr("running", running() ? "true" : "false");
+	xml.set_attr("description", descr ? description() : "");
+	return xml;
 }
 
 String
 ServiceSet::name() const
 {
-  if (!_name.get() || servs.empty())
-    throw String("internal: ServiceSet not initialized");
-  return *_name;
+	if (!_name.get() || servs.empty())
+		throw String("internal: ServiceSet not initialized");
+	return *_name;
 }
 
 bool
 ServiceSet::enabled() const
 {
-  name();
-  for (list<Service>::const_iterator iter = servs.begin();
-       iter != servs.end();
-       iter++)
-    if (!iter->enabled())
-      return false;
-  return true;
+	name();
+
+	for (list<Service>::const_iterator
+		iter = servs.begin() ;
+		iter != servs.end() ;
+		iter++)
+	{
+		if (!iter->enabled())
+			return false;
+	}
+
+	return true;
 }
 
 bool
 ServiceSet::running() const
 {
-  name();
-  for (list<Service>::const_iterator iter = servs.begin();
-       iter != servs.end();
-       iter++)
-    if (!iter->running())
-      return false;
-  return true;
+	name();
+
+	for (list<Service>::const_iterator
+			iter = servs.begin() ;
+			iter != servs.end() ;
+			iter++)
+	{
+		if (!iter->running())
+			return false;
+	}
+	
+	return true;
 }
 
 String
 ServiceSet::description() const
 {
-  name();
-  return *_descr;
+	name();
+	return *_descr;
 }
 
 void
 ServiceSet::enable()
 {
-  name();
-  try {
-    for (list<Service>::iterator iter = servs.begin();
-	 iter != servs.end();
-	 iter++)
-      iter->enable();
-  } catch (String e) {
-    throw String("service set '") + name() + "' failed to enable";
-  }
+	name();
+
+	try {
+		for (list<Service>::iterator
+				iter = servs.begin() ;
+				iter != servs.end() ;
+				iter++)
+		{
+			iter->enable();
+		}
+	} catch (String e) {
+		throw String("service set '") + name() + "' failed to enable: " + e;
+	}
 }
 
 void
 ServiceSet::disable()
 {
-  name();
-  try {
-    for (list<Service>::iterator iter = servs.begin();
-	 iter != servs.end();
-	 iter++)
-      iter->disable();
-  } catch (String e) {
-    throw String("service set '") + name() + "' failed to disable";
-  }
+	name();
+
+	try {
+		for (list<Service>::iterator
+				iter = servs.begin() ;
+				iter != servs.end() ;
+				iter++)
+		{
+			iter->disable();
+		}
+	} catch (String e) {
+		throw String("service set '") + name() + "' failed to disable: " + e;
+	}
 }
 
 void
 ServiceSet::start()
 {
-  name();
-  try {
-    for (list<Service>::iterator iter = servs.begin();
-	 iter != servs.end();
-	 iter++)
-      iter->start();
-  } catch (String e) {
-    throw String("service set '") + name() + "' failed to start";
-  }
+	name();
+
+	try {
+		for (list<Service>::iterator
+				iter = servs.begin() ;
+				iter != servs.end() ;
+				iter++)
+		{
+			iter->start();
+		}
+	} catch (String e) {
+		throw String("service set '") + name() + "' failed to start: " + e;
+	}
 }
 
 void
 ServiceSet::restart()
 {
-  name();
-  try {
-    // ordered sequence: last started, first to be stoped
-    stop();
-    start();
-  } catch (String e) {
-    throw String("service set '") + name() + "' failed to restart";
-  }
+	name();
+
+	try {
+		// ordered sequence: last started, first to be stoped
+		stop();
+		start();
+	} catch (String e) {
+		throw String("service set '") + name() + "' failed to restart: " + e;
+	}
 }
 
 void
 ServiceSet::stop()
 {
-  name();
-  try {
-    for (list<Service>::reverse_iterator iter = servs.rbegin();
-	 iter != servs.rend();
-	 iter++)
-      iter->stop();
-  } catch (String e) {
-    throw String("service set '") + name() + "' failed to stop";
-  }
-}
-
-
-
+	name();
 
+	try {
+		for (list<Service>::reverse_iterator
+				iter = servs.rbegin() ;
+				iter != servs.rend() ;
+				iter++)
+		{
+			iter->stop();
+		}
+	} catch (String e) {
+		throw String("service set '") + name() + "' failed to stop: " + e;
+	}
+}
 
 ServiceManager::ServiceManager()
 {
-  set_release();
+	set_release();
 
-  String out, err;
-  int status;
-  vector<String> args;
-  args.push_back("--list");
-  if (utils::execute(CHKCONFIG_PATH, args, out, err, status, true))
-    throw command_not_found_error_msg(CHKCONFIG_PATH);
-  if (status)
-    throw String("chkconfig failed");
-  vector<String> lines = utils::split(out, "\n");
-  for (vector<String>::const_iterator iter = lines.begin();
-       iter != lines.end();
-       iter++) {
-    vector<String> words = utils::split(utils::strip(*iter));
-    if (words.size() != 8)
-      continue;
-    String name = words[0];
-    bool enabled = false;
-    for (vector<String>::size_type i=2;
-	 i < words.size() - 1;
-	 i++)
-      if (words[i].find("on") != String::npos)
-	enabled = true;
-    _servs[name] = Service(name, enabled);
-  }
+	String out, err;
+	int status;
+	vector<String> args;
+
+	args.push_back("--list");
+	if (utils::execute(CHKCONFIG_PATH, args, out, err, status, true))
+		throw command_not_found_error_msg(CHKCONFIG_PATH);
+	if (status)
+		throw String("chkconfig failed: " + err);
+
+	vector<String> lines = utils::split(out, "\n");
+	for (vector<String>::const_iterator
+			iter = lines.begin() ;
+			iter != lines.end() ;
+			iter++)
+	{
+		vector<String> words = utils::split(utils::strip(*iter));
+		if (words.size() != 8)
+			continue;
+
+		String name = words[0];
+		bool enabled = false;
+		for (vector<String>::size_type i = 2; i < words.size() - 1; i++) {
+			if (words[i].find("on") != String::npos)
+				enabled = true;
+		}
+		_servs[name] = Service(name, enabled);
+	}
 
-  _sets = generate_sets();
+	_sets = generate_sets();
 }
 
 ServiceManager::~ServiceManager()
 {}
 
-
 map<String, ServiceSet>
 ServiceManager::generate_sets()
 {
-  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);
-  if (populate_set(s, servs))
-    sets[name] = s;
-
-
-  if (RHEL4 || FC5) {
-    servs.clear();
-    name = "Cluster Base - Gulm";
-    descr = "Cluster infrastructure: ccs, gulm";
-    s = ServiceSet(name, descr);
-    servs.push_back("ccsd");
-    servs.push_back("lock_gulmd");
-    if (populate_set(s, servs))
-      sets[name] = s;
-  }
-
-
-  servs.clear();
-  name = "Cluster Service Manager";
-  descr = "Cluster Service Manager: rgmanager";
-  s = ServiceSet(name, descr);
-  servs.push_back("rgmanager");
-  if (populate_set(s, servs))
-    sets[name] = s;
-
-
-  servs.clear();
-  name = "Clustered Storage";
-  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);
-  if (populate_set(s, servs))
-    sets[name] = s;
-
-
-  servs.clear();
-  name = "Linux Virtual Server";
-  descr = "Red Hat's LVS implementation: pulse, piranha";
-  s = ServiceSet(name, descr);
-  servs.push_back("pulse");
-  servs.push_back("piranha-gui");
-  if (populate_set(s, servs))
-    sets[name] = s;
+	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);
+	if (populate_set(s, servs))
+		sets[name] = s;
+
+	if (RHEL4 || FC5) {
+		servs.clear();
+		name = "Cluster Base - Gulm";
+		descr = "Cluster infrastructure: ccs, gulm";
+		s = ServiceSet(name, descr);
+		servs.push_back("ccsd");
+		servs.push_back("lock_gulmd");
+		if (populate_set(s, servs))
+			sets[name] = s;
+	}
+
+	servs.clear();
+	name = "Cluster Service Manager";
+	descr = "Cluster Service Manager: rgmanager";
+	s = ServiceSet(name, descr);
+	servs.push_back("rgmanager");
+	if (populate_set(s, servs))
+		sets[name] = s;
+
+	servs.clear();
+	name = "Clustered Storage";
+	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);
+	if (populate_set(s, servs))
+		sets[name] = s;
+
+	servs.clear();
+	name = "Linux Virtual Server";
+	descr = "Red Hat's LVS implementation: pulse, piranha";
+	s = ServiceSet(name, descr);
+	servs.push_back("pulse");
+	servs.push_back("piranha-gui");
+	if (populate_set(s, servs))
+		sets[name] = s;
 
   return sets;
 }
 
 bool
-ServiceManager::populate_set(ServiceSet& ss,
-			     std::list<String> servs)
+ServiceManager::populate_set(ServiceSet& ss, std::list<String> servs)
 {
-  for (list<String>::iterator n_iter = servs.begin();
-       n_iter != servs.end();
-       n_iter++) {
-    if (_servs.find(*n_iter) == _servs.end())
-      return false;
-    else
-      ss.servs.push_back(_servs[*n_iter]);
-  }
-  return true;
+	for (list<String>::iterator
+			n_iter = servs.begin() ;
+			n_iter != servs.end() ;
+			n_iter++)
+	{
+		if (_servs.find(*n_iter) == _servs.end())
+			return false;
+		else
+			ss.servs.push_back(_servs[*n_iter]);
+	}
+
+	return true;
 }
 
 
 void
-ServiceManager::enable(const std::list<String>& services,
-		       const std::list<String>& sets)
-{
-  // check
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    if (_servs.find(*iter) == _servs.end())
-      throw String("no such service: ") + *iter;
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    if (_sets.find(*iter) == _sets.end())
-      throw String("no such service set: ") + *iter;
-
-  // apply
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    _servs[*iter].enable();
-
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    _sets[*iter].enable();
+ServiceManager::enable(	const std::list<String>& services,
+						const std::list<String>& sets)
+{
+	// check
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		if (_servs.find(*iter) == _servs.end())
+			throw String("no such service: ") + *iter;
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		if (_sets.find(*iter) == _sets.end())
+			throw String("no such service set: ") + *iter;
+	}
+
+	// apply
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		_servs[*iter].enable();
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		_sets[*iter].enable();
+	}
 }
 
 void
 ServiceManager::disable(const std::list<String>& services,
-			const std::list<String>& sets)
+						const std::list<String>& sets)
 {
-  // check
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    if (_servs.find(*iter) == _servs.end())
-      throw String("no such service: ") + *iter;
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    if (_sets.find(*iter) == _sets.end())
-      throw String("no such service set: ") + *iter;
-
-  // apply
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    _servs[*iter].disable();
-
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    _sets[*iter].disable();
-}
-
-void
-ServiceManager::start(const std::list<String>& services,
-		      const std::list<String>& sets)
-{
-  // check
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    if (_servs.find(*iter) == _servs.end())
-      throw String("no such service: ") + *iter;
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    if (_sets.find(*iter) == _sets.end())
-      throw String("no such service set: ") + *iter;
-
-  // apply
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    _servs[*iter].start();
-
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    _sets[*iter].start();
+	// check
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		if (_servs.find(*iter) == _servs.end())
+			throw String("no such service: ") + *iter;
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		if (_sets.find(*iter) == _sets.end())
+			throw String("no such service set: ") + *iter;
+	}
+
+	// apply
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		_servs[*iter].disable();
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		_sets[*iter].disable();
+	}
+}
+
+void
+ServiceManager::start(	const std::list<String>& services,
+						const std::list<String>& sets)
+{
+	// check
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		if (_servs.find(*iter) == _servs.end())
+			throw String("no such service: ") + *iter;
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		if (_sets.find(*iter) == _sets.end())
+			throw String("no such service set: ") + *iter;
+	}
+
+	// apply
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		_servs[*iter].start();
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		_sets[*iter].start();
+	}
 }
 
 void
 ServiceManager::restart(const std::list<String>& services,
-		     const std::list<String>& sets)
+						const std::list<String>& sets)
 {
-  // check
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    if (_servs.find(*iter) == _servs.end())
-      throw String("no such service: ") + *iter;
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    if (_sets.find(*iter) == _sets.end())
-      throw String("no such service set: ") + *iter;
-
-  // apply
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    _servs[*iter].restart();
-
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    _sets[*iter].restart();
-}
-
-void
-ServiceManager::stop(const std::list<String>& services,
-		     const std::list<String>& sets)
-{
-  // check
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    if (_servs.find(*iter) == _servs.end())
-      throw String("no such service: ") + *iter;
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    if (_sets.find(*iter) == _sets.end())
-      throw String("no such service set: ") + *iter;
-
-  // apply
-  for (list<String>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    _servs[*iter].stop();
-
-  for (list<String>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    _sets[*iter].stop();
-}
-
-void
-ServiceManager::lists(std::list<Service>& services,
-		      std::list<ServiceSet>& sets)
-{
-  services.clear();
-  sets.clear();
-
-  for (map<String, Service>::const_iterator iter = _servs.begin();
-       iter != _servs.end();
-       iter++)
-    services.push_back(iter->second);
-
-  for (map<String, ServiceSet>::const_iterator iter = _sets.begin();
-       iter != _sets.end();
-       iter++)
-    sets.push_back(iter->second);
-}
-
-void
-ServiceManager::query(const std::list<String>& serv_names,
-		      const std::list<String>& set_names,
-		      std::list<Service>& services,
-		      std::list<ServiceSet>& sets)
-{
-  services.clear();
-  sets.clear();
-
-  for (list<String>::const_iterator iter = serv_names.begin();
-       iter != serv_names.end();
-       iter++)
-    if (_servs.find(*iter) != _servs.end())
-      services.push_back(_servs[*iter]);
-
-  for (list<String>::const_iterator iter = set_names.begin();
-       iter != set_names.end();
-       iter++)
-    if (_sets.find(*iter) != _sets.end())
-      sets.push_back(_sets[*iter]);
+	// check
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		if (_servs.find(*iter) == _servs.end())
+			throw String("no such service: ") + *iter;
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		if (_sets.find(*iter) == _sets.end())
+			throw String("no such service set: ") + *iter;
+	}
+
+	// apply
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		_servs[*iter].restart();
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		_sets[*iter].restart();
+	}
+}
+
+void
+ServiceManager::stop(	const std::list<String>& services,
+						const std::list<String>& sets)
+{
+	// check
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		if (_servs.find(*iter) == _servs.end())
+			throw String("no such service: ") + *iter;
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		if (_sets.find(*iter) == _sets.end())
+			throw String("no such service set: ") + *iter;
+	}
+
+	// apply
+	for (list<String>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		_servs[*iter].stop();
+	}
+
+	for (list<String>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		_sets[*iter].stop();
+	}
+}
+
+void
+ServiceManager::lists(	std::list<Service>& services,
+						std::list<ServiceSet>& sets)
+{
+	services.clear();
+	sets.clear();
+
+	for (map<String, Service>::const_iterator
+			iter = _servs.begin() ;
+			iter != _servs.end() ;
+			iter++)
+	{
+		services.push_back(iter->second);
+	}
+
+	for (map<String, ServiceSet>::const_iterator
+			iter = _sets.begin() ;
+			iter != _sets.end() ;
+			iter++)
+	{
+		sets.push_back(iter->second);
+	}
+}
+
+void
+ServiceManager::query(	const std::list<String>& serv_names,
+						const std::list<String>& set_names,
+						std::list<Service>& services,
+						std::list<ServiceSet>& sets)
+{
+	services.clear();
+	sets.clear();
+
+	for (list<String>::const_iterator
+			iter = serv_names.begin() ;
+			iter != serv_names.end() ;
+			iter++)
+	{
+		if (_servs.find(*iter) != _servs.end())
+			services.push_back(_servs[*iter]);
+	}
+
+	for (list<String>::const_iterator iter = set_names.begin() ;
+			iter != set_names.end() ;
+			iter++)
+	{
+		if (_sets.find(*iter) != _sets.end())
+			sets.push_back(_sets[*iter]);
+	}
 }
 
-
-
-
-
-
-
 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("Fedora Core") != release.npos &&
-	     release.find("6") != release.npos)
-      // TODO: detect FC6
-      FC6 = true;
-    else if (release.find("Tikanga") != release.npos)
-      RHEL5 = true;
+	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 {
+			/* Fallback to RHEL5 if we don't match on any release name. */
+			RHEL5 = true;
+		}
 
-    release_set = true;
-  }
+		release_set = true;
+	}
 }
--- conga/ricci/modules/service/ServiceManager.h	2007/09/11 02:45:28	1.5
+++ conga/ricci/modules/service/ServiceManager.h	2007/09/11 13:53:19	1.6
@@ -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
@@ -37,104 +37,96 @@
 
 class Service
 {
- public:
-  Service();
-  virtual ~Service();
-
-  String name() const;
-  bool enabled() const;
-  bool running() const;
-  String description() const;
-
-  void enable();
-  void disable();
-  void restart();
-  void start();
-  void stop();
-
-  XMLObject xml(bool descriptions) const;
-
- private:
-  Service(const String& name, bool enabled);
-
-  mutable counting_auto_ptr<String> _name;
-  mutable counting_auto_ptr<String> _descr;
-  mutable counting_auto_ptr<bool> _enabled;
-  mutable counting_auto_ptr<bool> _running;
-
-  enum ActionState {
-    START,
-    STOP,
-    RESTART
-  };
-
-  static void enable_service(const String& name, bool on);
-  static bool service_running(const String& name);
-  static void run_service(const String& name, ActionState state);
-
-  friend class ServiceManager;
+	public:
+		Service();
+		virtual ~Service();
+
+		String name() const;
+		bool enabled() const;
+		bool running() const;
+		String description() const;
+
+		void enable();
+		void disable();
+		void restart();
+		void start();
+		void stop();
+
+		XMLObject xml(bool descriptions) const;
+
+	private:
+		Service(const String& name, bool enabled);
+
+		mutable counting_auto_ptr<String> _name;
+		mutable counting_auto_ptr<String> _descr;
+		mutable counting_auto_ptr<bool> _enabled;
+		mutable counting_auto_ptr<bool> _running;
+
+		enum ActionState {
+			START,
+			STOP,
+			RESTART
+		};
+
+		static void enable_service(const String& name, bool on);
+		static bool service_running(const String& name);
+		static void run_service(const String& name, ActionState state);
 
+	friend class ServiceManager;
 };
 
 class ServiceSet
 {
- public:
-  ServiceSet();
-  ServiceSet(const String& name, const String& description);
-  virtual ~ServiceSet();
-
-  String name() const;
-  bool enabled() const;
-  bool running() const;
-  String description() const;
-
-  void enable();
-  void disable();
-  void start();
-  void restart();
-  void stop();
-
-  std::list<Service> servs;
-
-  XMLObject xml(bool descriptions) const;
-
- private:
-  mutable counting_auto_ptr<String> _name;
-  mutable counting_auto_ptr<String> _descr;
-
+	public:
+		ServiceSet();
+		ServiceSet(const String& name, const String& description);
+		virtual ~ServiceSet();
+
+		String name() const;
+		bool enabled() const;
+		bool running() const;
+		String description() const;
+
+		void enable();
+		void disable();
+		void start();
+		void restart();
+		void stop();
+
+		std::list<Service> servs;
+		XMLObject xml(bool descriptions) const;
+
+	private:
+		mutable counting_auto_ptr<String> _name;
+		mutable counting_auto_ptr<String> _descr;
 };
 
-
 class ServiceManager
 {
- public:
-  ServiceManager();
-  virtual ~ServiceManager();
-
-  void enable(const std::list<String>& services, const std::list<String>& sets);
-  void disable(const std::list<String>& services, const std::list<String>& sets);
-
-  void start(const std::list<String>& services, const std::list<String>& sets);
-  void restart(const std::list<String>& services, const std::list<String>& sets);
-  void stop(const std::list<String>& services, const std::list<String>& sets);
-
-  void lists(std::list<Service>& services,
-	     std::list<ServiceSet>& sets);
-
-  void query(const std::list<String>& serv_names,
-	     const std::list<String>& set_names,
-	     std::list<Service>& services,
-	     std::list<ServiceSet>& sets);
-
- private:
-  std::map<String, Service>     _servs;
-  std::map<String, ServiceSet>  _sets;
-
-  std::map<String, ServiceSet> generate_sets();
-
-  bool populate_set(ServiceSet& ss, std::list<String> servs);
+	public:
+		ServiceManager();
+		virtual ~ServiceManager();
+
+		void enable(const std::list<String>& services, const std::list<String>& sets);
+		void disable(const std::list<String>& services, const std::list<String>& sets);
+
+		void start(const std::list<String>& services, const std::list<String>& sets);
+		void restart(const std::list<String>& services, const std::list<String>& sets);
+		void stop(const std::list<String>& services, const std::list<String>& sets);
+
+		void lists(std::list<Service>& services, std::list<ServiceSet>& sets);
+
+		void query(	const std::list<String>& serv_names,
+					const std::list<String>& set_names,
+					std::list<Service>& services,
+					std::list<ServiceSet>& sets);
+
+	private:
+		std::map<String, Service> _servs;
+		std::map<String, ServiceSet> _sets;
+		std::map<String, ServiceSet> generate_sets();
 
+		bool populate_set(ServiceSet& ss, std::list<String> servs);
 };
 
-
-#endif  // ServiceManager_h
+#endif
--- conga/ricci/modules/service/ServiceModule.cpp	2007/09/11 02:45:28	1.5
+++ conga/ricci/modules/service/ServiceModule.cpp	2007/09/11 13:53:19	1.6
@@ -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
@@ -27,7 +27,6 @@
 
 using namespace std;
 
-
 static VarMap enable(const VarMap& args);
 static VarMap disable(const VarMap& args);
 static VarMap start(const VarMap& args);
@@ -38,264 +37,285 @@
 
 static ApiFcnMap build_fcn_map();
 
-
 ServiceModule::ServiceModule() :
-  Module(build_fcn_map())
+	Module(build_fcn_map())
 {}
 
 ServiceModule::~ServiceModule()
 {}
 
-
 ApiFcnMap
 build_fcn_map()
 {
-  FcnMap   api_1_0;
-  api_1_0["enable"]     = enable;
-  api_1_0["disable"]    = disable;
-  api_1_0["start"]      = start;
-  api_1_0["restart"]	= restart;
-  api_1_0["stop"]       = stop;
-  api_1_0["list"]       = lists;
-  api_1_0["query"]      = query;
+	FcnMap api_1_0;
 
-  ApiFcnMap   api_fcn_map;
-  api_fcn_map["1.0"] = api_1_0;
+	api_1_0["enable"] = enable;
+	api_1_0["disable"] = disable;
+	api_1_0["start"] = start;
+	api_1_0["restart"] = restart;
+	api_1_0["stop"] = stop;
+	api_1_0["list"] = lists;
+	api_1_0["query"] = query;
 
-  return api_fcn_map;
-}
+	ApiFcnMap api_fcn_map;
+	api_fcn_map["1.0"] = api_1_0;
 
+	return api_fcn_map;
+}
 
 VarMap
 enable(const VarMap& args)
 {
-  list<XMLObject> serv_list;
-  try {
-    VarMap::const_iterator iter = args.find("services");
-    if (iter == args.end())
-      throw APIerror("missing services variable");
-    serv_list = iter->second.get_list_XML();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  list<String> services, sets;
-  for (list<XMLObject>::const_iterator iter = serv_list.begin();
-       iter != serv_list.end();
-       iter++) {
-    if (iter->tag() == "service")
-      services.push_back(iter->get_attr("name"));
-    else if (iter->tag() == "set")
-      sets.push_back(iter->get_attr("name"));
-  }
+	list<XMLObject> serv_list;
 
-  ServiceManager().enable(services, sets);
+	try {
+		VarMap::const_iterator iter = args.find("services");
+		if (iter == args.end())
+			throw APIerror("missing services variable");
+		serv_list = iter->second.get_list_XML();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	list<String> services, sets;
+	for (list<XMLObject>::const_iterator
+			iter = serv_list.begin() ;
+			iter != serv_list.end() ;
+			iter++)
+	{
+		if (iter->tag() == "service")
+			services.push_back(iter->get_attr("name"));
+		else if (iter->tag() == "set")
+			sets.push_back(iter->get_attr("name"));
+	}
 
-  return VarMap();
+	ServiceManager().enable(services, sets);
+	return VarMap();
 }
 
 VarMap
 disable(const VarMap& args)
 {
-  list<XMLObject> serv_list;
-  try {
-    VarMap::const_iterator iter = args.find("services");
-    if (iter == args.end())
-      throw APIerror("missing services variable");
-    serv_list = iter->second.get_list_XML();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  list<String> services, sets;
-  for (list<XMLObject>::const_iterator iter = serv_list.begin();
-       iter != serv_list.end();
-       iter++) {
-    if (iter->tag() == "service")
-      services.push_back(iter->get_attr("name"));
-    else if (iter->tag() == "set")
-      sets.push_back(iter->get_attr("name"));
-  }
+	list<XMLObject> serv_list;
 
-  ServiceManager().disable(services, sets);
+	try {
+		VarMap::const_iterator iter = args.find("services");
+		if (iter == args.end())
+			throw APIerror("missing services variable");
+		serv_list = iter->second.get_list_XML();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	list<String> services, sets;
+	for (list<XMLObject>::const_iterator
+			iter = serv_list.begin() ;
+			iter != serv_list.end() ;
+			iter++)
+	{
+		if (iter->tag() == "service")
+			services.push_back(iter->get_attr("name"));
+		else if (iter->tag() == "set")
+			sets.push_back(iter->get_attr("name"));
+	}
 
-  return VarMap();
+	ServiceManager().disable(services, sets);
+	return VarMap();
 }
 
 VarMap
 start(const VarMap& args)
 {
-  list<XMLObject> serv_list;
-  try {
-    VarMap::const_iterator iter = args.find("services");
-    if (iter == args.end())
-      throw APIerror("missing services variable");
-    serv_list = iter->second.get_list_XML();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  list<String> services, sets;
-  for (list<XMLObject>::const_iterator iter = serv_list.begin();
-       iter != serv_list.end();
-       iter++) {
-    if (iter->tag() == "service")
-      services.push_back(iter->get_attr("name"));
-    else if (iter->tag() == "set")
-      sets.push_back(iter->get_attr("name"));
-  }
+	list<XMLObject> serv_list;
 
-  ServiceManager().start(services, sets);
+	try {
+		VarMap::const_iterator iter = args.find("services");
+		if (iter == args.end())
+			throw APIerror("missing services variable");
+		serv_list = iter->second.get_list_XML();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	list<String> services, sets;
+	for (list<XMLObject>::const_iterator
+			iter = serv_list.begin() ;
+			iter != serv_list.end() ;
+			iter++)
+	{
+		if (iter->tag() == "service")
+			services.push_back(iter->get_attr("name"));
+		else if (iter->tag() == "set")
+			sets.push_back(iter->get_attr("name"));
+	}
 
-  return VarMap();
+	ServiceManager().start(services, sets);
+	return VarMap();
 }
 
 VarMap
 restart(const VarMap& args)
 {
-  list<XMLObject> serv_list;
-  try {
-    VarMap::const_iterator iter = args.find("services");
-    if (iter == args.end())
-      throw APIerror("missing services variable");
-    serv_list = iter->second.get_list_XML();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  list<String> services, sets;
-  for (list<XMLObject>::const_iterator iter = serv_list.begin();
-       iter != serv_list.end();
-       iter++) {
-    if (iter->tag() == "service")
-      services.push_back(iter->get_attr("name"));
-    else if (iter->tag() == "set")
-      sets.push_back(iter->get_attr("name"));
-  }
+	list<XMLObject> serv_list;
 
-  ServiceManager().restart(services, sets);
+	try {
+		VarMap::const_iterator iter = args.find("services");
+		if (iter == args.end())
+			throw APIerror("missing services variable");
+		serv_list = iter->second.get_list_XML();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	list<String> services, sets;
+	for (list<XMLObject>::const_iterator
+			iter = serv_list.begin() ;
+			iter != serv_list.end() ;
+			iter++)
+	{
+		if (iter->tag() == "service")
+			services.push_back(iter->get_attr("name"));
+		else if (iter->tag() == "set")
+			sets.push_back(iter->get_attr("name"));
+	}
 
-  return VarMap();
+	ServiceManager().restart(services, sets);
+	return VarMap();
 }
 
 VarMap
 stop(const VarMap& args)
 {
-  list<XMLObject> serv_list;
-  try {
-    VarMap::const_iterator iter = args.find("services");
-    if (iter == args.end())
-      throw APIerror("missing services variable");
-    serv_list = iter->second.get_list_XML();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  list<String> services, sets;
-  for (list<XMLObject>::const_iterator iter = serv_list.begin();
-       iter != serv_list.end();
-       iter++) {
-    if (iter->tag() == "service")
-      services.push_back(iter->get_attr("name"));
-    else if (iter->tag() == "set")
-      sets.push_back(iter->get_attr("name"));
-  }
+	list<XMLObject> serv_list;
 
-  ServiceManager().stop(services, sets);
+	try {
+		VarMap::const_iterator iter = args.find("services");
+		if (iter == args.end())
+			throw APIerror("missing services variable");
+		serv_list = iter->second.get_list_XML();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	list<String> services, sets;
+	for (list<XMLObject>::const_iterator
+			iter = serv_list.begin() ;
+			iter != serv_list.end() ;
+			iter++)
+	{
+		if (iter->tag() == "service")
+			services.push_back(iter->get_attr("name"));
+		else if (iter->tag() == "set")
+			sets.push_back(iter->get_attr("name"));
+	}
 
-  return VarMap();
+	ServiceManager().stop(services, sets);
+	return VarMap();
 }
 
 VarMap
 lists(const VarMap& args)
 {
-  bool descr;
-  try {
-    descr = false;
-    VarMap::const_iterator iter = args.find("description");
-    if (iter != args.end())
-      descr = iter->second.get_bool();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  // command
-
-  list<XMLObject> xml_list;
-
-  list<Service> services;
-  list<ServiceSet> sets;
-  ServiceManager().lists(services, sets);
-  for (list<Service>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    xml_list.push_back(iter->xml(descr));
-  for (list<ServiceSet>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    xml_list.push_back(iter->xml(descr));
-
-  // response
-  Variable var("services", xml_list);
-
-  VarMap ret;
-  ret.insert(pair<String, Variable>(var.name(), var));
-  return ret;
+	bool descr;
+
+	try {
+		descr = false;
+		VarMap::const_iterator iter = args.find("description");
+
+		if (iter != args.end())
+			descr = iter->second.get_bool();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	// command
+	list<XMLObject> xml_list;
+
+	list<Service> services;
+	list<ServiceSet> sets;
+	ServiceManager().lists(services, sets);
+
+	for (list<Service>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		xml_list.push_back(iter->xml(descr));
+	}
+
+	for (list<ServiceSet>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		xml_list.push_back(iter->xml(descr));
+	}
+
+	// response
+	Variable var("services", xml_list);
+	VarMap ret;
+	ret.insert(pair<String, Variable>(var.name(), var));
+	return ret;
 }
 
 VarMap
 query(const VarMap& args)
 {
-  list<XMLObject> search_list;
-  bool descr;
-  try {
-    VarMap::const_iterator iter = args.find("search");
-    if (iter == args.end())
-      throw APIerror("missing search variable");
-    search_list = iter->second.get_list_XML();
-
-    descr = false;
-    iter = args.find("description");
-    if (iter != args.end())
-      descr = iter->second.get_bool();
-  } catch ( String e ) {
-    throw APIerror(e);
-  }
-
-  // command
-
-  list<String> serv_names, set_names;
-  for (list<XMLObject>::const_iterator iter = search_list.begin();
-       iter != search_list.end();
-       iter++) {
-    if (iter->tag() == "service")
-      serv_names.push_back(iter->get_attr("name"));
-    else if (iter->tag() == "set")
-      set_names.push_back(iter->get_attr("name"));
-  }
-
-  list<Service> services;
-  list<ServiceSet> sets;
-  ServiceManager().query(serv_names,
-			 set_names,
-			 services,
-			 sets);
-
-  // response
-
-  list<XMLObject> result_list;
-  for (list<Service>::const_iterator iter = services.begin();
-       iter != services.end();
-       iter++)
-    result_list.push_back(iter->xml(descr));
-  for (list<ServiceSet>::const_iterator iter = sets.begin();
-       iter != sets.end();
-       iter++)
-    result_list.push_back(iter->xml(descr));
-
-  Variable var("result", result_list);
-
-  VarMap ret;
-  ret.insert(pair<String, Variable>(var.name(), var));
-  return ret;
+	list<XMLObject> search_list;
+	bool descr;
+
+	try {
+		VarMap::const_iterator iter = args.find("search");
+		if (iter == args.end())
+			throw APIerror("missing search variable");
+		search_list = iter->second.get_list_XML();
+
+		descr = false;
+		iter = args.find("description");
+		if (iter != args.end())
+			descr = iter->second.get_bool();
+	} catch ( String e ) {
+		throw APIerror(e);
+	}
+
+	// command
+	list<String> serv_names, set_names;
+	for (list<XMLObject>::const_iterator
+			iter = search_list.begin() ;
+			iter != search_list.end() ;
+			iter++)
+	{
+		if (iter->tag() == "service")
+			serv_names.push_back(iter->get_attr("name"));
+		else if (iter->tag() == "set")
+			set_names.push_back(iter->get_attr("name"));
+	}
+
+	list<Service> services;
+	list<ServiceSet> sets;
+	ServiceManager().query(serv_names, set_names, services, sets);
+
+	// response
+	list<XMLObject> result_list;
+	for (list<Service>::const_iterator
+			iter = services.begin() ;
+			iter != services.end() ;
+			iter++)
+	{
+		result_list.push_back(iter->xml(descr));
+	}
+
+	for (list<ServiceSet>::const_iterator
+			iter = sets.begin() ;
+			iter != sets.end() ;
+			iter++)
+	{
+		result_list.push_back(iter->xml(descr));
+	}
+
+	Variable var("result", result_list);
+
+	VarMap ret;
+	ret.insert(pair<String, Variable>(var.name(), var));
+	return ret;
 }
--- conga/ricci/modules/service/ServiceModule.h	2007/09/11 02:45:28	1.2
+++ conga/ricci/modules/service/ServiceModule.h	2007/09/11 13:53:19	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
--- conga/ricci/modules/service/main.cpp	2007/09/11 02:45:28	1.5
+++ conga/ricci/modules/service/main.cpp	2007/09/11 13:53:19	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
@@ -20,22 +20,20 @@
  * Author: Stanko Kupcevic <kupcevic redhat com>
  */
 
-
 #include "ServiceModule.h"
 
 #include <iostream>
+
 using namespace std;
 
 int
-main(int argc, char** argv)
+main(int argc, char **argv)
 {
-  try {
-    ServiceModule m;
-    return stdin_out_module_driver(m,
-				   argc,
-				   argv);
-  } catch (String e) {
-    cerr << e << endl;
-    return 1;
-  }
+	try {
+		ServiceModule m;
+		return stdin_out_module_driver(m, argc, argv);
+	} catch (String e) {
+		cerr << e << endl;
+		return 1;
+	}
 }


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