From 6a016df96574bf2643e384d551d0b4cf3ff2fc84 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Mon, 19 Jul 2010 16:40:38 +0200 Subject: [PATCH] cmdlib: Return new name from rename operations The new name is then displayed by the clients. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Manuel Franceschini <livewire@google.com> --- lib/cmdlib.py | 4 ++++ scripts/gnt-cluster | 22 +++++++++++++++------- scripts/gnt-instance | 5 ++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6d9386faf..8124d4b29 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2583,6 +2583,8 @@ class LURenameCluster(LogicalUnit): self.LogWarning("Could not re-enable the master role on" " the master, please restart manually: %s", msg) + return clustername + class LUSetClusterParams(LogicalUnit): """Change the parameters of the cluster. @@ -4965,6 +4967,8 @@ class LURenameInstance(LogicalUnit): finally: _ShutdownInstanceDisks(self, inst) + return inst.name + class LURemoveInstance(LogicalUnit): """Remove an instance. diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index d5c2c191c..f5ad94210 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -162,17 +162,25 @@ def RenameCluster(opts, args): @return: the desired exit code """ - name = args[0] + cl = GetClient() + + (cluster_name, ) = cl.QueryConfigValues(["cluster_name"]) + + new_name = args[0] if not opts.force: - usertext = ("This will rename the cluster to '%s'. If you are connected" - " over the network to the cluster name, the operation is very" - " dangerous as the IP address will be removed from the node" - " and the change may not go through. Continue?") % name + usertext = ("This will rename the cluster from '%s' to '%s'. If you are" + " connected over the network to the cluster name, the" + " operation is very dangerous as the IP address will be" + " removed from the node and the change may not go through." + " Continue?") % (cluster_name, new_name) if not AskUser(usertext): return 1 - op = opcodes.OpRenameCluster(name=name) - SubmitOpCode(op, opts=opts) + op = opcodes.OpRenameCluster(name=new_name) + result = SubmitOpCode(op, opts=opts, cl=cl) + + ToStdout("Cluster renamed from '%s' to '%s'", cluster_name, result) + return 0 diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 7d72dfd09..ec19602ca 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -636,7 +636,10 @@ def RenameInstance(opts, args): new_name=args[1], ip_check=opts.ip_check, name_check=opts.name_check) - SubmitOrSend(op, opts) + result = SubmitOrSend(op, opts) + + ToStdout("Instance '%s' renamed to '%s'", args[0], result) + return 0 -- GitLab