Skip to contentSkip to conversation

conga/ricci docs/service_api.html modules/serv ...

Cluster-devel [email protected] 1 participant 1 message Feb 28, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Branch: RHEL4
Changes by: kupcevic at sourceware.org 2007-02-28 23:21:40

Modified files:
ricci/docs : service_api.html
ricci/modules/service: ServiceManager.cpp ServiceManager.h
ServiceModule.cpp

Log message:
add restart fcn to modservice

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/docs/service_api.html.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.4.1&r2=1.1.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.cpp.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.7.2.2&r2=1.7.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceManager.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.2&r2=1.2.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/service/ServiceModule.cpp.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3&r2=1.3.4.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 +66 -10

119 lines not on this page · raw message

ricci/modules/service/ServiceManager.h +10 -1
@@ -48,6 +48,7 @@
   
   void enable();
   void disable();
+  void restart();
   void start();
   void stop();
   
@@ -61,9 +62,15 @@
   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, bool on);
+  static void run_service(const String& name, ActionState state);
   
   friend class ServiceManager;
 
@@ -84,6 +91,7 @@
   void enable();
   void disable();
   void start();
+  void restart();
   void stop();
   
   std::list<Service> servs;
@@ -107,6 +115,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;