From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 9 Mar 2007 22:49:39 -0000 Subject: [Cluster-devel] conga/ricci docs/cluster_api.html modules/clus ... Message-ID: <20070309224939.3847.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 @@

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.
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???.

Input variables:
- ???servicename??? (string) ??? name of service to manipulate
- ???nodename??? (string) ??? optional - name of node for service to start on/ migrate to

+ name of node for service to start on / relocate to

No output variables.

On failure:
- 1 ??? service manager is not running on this managed system
- generic ones

+
  • migrate_service

    +
      +

      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. +

      +

      Input variables:
      - ???servicename??? (string) ??? name of + the virtual service to migrate.
      - ???nodename??? (string) ??? + name of node to which the virtual service is to be migrated.

      +

      No output variables.

      +

      On failure:
      - 1 ??? service manager is not running on this + managed system
      - generic ones

      +
    +
  • stop_service

      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 > info = service_states(); list nodes = info.first; list 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 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 > info = service_states(); + list nodes = info.first; + list services = info.second; + + // check if node can run services + bool node_found = false; + for (list::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::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 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 > info = service_states(); @@ -151,7 +206,10 @@ int status; vector 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 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); };