Commit 12da663a authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Make OpGroupRename consistent with OpInstanceRename



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: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 526a662a
......@@ -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"),
}
......
......@@ -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)
......
......@@ -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"),
]
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment