On Mon, Feb 14, 2011 at 5:37 PM, Michael Hanselmann <[email protected]> wrote:
> OpInstanceRename uses “instance_name” (like almost all other OpInstance*
> opcodes), not “old_name”, to specify the original name. OpGroupRename is
> made consistent by renaming “old_name” to “group_name”.
>
> Signed-off-by: Michael Hanselmann <[email protected]>
> ---
>  lib/client/gnt_group.py            |    8 ++++----
>  lib/cmdlib.py                      |    9 ++++-----
>  lib/opcodes.py                     |    5 ++---
>  lib/rapi/rlib2.py                  |    3 +--
>  test/ganeti.rapi.rlib2_unittest.py |    4 ++--
>  5 files changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py
> index 882bbcd..23d2550 100644
> --- a/lib/client/gnt_group.py
> +++ b/lib/client/gnt_group.py
> @@ -175,8 +175,8 @@ def RenameGroup(opts, args):
>   @return: the desired exit code
>
>   """
> -  old_name, new_name = args
> -  op = opcodes.OpGroupRename(old_name=old_name, new_name=new_name)
> +  group_name, new_name = args
> +  op = opcodes.OpGroupRename(group_name=group_name, new_name=new_name)
>   SubmitOpCode(op, opts=opts)
>
>
> @@ -203,11 +203,11 @@ commands = {
>     "<group_name>", "Alters the parameters of a node group"),
>   "remove": (
>     RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT],
> -    "[--dry-run] <group_name>",
> +    "[--dry-run] <group-name>",
>     "Remove an (empty) node group from the cluster"),
>   "rename": (
>     RenameGroup, [ArgGroup(min=2, max=2)], [DRY_RUN_OPT],
> -    "[--dry-run] <old_name> <new_name>", "Rename a node group"),
> +    "[--dry-run] <group-name> <new-name>", "Rename a node group"),
>  }
>
>
> diff --git a/lib/cmdlib.py b/lib/cmdlib.py
> index d6f6cad..4bddc78 100644
> --- a/lib/cmdlib.py
> +++ b/lib/cmdlib.py
> @@ -10413,7 +10413,7 @@ class LUGroupRename(LogicalUnit):
>
>   def ExpandNames(self):
>     # This raises errors.OpPrereqError on its own:
> -    self.group_uuid = self.cfg.LookupNodeGroup(self.op.old_name)
> +    self.group_uuid = self.cfg.LookupNodeGroup(self.op.group_name)
>
>     self.needed_locks = {
>       locking.LEVEL_NODEGROUP: [self.group_uuid],
> @@ -10422,8 +10422,7 @@ class LUGroupRename(LogicalUnit):
>   def CheckPrereq(self):
>     """Check prerequisites.
>
> -    This checks that the given old_name exists as a node group, and that
> -    new_name doesn't.
> +    Ensures requested new name is not yet used.
>
>     """
>     try:
> @@ -10441,7 +10440,7 @@ class LUGroupRename(LogicalUnit):
>
>     """
>     env = {
> -      "OLD_NAME": self.op.old_name,
> +      "OLD_NAME": self.op.group_name,
>       "NEW_NAME": self.op.new_name,
>       }
>
> @@ -10464,7 +10463,7 @@ class LUGroupRename(LogicalUnit):
>
>     if group is None:
>       raise errors.OpExecError("Could not retrieve group '%s' (UUID: %s)" %
> -                               (self.op.old_name, self.group_uuid))
> +                               (self.op.group_name, self.group_uuid))
>
>     group.name = self.op.new_name
>     self.cfg.Update(group, feedback_fn)
> diff --git a/lib/opcodes.py b/lib/opcodes.py
> index 5796e07..24f93df 100644
> --- a/lib/opcodes.py
> +++ b/lib/opcodes.py
> @@ -1180,10 +1180,9 @@ class OpGroupRemove(OpCode):
>
>  class OpGroupRename(OpCode):
>   """Rename a node group in the cluster."""
> -  OP_DSC_FIELD = "old_name"
>   OP_PARAMS = [
> -    ("old_name", ht.NoDefault, ht.TNonEmptyString, None),
> -    ("new_name", ht.NoDefault, ht.TNonEmptyString, None),
> +    _PGroupName,
> +    ("new_name", ht.NoDefault, ht.TNonEmptyString, "New group name"),
>     ]
>
>
> diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py
> index c5b8c00..2aaa774 100644
> --- a/lib/rapi/rlib2.py
> +++ b/lib/rapi/rlib2.py
> @@ -664,10 +664,9 @@ def _ParseRenameGroupRequest(name, data, dry_run):
>   @return: Node group rename opcode
>
>   """
> -  old_name = name
>   new_name = baserlib.CheckParameter(data, "new_name")
>
> -  return opcodes.OpGroupRename(old_name=old_name, new_name=new_name,
> +  return opcodes.OpGroupRename(group_name=name, new_name=new_name,
>                                dry_run=dry_run)
>
>
> diff --git a/test/ganeti.rapi.rlib2_unittest.py 
> b/test/ganeti.rapi.rlib2_unittest.py
> index ec97eac..52ee7f3 100755
> --- a/test/ganeti.rapi.rlib2_unittest.py
> +++ b/test/ganeti.rapi.rlib2_unittest.py
> @@ -460,7 +460,7 @@ class 
> TestParseRenameGroupRequest(testutils.GanetiTestCase):
>     op = self.Parse(name, data, False)
>
>     self.assert_(isinstance(op, opcodes.OpGroupRename))
> -    self.assertEqual(op.old_name, name)
> +    self.assertEqual(op.group_name, name)
>     self.assertEqual(op.new_name, "ua0aiyoo")
>     self.assertFalse(op.dry_run)
>
> @@ -473,7 +473,7 @@ class 
> TestParseRenameGroupRequest(testutils.GanetiTestCase):
>     op = self.Parse(name, data, True)
>
>     self.assert_(isinstance(op, opcodes.OpGroupRename))
> -    self.assertEqual(op.old_name, name)
> +    self.assertEqual(op.group_name, name)
>     self.assertEqual(op.new_name, "ua0aiyoo")
>     self.assert_(op.dry_run)
>
> --
> 1.7.3.5

LGTM

>
>

Reply via email to