MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / getClientForVM

Method getClientForVM

internal/ui/components/app.go:624–644  ·  view source on GitHub ↗

getClientForVM returns the appropriate API client for a VM. In group mode, it returns the client for the VM's source profile. In single-profile mode, it returns the main client.

(vm *api.VM)

Source from the content-addressed store, hash-verified

622// In group mode, it returns the client for the VM's source profile.
623// In single-profile mode, it returns the main client.
624func (a *App) getClientForVM(vm *api.VM) (*api.Client, error) {
625 conn := a.snapConn()
626 if conn.isGroupMode {
627 if vm.SourceProfile == "" {
628 return nil, fmt.Errorf("source profile not set for VM %s in group mode", vm.Name)
629 }
630
631 profileClient, exists := conn.groupManager.GetClient(vm.SourceProfile)
632 if !exists {
633 return nil, fmt.Errorf("profile '%s' not found in group manager", vm.SourceProfile)
634 }
635
636 status, err := profileClient.GetStatus()
637 if status != api.ProfileStatusConnected {
638 return nil, fmt.Errorf("profile '%s' is not connected: %v (error: %v)", vm.SourceProfile, status, err)
639 }
640
641 return profileClient.Client, nil
642 }
643 return conn.client, nil
644}
645
646// getClientForNode returns the appropriate API client for a Node.
647// In group mode, it returns the client for the Node's source profile.

Callers 15

doRefreshVMDataMethod · 0.95
showMigrationDialogMethod · 0.95
pollForConfigChangeMethod · 0.95
connectToVMVNCMethod · 0.95
openVMShellMethod · 0.95
ShowVMContextMenuMethod · 0.95
queueBatchOperationMethod · 0.95
CreateSnapshotMethod · 0.80
DeleteSnapshotMethod · 0.80
RollbackToSnapshotMethod · 0.80

Calls 3

snapConnMethod · 0.95
GetClientMethod · 0.80
GetStatusMethod · 0.80

Tested by

no test coverage detected