Commit 51c6e7b5 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add --print parameter to “gnt-instance console”

This enables us to run automated tests on “gnt-instance console”, at least
to some degree.

Reviewed-by: iustinp
parent 0a80a26f
......@@ -797,12 +797,14 @@
<title>CONSOLE</title>
<cmdsynopsis>
<command>console</command>
<arg choice="opt">--show-cmd</arg>
<arg choice="req"><replaceable>instance</replaceable></arg>
</cmdsynopsis>
<para>
Connects to the console of the given instance. If the instance
is not up, an error is returned.
is not up, an error is returned. Use the <option>--show-cmd</option>
option to display the command instead of executing it.
</para>
<para>
......
......@@ -506,14 +506,18 @@ def ConnectToInstanceConsole(opts, args):
op = opcodes.OpConnectConsole(instance_name=instance_name)
cmd = SubmitOpCode(op)
# drop lock and exec so other commands can run while we have console
utils.Unlock("cmd")
try:
os.execvp(cmd[0], cmd)
finally:
sys.stderr.write("Can't run console command %s with arguments:\n'%s'" %
(cmd, " ".join(argv)))
os._exit(1)
if opts.show_command:
print utils.ShellQuoteArgs(cmd)
else:
# drop lock and exec so other commands can run while we have console
utils.Unlock("cmd")
try:
os.execvp(cmd[0], cmd)
finally:
sys.stderr.write("Can't run console command %s with arguments:\n'%s'" %
(cmd, " ".join(argv)))
os._exit(1)
def _FormatBlockDevInfo(buf, dev, indent_level):
......@@ -762,8 +766,12 @@ commands = {
'add': (AddInstance, ARGS_ONE, add_opts,
"[opts...] <name>",
"Creates and adds a new instance to the cluster"),
'console': (ConnectToInstanceConsole, ARGS_ONE, [DEBUG_OPT],
"<instance>",
'console': (ConnectToInstanceConsole, ARGS_ONE,
[DEBUG_OPT,
make_option("--show-cmd", dest="show_command",
action="store_true", default=False,
help=("Show command instead of executing it"))],
"[--show-cmd] <instance>",
"Opens a console on the specified instance"),
'failover': (FailoverInstance, ARGS_ONE,
[DEBUG_OPT, FORCE_OPT,
......
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