All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci docs/cluster_api.html modules/clus ...
Date: 9 Mar 2007 22:49:39 -0000	[thread overview]
Message-ID: <20070309224939.3847.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	rmccabe at sourceware.org	2007-03-09 22:49:37

Modified files:
	ricci/docs     : cluster_api.html 
	ricci/modules/cluster: ClusterModule.cpp Clusvcadm.cpp 
	                       Clusvcadm.h 

Log message:
	- Fix virt service disable and relocate.
	- Add a "migrate" ricci call to allow for the bifurcation of relocation and live migration for virt services.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/docs/cluster_api.html.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.1&r2=1.4.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.1&r2=1.5.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Clusvcadm.cpp.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7.2.2&r2=1.7.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/Clusvcadm.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2&r2=1.2.2.1

--- conga/ricci/docs/cluster_api.html	2007/03/01 00:31:19	1.4.2.1
+++ conga/ricci/docs/cluster_api.html	2007/03/09 22:49:36	1.4.2.2
@@ -75,15 +75,27 @@
 		<P>Start service ???servicename???. If ???nodename??? is specified,
 		service is started on that node, otherwise it will be started on a
 		node chosen by service manager. <BR>If service was not running, it
-		is started. If it was running, it is migrated to ???nodename???. 
+		is started. If it was running, it is relocated to ???nodename???. 
 		</P>
 		<P>Input variables:<BR>- ???servicename??? (string) ??? name of
 		service to manipulate<BR>- ???nodename??? (string) ??? optional
-		name of node for service to start on/ migrate to</P>
+		name of node for service to start on / relocate to</P>
 		<P>No output variables.</P>
 		<P>On failure:<BR>- 1 ??? service manager is not running on this
 		managed system<BR>- generic ones</P>
 	</UL>
+	<LI><P>migrate_service</P>
+	<UL>
+		<P>Migrate the virtual service ???servicename??? to cluster node ???nodename.??? The virtual service ???servicename??? must be running, and xend must be running and configured to allow live migration on both nodes.
+		</P>
+		<P>Input variables:<BR>- ???servicename??? (string) ??? name of
+		the virtual service to migrate.<BR>- ???nodename??? (string) ??? 
+		name of node to which the virtual service is to be migrated.</P>
+		<P>No output variables.</P>
+		<P>On failure:<BR>- 1 ??? service manager is not running on this
+		managed system<BR>- generic ones</P>
+	</UL>
+
 	<LI><P>stop_service</P>
 	<UL>
 		<P>Stop service ???servicename???. It is not an error to stop
--- conga/ricci/modules/cluster/ClusterModule.cpp	2006/11/20 23:15:03	1.5.2.1
+++ conga/ricci/modules/cluster/ClusterModule.cpp	2007/03/09 22:49:37	1.5.2.2
@@ -36,6 +36,7 @@
 static VarMap set_cluster_conf(const VarMap& args);
 static VarMap cluster_status(const VarMap& args);
 static VarMap service_start(const VarMap& args);
+static VarMap service_migrate(const VarMap& args);
 static VarMap service_stop(const VarMap& args);
 static VarMap service_restart(const VarMap& args);
 static VarMap fence_node(const VarMap& args);
@@ -66,6 +67,7 @@
   api_1_0["start_service"]                        = service_start;
   api_1_0["stop_service"]                         = service_stop;
   api_1_0["restart_service"]                      = service_restart;
+  api_1_0["migrate_service"]                      = service_migrate;
   
   api_1_0["start_node"]                           = start_node;
   api_1_0["stop_node"]                            = stop_node;
@@ -168,6 +170,29 @@
 }
 
 VarMap 
+service_migrate(const VarMap& args)
+{
+  String service_name, node_name;
+  try {
+    VarMap::const_iterator iter = args.find("servicename");
+    if (iter == args.end())
+      throw APIerror("missing servicename variable");
+    service_name = iter->second.get_string();
+    
+    iter = args.find("nodename");
+    if (iter != args.end())
+      node_name = iter->second.get_string();
+  } catch ( String e ) {
+    throw APIerror(e);
+  }
+  
+  Clusvcadm::migrate(service_name, node_name);
+  
+  VarMap ret;
+  return ret;
+}
+
+VarMap 
 service_restart(const VarMap& args)
 {
   String name;
--- conga/ricci/modules/cluster/Clusvcadm.cpp	2007/03/08 06:05:08	1.7.2.2
+++ conga/ricci/modules/cluster/Clusvcadm.cpp	2007/03/09 22:49:37	1.7.2.3
@@ -72,7 +72,6 @@
 
 
 
-
 void 
 Clusvcadm::start(const String& servicename,
 		 const String& nodename)
@@ -80,7 +79,6 @@
   pair<list<String>, list<ServiceStatus> > info = service_states();
   list<String> nodes = info.first;
   list<ServiceStatus> services = info.second;
-  String svcname = servicename;
   
   // check if node can run services
   bool node_found = false;
@@ -106,19 +104,18 @@
 	flag = "-e";
       else if (iter->status == ServiceStatus::RG_STATE_STARTED ||
 	       iter->status == ServiceStatus::RG_STATE_STARTING) {
-	if (iter->vm) {
-	  flag = "-M";
-      svcname = "vm:" + servicename;
 	} else
 	  flag = "-r";
-      }
       
       if (flag.size()) {
 	String out, err;
 	int status;
 	vector<String> args;
 	args.push_back(flag);
-	args.push_back(svcname);
+	if (iter->vm)
+		args.push_back("vm:" + servicename);
+	else
+		args.push_back(servicename);
 	if (nodename.size()) {
 	  args.push_back("-m");
 	  args.push_back(nodename);
@@ -135,6 +132,64 @@
 }
 
 void 
+Clusvcadm::migrate(const String& servicename, const String& nodename)
+{
+  pair<list<String>, list<ServiceStatus> > info = service_states();
+  list<String> nodes = info.first;
+  list<ServiceStatus> services = info.second;
+  
+  // check if node can run services
+  bool node_found = false;
+  for (list<String>::const_iterator iter = nodes.begin();
+       iter != nodes.end();
+       iter++)
+    if (*iter == nodename)
+      node_found = true;
+  if (!node_found && nodename.size())
+    throw String("node unable to run services");
+  
+  // start
+  for (list<ServiceStatus>::const_iterator iter = services.begin();
+       iter != services.end();
+       iter++) {
+	if (!iter->vm)
+		continue;
+    if (iter->name == servicename) {
+      String flag;
+      if (iter->status == ServiceStatus::RG_STATE_STOPPED ||
+	  iter->status == ServiceStatus::RG_STATE_STOPPING ||
+	  iter->status == ServiceStatus::RG_STATE_FAILED ||
+	  iter->status == ServiceStatus::RG_STATE_ERROR ||
+	  iter->status == ServiceStatus::RG_STATE_DISABLED)
+	flag = "-e";
+      else if (iter->status == ServiceStatus::RG_STATE_STARTED ||
+	       iter->status == ServiceStatus::RG_STATE_STARTING) {
+	flag = "-M";
+      }
+      
+      if (flag.size()) {
+	String out, err;
+	int status;
+	vector<String> args;
+	args.push_back(flag);
+	args.push_back("vm:" + servicename);
+	if (nodename.size()) {
+	  args.push_back("-m");
+	  args.push_back(nodename);
+	}
+	if (utils::execute(CLUSVCADM_TOOL_PATH, args, out, err, status, false))
+	  throw command_not_found_error_msg(CLUSVCADM_TOOL_PATH);
+	if (status != 0)
+	  throw String("clusvcadm failed");
+      }
+      return;
+    }
+  }
+  
+  throw String("no such virtual service");
+}
+
+void 
 Clusvcadm::stop(const String& servicename)
 {
   pair<list<String>, list<ServiceStatus> > info = service_states();
@@ -151,7 +206,10 @@
 	int status;
 	vector<String> args;
 	args.push_back("-d");
-	args.push_back(servicename);
+	if (iter->vm)
+		args.push_back("vm:" + servicename);
+	else
+		args.push_back(servicename);
 	if (utils::execute(CLUSVCADM_TOOL_PATH, args, out, err, status, false))
 	  throw command_not_found_error_msg(CLUSVCADM_TOOL_PATH);
 	if (status != 0)
@@ -189,7 +247,10 @@
 	int status;
 	vector<String> args;
 	args.push_back(flag);
-	args.push_back(servicename);
+	if (iter->vm)
+		args.push_back("vm:" + servicename);
+	else
+		args.push_back(servicename);
 	if (utils::execute(CLUSVCADM_TOOL_PATH, args, out, err, status, false))
 	  throw command_not_found_error_msg(CLUSVCADM_TOOL_PATH);
 	if (status != 0)
--- conga/ricci/modules/cluster/Clusvcadm.h	2006/08/10 22:53:08	1.2
+++ conga/ricci/modules/cluster/Clusvcadm.h	2007/03/09 22:49:37	1.2.2.1
@@ -30,11 +30,10 @@
 class Clusvcadm
 {
  public:
-  static void start(const String& servicename,
-		    const String& nodename);
-  static void stop(const String& servicename);
+  static void start(const String& servicename, const String& nodename);
+  static void migrate(const String& servicename, const String& nodename);
   static void restart(const String& servicename);
-  
+  static void stop(const String& servicename);
 };
 
 



             reply	other threads:[~2007-03-09 22:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-09 22:49 rmccabe [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-03-10  5:01 [Cluster-devel] conga/ricci docs/cluster_api.html modules/clus rmccabe
2007-03-10  5:00 rmccabe
2007-03-10  4:57 rmccabe
2007-03-09 22:50 rmccabe
2007-03-09 22:48 rmccabe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070309224939.3847.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.