conga/ricci docs/service_api.html modules/serv ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2007-02-23 22:02:59
Modified files:
ricci/docs : service_api.html
ricci/modules/service: ServiceManager.cpp ServiceManager.h
ServiceModule.cpp
Added files:
ricci/test_suite/service: restart.xml
Log message:
- Add a restart function to the service module
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/docs/service_api.html.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.cpp.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.h.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceModule.cpp.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/test_suite/service/restart.xml.diff?cvsroot=cluster&r1=NONE&r2=1.1
ricci/docs/service_api.html +12 -0
@@ -117,6 +117,18 @@ generic ones might get returned. </P> </UL> + <LI><P>restart</P> + <UL> + <P ALIGN=LEFT>Restart services/sets.</P> + <P>Input variables: <BR>- ???services??? (list_xml) ??? list of + services/sets to restart. For format see ???query???. + </P> + <P>No output variables. + </P> + <P ALIGN=LEFT>On failure: <BR>- No special errors defined, only + generic ones might get returned. + </P> + </UL> <LI><P>stop</P> <UL> <P ALIGN=LEFT>Stop services/sets. It is not error to stop already
ricci/modules/service/ServiceManager.cpp +63 -11
116 lines not on this page · raw message
ricci/modules/service/ServiceManager.h +9 -1
@@ -34,6 +34,11 @@class ServiceManager; +enum { +SERVICE_STOP , +SERVICE_START , +SERVICE_RESTART +};class Service {
@@ -48,6 +53,7 @@void enable ();void disable (); +void restart ();void start ();void stop ();
@@ -63,7 +69,7 @@ static void enable_service(const String& name, bool on); static bool service_running(const String& name); - static void run_service(const String& name, bool on); + static void run_service(const String& name, int state); friend class ServiceManager;
@@ -84,6 +90,7 @@void enable ();void disable ();void start (); +void restart ();void stop (); std::list<Service> servs;
@@ -107,6 +114,7 @@ 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,
ricci/modules/service/ServiceModule.cpp +30 -0
@@ -31,6 +31,7 @@ static VarMap enable(const VarMap& args); static VarMap disable(const VarMap& args); static VarMap start(const VarMap& args); +static VarMap restart(const VarMap& args); static VarMap stop(const VarMap& args); static VarMap lists(const VarMap& args); static VarMap query(const VarMap& args);
@@ -53,6 +54,7 @@ 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;
@@ -149,6 +151,34 @@ } 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")); + } + + ServiceManager().restart(services, sets); + + return VarMap(); +} + +VarMap stop(const VarMap& args) { list<XMLObject> serv_list;
/cvs/cluster/conga/ricci/test_suite/service/restart.xml,v --> standard output revision 1.1
- renamed from ricci/test_suite/service/restart.xml +16 -0
@@ -0,0 +1,16 @@ +<?xml version="1.0" ?> +<ricci version="1.0" function="process_batch" async="false"> +<batch> + +<module name="service"> +<request sequence="1254" API_version="1.0"> +<function_call name="restart"> + <var mutable="false" name="services" type="list_xml"> + <service name="httpd"/> + </var> +</function_call> +</request> +</module> + +</batch> +</ricci>