ConnectToNode opens a VNC shell connection to a node in the user's browser.
(nodeName string)
| 90 | |
| 91 | // ConnectToNode opens a VNC shell connection to a node in the user's browser. |
| 92 | func (s *Service) ConnectToNode(nodeName string) error { |
| 93 | s.logger.Info("Connecting to node VNC shell: %s", nodeName) |
| 94 | |
| 95 | // Generate the VNC shell URL |
| 96 | vncURL, err := s.client.GenerateNodeVNCURL(nodeName) |
| 97 | if err != nil { |
| 98 | s.logger.Error("Failed to generate VNC shell URL for node %s: %v", nodeName, err) |
| 99 | |
| 100 | return fmt.Errorf("failed to generate VNC shell URL: %w", err) |
| 101 | } |
| 102 | |
| 103 | s.logger.Debug("Generated VNC shell URL for node %s: %s", nodeName, vncURL) |
| 104 | |
| 105 | // Open the URL in the default browser |
| 106 | err = openBrowser(vncURL) |
| 107 | if err != nil { |
| 108 | s.logger.Error("Failed to open browser for node %s VNC shell: %v", nodeName, err) |
| 109 | |
| 110 | return err |
| 111 | } |
| 112 | |
| 113 | s.logger.Info("Successfully opened VNC shell connection for node %s", nodeName) |
| 114 | |
| 115 | return nil |
| 116 | } |
| 117 | |
| 118 | // openBrowser opens the specified URL in the user's default browser. |
| 119 | func openBrowser(url string) error { |
nothing calls this directly
no test coverage detected