Revision d6f46b6a lib/client/gnt_instance.py

b/lib/client/gnt_instance.py
889 889
  """
890 890
  instance_name = args[0]
891 891

  
892
  op = opcodes.OpInstanceConsole(instance_name=instance_name)
893

  
894 892
  cl = GetClient()
895 893
  try:
896 894
    cluster_name = cl.QueryConfigValues(["cluster_name"])[0]
897
    console_data = SubmitOpCode(op, opts=opts, cl=cl)
895
    ((console_data, oper_state), ) = \
896
      cl.QueryInstances([instance_name], ["console", "oper_state"], False)
898 897
  finally:
899 898
    # Ensure client connection is closed while external commands are run
900 899
    cl.Close()
901 900

  
902 901
  del cl
903 902

  
903
  if not console_data:
904
    if oper_state:
905
      # Instance is running
906
      raise errors.OpExecError("Console information for instance %s is"
907
                               " unavailable" % instance_name)
908
    else:
909
      raise errors.OpExecError("Instance %s is not running, can't get console" %
910
                               instance_name)
911

  
904 912
  return _DoConsole(objects.InstanceConsole.FromDict(console_data),
905 913
                    opts.show_command, cluster_name)
906 914

  

Also available in: Unified diff