Commit d6f46b6a authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

gnt-instance console: Use query instead of opcode



This means opening the console no longer requires the instance lock,
allowing it to be used during long-running operations (e.g. replacing a
disk).
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent dbfde874
...@@ -889,18 +889,26 @@ def ConnectToInstanceConsole(opts, args): ...@@ -889,18 +889,26 @@ def ConnectToInstanceConsole(opts, args):
""" """
instance_name = args[0] instance_name = args[0]
op = opcodes.OpInstanceConsole(instance_name=instance_name)
cl = GetClient() cl = GetClient()
try: try:
cluster_name = cl.QueryConfigValues(["cluster_name"])[0] cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
console_data = SubmitOpCode(op, opts=opts, cl=cl) ((console_data, oper_state), ) = \
cl.QueryInstances([instance_name], ["console", "oper_state"], False)
finally: finally:
# Ensure client connection is closed while external commands are run # Ensure client connection is closed while external commands are run
cl.Close() cl.Close()
del cl del cl
if not console_data:
if oper_state:
# Instance is running
raise errors.OpExecError("Console information for instance %s is"
" unavailable" % instance_name)
else:
raise errors.OpExecError("Instance %s is not running, can't get console" %
instance_name)
return _DoConsole(objects.InstanceConsole.FromDict(console_data), return _DoConsole(objects.InstanceConsole.FromDict(console_data),
opts.show_command, cluster_name) opts.show_command, cluster_name)
......
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