Re: [Pacemaker] [PATCH]Bug 2567 - crm resource migrate should support an optional role parameter

2011-04-24 Thread Holger Teutsch
On Mon, 2011-04-11 at 20:50 +0200, Andrew Beekhof wrote:
 why?
 CMD_ERR(Resource %s not moved:
  specifying --master is not supported for
 --move-from\n, rsc_id);
 
it did not look sensible to me but I can't recall the exact reasons 8-)
It's now implemented.
 also the legacy handling is a little off - do a make install and run
 tools/regression.sh and you'll see what i mean.

Remaining diffs seem to be not related to my changes.

 other than that the crm_resource part looks pretty good.
 can you add some regression testcases in tools/ too please?
 
Will add them once the code is in the repo.

Latest diffs are attached.

-holger

diff -r b4f456380f60 shell/modules/ui.py.in
--- a/shell/modules/ui.py.in	Thu Mar 17 09:41:25 2011 +0100
+++ b/shell/modules/ui.py.in	Sun Apr 24 16:18:59 2011 +0200
@@ -738,8 +738,9 @@
 rsc_status = crm_resource -W -r '%s'
 rsc_showxml = crm_resource -q -r '%s'
 rsc_setrole = crm_resource --meta -r '%s' -p target-role -v '%s'
-rsc_migrate = crm_resource -M -r '%s' %s
-rsc_unmigrate = crm_resource -U -r '%s'
+rsc_move_to = crm_resource --move-to -r '%s' %s
+rsc_move_from = crm_resource --move-from -r '%s' %s
+rsc_move_cleanup = crm_resource --move-cleanup -r '%s'
 rsc_cleanup = crm_resource -C -r '%s' -H '%s'
 rsc_cleanup_all = crm_resource -C -r '%s'
 rsc_param =  {
@@ -776,8 +777,12 @@
 self.cmd_table[demote] = (self.demote,(1,1),0)
 self.cmd_table[manage] = (self.manage,(1,1),0)
 self.cmd_table[unmanage] = (self.unmanage,(1,1),0)
+# the next two commands are deprecated
 self.cmd_table[migrate] = (self.migrate,(1,4),0)
 self.cmd_table[unmigrate] = (self.unmigrate,(1,1),0)
+self.cmd_table[move-to] = (self.move_to,(2,4),0)
+self.cmd_table[move-from] = (self.move_from,(1,4),0)
+self.cmd_table[move-cleanup] = (self.move_cleanup,(1,1),0)
 self.cmd_table[param] = (self.param,(3,4),1)
 self.cmd_table[meta] = (self.meta,(3,4),1)
 self.cmd_table[utilization] = (self.utilization,(3,4),1)
@@ -846,9 +851,67 @@
 if not is_name_sane(rsc):
 return False
 return set_deep_meta_attr(is-managed,false,rsc)
+def move_to(self,cmd,*args):
+usage: move-to rsc[:master] node [lifetime] [force]
+elem = args[0].split(':')
+rsc = elem[0]
+master = False
+if len(elem)  1:
+master = elem[1]
+if master != master:
+common_error(%s is invalid, specify 'master' % master)
+return False
+master = True
+if not is_name_sane(rsc):
+return False
+node = args[1]
+lifetime = None
+force = False
+if len(args) == 3:
+if args[2] == force:
+force = True
+else:
+lifetime = args[2]
+elif len(args) == 4:
+if args[2] == force:
+force = True
+lifetime = args[3]
+elif args[3] == force:
+force = True
+lifetime = args[2]
+else:
+syntax_err((cmd,force))
+return False
+
+opts = ''
+if node:
+opts = --node='%s' % node
+if lifetime:
+opts = %s --lifetime='%s' % (opts,lifetime)
+if force or user_prefs.get_force():
+opts = %s --force % opts
+if master:
+opts = %s --master % opts
+return ext_cmd(self.rsc_move_to % (rsc,opts)) == 0
+
 def migrate(self,cmd,*args):
-usage: migrate rsc [node] [lifetime] [force]
-rsc = args[0]
+Deprecated: migrate rsc [node] [lifetime] [force]
+common_warning(migrate is deprecated, use move-to or move-from)
+if len(args) = 2 and args[1] in listnodes():
+return self.move_to(cmd, *args)
+return self.move_from(cmd, *args)
+
+def move_from(self,cmd,*args):
+usage: move-from rsc[:master] [node] [lifetime] [force]
+elem = args[0].split(':')
+rsc = elem[0]
+master = False
+if len(elem)  1:
+master = elem[1]
+if master != master:
+common_error(%s is invalid, specify 'master' % master)
+return False
+master = True
 if not is_name_sane(rsc):
 return False
 node = None
@@ -888,12 +951,18 @@
 opts = %s --lifetime='%s' % (opts,lifetime)
 if force or user_prefs.get_force():
 opts = %s --force % opts
-return ext_cmd(self.rsc_migrate % (rsc,opts)) == 0
-def unmigrate(self,cmd,rsc):
-usage: unmigrate rsc
+if master:
+opts = %s --master % opts
+return ext_cmd(self.rsc_move_from % (rsc,opts)) == 0
+def move_cleanup(self,cmd,rsc):
+usage: move_cleanup rsc
 if not is_name_sane(rsc):
 

Re: [Pacemaker] [pacemaker]Notification alerts when fail-over take place from one node to other node in cluster.

2011-04-24 Thread Rakesh K
Vadym Chepkov vchepkov@... writes:


 You can colocate your resource with a MailTo pseudo resource :
 
 # crm ra meta MailTo
 Notifies recipients by email in the event of resource takeover
(ocf:heartbeat:MailTo)
 
 Vadym
 
 ___
 Pacemaker mailing list: Pacemaker@...
 http://oss.clusterlabs.org/mailman/listinfo/pacemaker
 
 Project Home: http://www.clusterlabs.org
 Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
 Bugs: 
 http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker
 
 

Hi Vadym 

thanks for providing the reply. You said ti co-locate the resource with the
MailTo resource which will notify the recipients by email provided in the
configuration. But I had configured 4 resources in two node cluster. for this
case what would be the best approach ..

Regards
Rakesh



___
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker