handleRunVMCommand shows the command menu for the selected QEMU VM.
(ctx context.Context, app *components.App, node *api.Node, guest *api.VM)
| 188 | |
| 189 | // handleRunVMCommand shows the command menu for the selected QEMU VM. |
| 190 | func (p *Plugin) handleRunVMCommand(ctx context.Context, app *components.App, node *api.Node, guest *api.VM) error { |
| 191 | if app == nil { |
| 192 | return fmt.Errorf("application context unavailable") |
| 193 | } |
| 194 | |
| 195 | if node == nil { |
| 196 | return fmt.Errorf("no node selected") |
| 197 | } |
| 198 | |
| 199 | if guest == nil { |
| 200 | return fmt.Errorf("no guest selected") |
| 201 | } |
| 202 | |
| 203 | if p.runner == nil || !p.runner.Enabled() { |
| 204 | return fmt.Errorf("command runner not initialized") |
| 205 | } |
| 206 | |
| 207 | p.updateSSHClient(node) |
| 208 | |
| 209 | vmCtx := commandrunner.VM{ |
| 210 | ID: guest.ID, |
| 211 | Node: node.Name, |
| 212 | Type: guest.Type, |
| 213 | Status: guest.Status, |
| 214 | AgentEnabled: guest.AgentEnabled, |
| 215 | AgentRunning: guest.AgentRunning, |
| 216 | OSType: guest.OSType, |
| 217 | } |
| 218 | |
| 219 | // Show VM command menu |
| 220 | p.runner.ShowVMCommandMenu(vmCtx, nil) |
| 221 | |
| 222 | return nil |
| 223 | } |
| 224 | |
| 225 | func (p *Plugin) updateSSHClient(node *api.Node) { |
| 226 | if p == nil || p.runner == nil { |