Fix a few commands behaviour with dry-run
authorIustin Pop <iustin@google.com>
Thu, 19 Aug 2010 13:51:00 +0000 (15:51 +0200)
committerIustin Pop <iustin@google.com>
Thu, 19 Aug 2010 15:48:24 +0000 (17:48 +0200)
These commands use or display the result from the LU, so in case of
dry-run, they will crash or display just 'None'. At least checking that
the result is 'true' (in the boolean sense) will make them work better.

As for gnt-os modify, it didn't pass the 'opts' parameter properly to
SubmitOpCode, so the dry-run option was silently ignored.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

scripts/gnt-cluster
scripts/gnt-instance
scripts/gnt-node
scripts/gnt-os

index efd49ea..66afdc7 100755 (executable)
@@ -179,7 +179,8 @@ def RenameCluster(opts, args):
   op = opcodes.OpRenameCluster(name=new_name)
   result = SubmitOpCode(op, opts=opts, cl=cl)
 
-  ToStdout("Cluster renamed from '%s' to '%s'", cluster_name, result)
+  if result:
+    ToStdout("Cluster renamed from '%s' to '%s'", cluster_name, result)
 
   return 0
 
index 75ecd63..cd3dc20 100755 (executable)
@@ -639,7 +639,8 @@ def RenameInstance(opts, args):
                                 name_check=opts.name_check)
   result = SubmitOrSend(op, opts)
 
-  ToStdout("Instance '%s' renamed to '%s'", args[0], result)
+  if result:
+    ToStdout("Instance '%s' renamed to '%s'", args[0], result)
 
   return 0
 
index b3d911f..f8048af 100755 (executable)
@@ -449,7 +449,8 @@ def PowercycleNode(opts, args):
 
   op = opcodes.OpPowercycleNode(node_name=node, force=opts.force)
   result = SubmitOpCode(op, opts=opts)
-  ToStderr(result)
+  if result:
+    ToStderr(result)
   return 0
 
 
index fd96cbe..ff3e4cf 100755 (executable)
@@ -254,7 +254,7 @@ def ModifyOS(opts, args):
                                   candidate_pool_size=None,
                                   os_hvp=os_hvp,
                                   osparams=osp)
-  SubmitOpCode(op)
+  SubmitOpCode(op, opts=opts)
 
   return 0