Пример #1
0
  @Override
  public void onPreviewSsh(@NotNull final String machineId) {
    ProcessTreeNode machineTreeNode = findProcessTreeNodeById(machineId);
    if (machineTreeNode == null) {
      return;
    }

    MachineDto machine = (MachineDto) machineTreeNode.getData();

    OutputConsole defaultConsole = commandConsoleFactory.create("SSH");
    addCommandOutput(machineId, defaultConsole);

    String machineName = machine.getConfig().getName();
    String sshServiceAddress = getSshServerAddress(machine);
    String machineHost = "";
    String sshPort = SSH_PORT;
    if (sshServiceAddress != null) {
      String[] parts = sshServiceAddress.split(":");
      machineHost = parts[0];
      sshPort = (parts.length == 2) ? parts[1] : sshPort;
    }

    if (defaultConsole instanceof DefaultOutputConsole) {
      ((DefaultOutputConsole) defaultConsole)
          .printText(localizationConstant.sshConnectInfo(machineName, machineHost, sshPort));
    }
  }