[Pacemaker] [Patch] Optional and message change of the "crm migrate" command.

renayama19661014 at ybb.ne.jp renayama19661014 at ybb.ne.jp
Wed Jun 15 23:49:17 UTC 2011


Hi Dejan,

Thank you for a reply.

> Many thanks for the patch. But we need a common procedure to
> fetch and remove options which are used in many commands from
> the list of arguments. Options such as "force" and "quiet".
> Right now I'm quite busy elsewhere, so that may take time ...

All right.

I think about the patch which I can commonize more.

Best Regards,
Hideo Yamauchi.



--- On Thu, 2011/6/16, Dejan Muhamedagic <dejanmm at fastmail.fm> wrote:

> Hi Hideo-san,
> 
> On Wed, Jun 15, 2011 at 02:47:09PM +0900, renayama19661014 at ybb.ne.jp wrote:
> > Hi all,
> > 
> > There is the message which does not comply with real operation by the message of the crm command.
> > 
> > When an operator executes "migrate" command, crm should display "unmigrate" in a message.
> > In addition, the crm command does not have the option corresponding to the Q option of the crm_resource command.
> > 
> > (snip)
> > crm(live)resource# move 
> > usage: migrate <rsc> [<node>] [<lifetime>] [force]
> > crm(live)resource# move grpDummy srv01 P3S force
> > Migration will take effect until: 2011-06-15 13:47:39Z
> > WARNING: Creating rsc_location constraint 'cli-standby-grpDummy' with a score of -INFINITY for resource grpDummy on srv02.
> >         This will prevent grpDummy from running on srv02 until the constraint is removed using the 'crm_resource -U' command or manually with cibadmin
> >         This will be the case even if srv02 is the last node in the cluster
> >         This message can be disabled with -Q
> > (snip)
> > 
> > I contribute a patch to add message and Q option to.(quiet option)
> > 
> > 
> > (snip)
> > crm(live)resource# migrate
> > usage: migrate <rsc> [<node>] [<lifetime>] [force] [quiet]
> > crm(live)resource# migrate grpDummy srv02 P3S force quiet
> > crm(live)resource# unmigrate grpDummy
> > crm(live)resource# migrate grpDummy srv01 P3S force
> > WARNING: Creating rsc_location constraint 'cli-standby-grpDummy' with a score of -INFINITY for resource grpDummy on srv02.
> >         This will prevent grpDummy from running on srv02 until the constraint is removed using the 'crm resource unmigrate' command or manually with cibadmin
> >         This will be the case even if srv02 is the last node in the cluster
> >         This message can be disabled with quiet
> > 
> > crm(live)resource# move grpDummy srv02 P3S force 
> > WARNING: Creating rsc_location constraint 'cli-standby-grpDummy' with a score of -INFINITY for resource grpDummy on srv02.
> >         This will prevent grpDummy from running on srv02 until the constraint is removed using the 'crm resource unmove' command or manually with cibadmin
> >         This will be the case even if srv02 is the last node in the cluster
> >         This message can be disabled with quiet
> > (snip)
> > 
> > I am going to contribute the patch functionalizing Q option to other crm commands later.
> > 
> > I do not yet revise crm_cli.txt.
> > I intend to send it with the patch of other Q options.
> 
> Many thanks for the patch. But we need a common procedure to
> fetch and remove options which are used in many commands from
> the list of arguments. Options such as "force" and "quiet".
> Right now I'm quite busy elsewhere, so that may take time ...
> 
> Cheers,
> 
> Dejan
> 
> > Best Regards,
> > Hideo Yamauchi.
> 
> > diff -r c3ac0f617f6a ui.py.in
> > --- a/ui.py.in    Wed Jun 15 23:35:31 2011 +0900
> > +++ b/ui.py.in    Wed Jun 15 23:39:41 2011 +0900
> > @@ -759,7 +759,7 @@
> >          self.cmd_table["demote"] = (self.demote,(1,1),0,(rsc_list,))
> >          self.cmd_table["manage"] = (self.manage,(1,1),0,(rsc_list,))
> >          self.cmd_table["unmanage"] = (self.unmanage,(1,1),0,(rsc_list,))
> > -        self.cmd_table["migrate"] = (self.migrate,(1,4),0,(rsc_list,nodes_list))
> > +        self.cmd_table["migrate"] = (self.migrate,(1,5),0,(rsc_list,nodes_list))
> >          self.cmd_table["unmigrate"] = (self.unmigrate,(1,1),0,(rsc_list,))
> >          self.cmd_table["param"] = (self.param,(3,4),1,(rsc_list,attr_cmds))
> >          self.cmd_table["meta"] = (self.meta,(3,4),1,(rsc_list,attr_cmds))
> > @@ -829,32 +829,43 @@
> >              return False
> >          return set_deep_meta_attr("is-managed","false",rsc)
> >      def migrate(self,cmd,*args):
> > -        """usage: migrate <rsc> [<node>] [<lifetime>] [force]"""
> > +        """usage: migrate <rsc> [<node>] [<lifetime>] [force] [quiet]"""
> >          rsc = args[0]
> >          if not is_name_sane(rsc):
> >              return False
> >          node = None
> >          lifetime = None
> >          force = False
> > +        quiet = None
> >          if len(args) == 2:
> >              if not args[1] in listnodes():
> >                  if args[1] == "force":
> >                      force = True
> > +                elif args[1] == "quiet":
> > +                    quiet = args[1]
> >                  else:
> >                      lifetime = args[1]
> >              else:
> >                  node = args[1]
> > -        elif len(args) == 3:
> > +        elif len(args) == 3 or len(args) == 4:
> >              if not args[1] in listnodes():
> > -                lifetime = args[1]
> > -                force = True
> > +                for i in range(1, len(args)):
> > +                    if args[i] == "force":
> > +                        force = True
> > +                    elif args[i] == "quiet":
> > +                        quiet = args[i]
> > +                    else:
> > +                        lifetime = args[i]
> >              else:
> >                  node = args[1]
> > -                if args[2] == "force":
> > -                    force = True
> > -                else:
> > -                    lifetime = args[2]
> > -        elif len(args) == 4:
> > +                for i in range(2, len(args)):
> > +                    if args[i] == "force":
> > +                        force = True
> > +                    elif args[i] == "quiet":
> > +                        quiet = args[i]
> > +                    else:
> > +                        lifetime = args[i]
> > +        elif len(args) == 5:
> >              if not is_name_sane(args[1]):
> >                  return False
> >              node = args[1]
> > @@ -863,6 +874,10 @@
> >                  syntax_err((cmd,force))
> >                  return False
> >              force = True
> > +            if not args[4] == "quiet":
> > +                syntax_err((cmd,quiet))
> > +                return False
> > +        quiet = args[4]
> >          opts = ''
> >          if node:
> >              opts = "--node='%s'" % node
> > @@ -870,7 +885,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
> > +        if quiet:
> > +            opts = "%s -Q" % opts
> > +        so, se, rc = get_allout(add_sudo(self.rsc_migrate % (rsc,opts)))
> > +        re.search("crm_resource -U", se)
> > +        if re:
> > +            if cmd == "migrate":
> > +                se = re.sub("crm_resource -U", "crm resource unmigrate", se)    
> > +            else:
> > +                se = re.sub("crm_resource -U", "crm resource unmove", se)    
> > +            se = re.sub("with -Q", "with quiet", se)    
> > +            page_string(se)
> > +        return rc == 0
> >      def unmigrate(self,cmd,rsc):
> >          "usage: unmigrate <rsc>"
> >          if not is_name_sane(rsc):
> > diff -r c3ac0f617f6a utils.py
> > --- a/utils.py    Wed Jun 15 23:35:31 2011 +0900
> > +++ b/utils.py    Wed Jun 15 23:39:41 2011 +0900
> > @@ -176,6 +176,19 @@
> >          print ".EXT", cmd
> >      return subprocess.call(add_sudo(cmd), shell=True)
>> > +def get_allout(cmd):
> > +    '''
> > +    Run a cmd, return stdout, stderr, returncode output.
> > +    '''
> > +    proc = subprocess.Popen(cmd, shell = True, \
> > +        stdout = subprocess.PIPE, stderr = subprocess.PIPE)
> > +    stdout_value, stderr_value = proc.communicate()
> > +    proc.wait()
> > +    rc = proc.returncode
> > +    stdout_value = stdout_value.strip()
> > +    stderr_value = stderr_value.strip()
> > +    return stdout_value, stderr_value, rc
> > +
> >  def get_stdout(cmd, stderr_on = True):
> >      '''
> >      Run a cmd, return stdin output.
> 
> > _______________________________________________
> > Pacemaker mailing list: Pacemaker at 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
> 
> 




More information about the Pacemaker mailing list