openNodeVNC opens a VNC shell connection to the currently selected node.
()
| 173 | |
| 174 | // openNodeVNC opens a VNC shell connection to the currently selected node. |
| 175 | func (a *App) openNodeVNC() { |
| 176 | node := a.nodeList.GetSelectedNode() |
| 177 | if node == nil { |
| 178 | // Show error in modal dialog instead of header |
| 179 | errorModal := CreateErrorDialog("VNC Error", "No node selected", func() { |
| 180 | a.pages.RemovePage("vnc_error") |
| 181 | }) |
| 182 | a.pages.AddPage("vnc_error", errorModal, false, true) |
| 183 | |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | logger := models.GetUILogger() |
| 188 | logger.Debug("Opening VNC shell for node: %s", node.Name) |
| 189 | |
| 190 | // Use the shared VNC service instead of creating a new one |
| 191 | vncService := a.GetVNCService() |
| 192 | |
| 193 | // Get client for node |
| 194 | client, err := a.getClientForNode(node) |
| 195 | if err != nil { |
| 196 | errorModal := CreateErrorDialog("VNC Error", fmt.Sprintf("Failed to get client for node: %v", err), func() { |
| 197 | a.pages.RemovePage("vnc_error") |
| 198 | }) |
| 199 | a.pages.AddPage("vnc_error", errorModal, false, true) |
| 200 | return |
| 201 | } |
| 202 | |
| 203 | // Check if VNC is available for this node |
| 204 | available, reason := vncService.GetNodeVNCStatusWithClient(client, node.Name) |
| 205 | if !available { |
| 206 | // Show error in modal dialog instead of header |
| 207 | errorModal := CreateErrorDialog("VNC Not Available", reason, func() { |
| 208 | a.pages.RemovePage("vnc_error") |
| 209 | }) |
| 210 | a.pages.AddPage("vnc_error", errorModal, false, true) |
| 211 | |
| 212 | return |
| 213 | } |
| 214 | |
| 215 | // Connect directly to VNC |
| 216 | a.connectToNodeVNC(node, vncService) |
| 217 | } |
| 218 | |
| 219 | // openVMVNC opens a VNC console connection to the currently selected VM. |
| 220 | func (a *App) openVMVNC() { |
no test coverage detected