gnt-instance console: Improve error reporting
authorMichael Hanselmann <hansmi@google.com>
Thu, 6 Jan 2011 15:38:31 +0000 (16:38 +0100)
committerMichael Hanselmann <hansmi@google.com>
Thu, 6 Jan 2011 16:52:22 +0000 (17:52 +0100)
If the SSH command fails, this will give a more detailed error
message than before.

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

lib/client/gnt_instance.py

index 431bc17..0bca839 100644 (file)
@@ -959,12 +959,12 @@ def ConnectToInstanceConsole(opts, args):
   if opts.show_command:
     ToStdout("%s", utils.ShellQuoteArgs(cmd))
   else:
-    try:
-      os.execvp(cmd[0], cmd)
-    finally:
-      ToStderr("Can't run console command %s with arguments:\n'%s'",
-               cmd[0], " ".join(cmd))
-      os._exit(1) # pylint: disable-msg=W0212
+    result = utils.RunCmd(cmd, interactive=True)
+    if result.failed:
+      raise errors.OpExecError("Console command \"%s\" failed: %s" %
+                               (utils.ShellQuoteArgs(cmd), result.fail_reason))
+
+  return constants.EXIT_SUCCESS
 
 
 def _FormatLogicalID(dev_type, logical_id, roman):