Commit 6a016df9 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Return new name from rename operations



The new name is then displayed by the clients.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarManuel Franceschini <livewire@google.com>
parent 3fe11ba3
...@@ -2583,6 +2583,8 @@ class LURenameCluster(LogicalUnit): ...@@ -2583,6 +2583,8 @@ class LURenameCluster(LogicalUnit):
self.LogWarning("Could not re-enable the master role on" self.LogWarning("Could not re-enable the master role on"
" the master, please restart manually: %s", msg) " the master, please restart manually: %s", msg)
return clustername
class LUSetClusterParams(LogicalUnit): class LUSetClusterParams(LogicalUnit):
"""Change the parameters of the cluster. """Change the parameters of the cluster.
...@@ -4965,6 +4967,8 @@ class LURenameInstance(LogicalUnit): ...@@ -4965,6 +4967,8 @@ class LURenameInstance(LogicalUnit):
finally: finally:
_ShutdownInstanceDisks(self, inst) _ShutdownInstanceDisks(self, inst)
return inst.name
class LURemoveInstance(LogicalUnit): class LURemoveInstance(LogicalUnit):
"""Remove an instance. """Remove an instance.
......
...@@ -162,17 +162,25 @@ def RenameCluster(opts, args): ...@@ -162,17 +162,25 @@ def RenameCluster(opts, args):
@return: the desired exit code @return: the desired exit code
""" """
name = args[0] cl = GetClient()
(cluster_name, ) = cl.QueryConfigValues(["cluster_name"])
new_name = args[0]
if not opts.force: if not opts.force:
usertext = ("This will rename the cluster to '%s'. If you are connected" usertext = ("This will rename the cluster from '%s' to '%s'. If you are"
" over the network to the cluster name, the operation is very" " connected over the network to the cluster name, the"
" dangerous as the IP address will be removed from the node" " operation is very dangerous as the IP address will be"
" and the change may not go through. Continue?") % name " removed from the node and the change may not go through."
" Continue?") % (cluster_name, new_name)
if not AskUser(usertext): if not AskUser(usertext):
return 1 return 1
op = opcodes.OpRenameCluster(name=name) op = opcodes.OpRenameCluster(name=new_name)
SubmitOpCode(op, opts=opts) result = SubmitOpCode(op, opts=opts, cl=cl)
ToStdout("Cluster renamed from '%s' to '%s'", cluster_name, result)
return 0 return 0
......
...@@ -636,7 +636,10 @@ def RenameInstance(opts, args): ...@@ -636,7 +636,10 @@ def RenameInstance(opts, args):
new_name=args[1], new_name=args[1],
ip_check=opts.ip_check, ip_check=opts.ip_check,
name_check=opts.name_check) name_check=opts.name_check)
SubmitOrSend(op, opts) result = SubmitOrSend(op, opts)
ToStdout("Instance '%s' renamed to '%s'", args[0], result)
return 0 return 0
......
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