openNodeShell opens an SSH session to the currently selected node.
()
| 16 | |
| 17 | // openNodeShell opens an SSH session to the currently selected node. |
| 18 | func (a *App) openNodeShell() { |
| 19 | node := a.nodeList.GetSelectedNode() |
| 20 | if node == nil || node.IP == "" { |
| 21 | a.showMessageSafe("Node IP address not available") |
| 22 | return |
| 23 | } |
| 24 | |
| 25 | // Log node IP details for debugging |
| 26 | shellLogger.Debug("Node shell for %s: IP from node object: '%s' (len=%d, bytes=%v)", |
| 27 | node.Name, node.IP, len(node.IP), []byte(node.IP)) |
| 28 | |
| 29 | sshSettings := a.config.ResolveSSHSettings(node.SourceProfile) |
| 30 | sshUser := sshSettings.SSHUser |
| 31 | jumpHost := sshSettings.SSHJumpHost |
| 32 | |
| 33 | if sshUser == "" { |
| 34 | a.showMessageSafe("SSH user not configured. Please set PROXMOX_SSH_USER environment variable or use --ssh-user flag.") |
| 35 | return |
| 36 | } |
| 37 | |
| 38 | // Temporarily suspend the UI |
| 39 | a.Suspend(func() { |
| 40 | // Display connecting message |
| 41 | fmt.Printf("\nConnecting to node %s (%s) as user %s...\n", node.Name, node.IP, sshUser) |
| 42 | |
| 43 | // Execute SSH command |
| 44 | err := ssh.ExecuteNodeShell(sshUser, node.IP, jumpHost) |
| 45 | if err != nil { |
| 46 | fmt.Printf("\nError connecting to node: %v\n", err) |
| 47 | } |
| 48 | // Wait for user to press Enter |
| 49 | // fmt.Print("\nPress Vj`Enter to return to the TUI...") |
| 50 | // utils.WaitForEnter() |
| 51 | }) |
| 52 | |
| 53 | // Fix for tview suspend/resume issue - comprehensive terminal state restoration |
| 54 | a.Sync() |
| 55 | } |
| 56 | |
| 57 | // handleVNCOutcome centralizes UI handling for VNC connection results to avoid duplicated code. |
| 58 | func (a *App) handleVNCOutcome(kind string, name string, vncURL string, err error) { |
no test coverage detected