Revision 55cc0a44 lib/hypervisor/hv_kvm.py

b/lib/hypervisor/hv_kvm.py
1035 1035
    return self.GetLinuxNodeInfo()
1036 1036

  
1037 1037
  @classmethod
1038
  def GetShellCommandForConsole(cls, instance, hvparams, beparams):
1038
  def GetInstanceConsole(cls, instance, hvparams, beparams):
1039 1039
    """Return a command for connecting to the console of an instance.
1040 1040

  
1041 1041
    """
1042 1042
    if hvparams[constants.HV_SERIAL_CONSOLE]:
1043
      shell_command = ("%s STDIO,%s UNIX-CONNECT:%s" %
1044
                       (constants.SOCAT_PATH, cls._SocatUnixConsoleParams(),
1045
                        utils.ShellQuote(cls._InstanceSerial(instance.name))))
1046
    else:
1047
      shell_command = "echo 'No serial shell for instance %s'" % instance.name
1043
      cmd = [constants.SOCAT_PATH,
1044
             "STDIO,%s" % cls._SocatUnixConsoleParams(),
1045
             "UNIX-CONNECT:%s" % cls._InstanceSerial(instance.name)]
1046
      return objects.InstanceConsole(instance=instance.name,
1047
                                     kind=constants.CONS_SSH,
1048
                                     host=instance.primary_node,
1049
                                     user=constants.GANETI_RUNAS,
1050
                                     command=cmd)
1048 1051

  
1049 1052
    vnc_bind_address = hvparams[constants.HV_VNC_BIND_ADDRESS]
1050
    if vnc_bind_address:
1051
      if instance.network_port > constants.VNC_BASE_PORT:
1052
        display = instance.network_port - constants.VNC_BASE_PORT
1053
        vnc_command = ("echo 'Instance has VNC listening on %s:%d"
1054
                       " (display: %d)'" % (vnc_bind_address,
1055
                                            instance.network_port,
1056
                                            display))
1057
        shell_command = "%s; %s" % (vnc_command, shell_command)
1058

  
1059
    return shell_command
1053
    if vnc_bind_address and instance.network_port > constants.VNC_BASE_PORT:
1054
      display = instance.network_port - constants.VNC_BASE_PORT
1055
      return objects.InstanceConsole(instance=instance.name,
1056
                                     kind=constants.CONS_VNC,
1057
                                     host=vnc_bind_address,
1058
                                     port=instance.network_port,
1059
                                     display=display)
1060

  
1061
    return objects.InstanceConsole(instance=instance.name,
1062
                                   kind=constants.CONS_MESSAGE,
1063
                                   message=("No serial shell for instance %s" %
1064
                                            instance.name))
1060 1065

  
1061 1066
  def Verify(self):
1062 1067
    """Verify the hypervisor.
......
1069 1074
    if not os.path.exists(constants.SOCAT_PATH):
1070 1075
      return "The socat binary ('%s') does not exist." % constants.SOCAT_PATH
1071 1076

  
1072

  
1073 1077
  @classmethod
1074 1078
  def CheckParameterSyntax(cls, hvparams):
1075 1079
    """Check the given parameters for validity.

Also available in: Unified diff