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

Method GetGroupClusterResources

pkg/api/grouped-cluster.go:274–319  ·  view source on GitHub ↗

GetGroupClusterResources retrieves cluster resources from all profiles in the group. This provides a unified view of all resources across all connected profiles. fresh flag bypasses caches when true.

(ctx context.Context, fresh bool)

Source from the content-addressed store, hash-verified

272// This provides a unified view of all resources across all connected profiles.
273// fresh flag bypasses caches when true.
274func (m *GroupClientManager) GetGroupClusterResources(ctx context.Context, fresh bool) ([]*Node, []*VM, error) {
275 // Use goroutines to fetch nodes and VMs concurrently for better performance
276 type result struct {
277 nodes []*Node
278 vms []*VM
279 err error
280 }
281
282 nodesChan := make(chan result, 1)
283 vmsChan := make(chan result, 1)
284
285 // Fetch nodes
286 go func() {
287 if fresh {
288 // Selectively invalidate cluster-level cache keys per profile
289 // instead of wiping the entire cache (preserves node disks, updates, etc.)
290 for _, pc := range m.GetConnectedClients() {
291 if pc.Client != nil {
292 pc.Client.ClearClusterCache()
293 }
294 }
295 }
296 nodes, err := m.GetGroupNodes(ctx)
297 nodesChan <- result{nodes: nodes, err: err}
298 }()
299
300 // Fetch VMs
301 go func() {
302 vms, err := m.GetGroupVMs(ctx)
303 vmsChan <- result{vms: vms, err: err}
304 }()
305
306 // Wait for both operations to complete
307 nodesResult := <-nodesChan
308 vmsResult := <-vmsChan
309
310 if nodesResult.err != nil {
311 return nil, nil, fmt.Errorf("failed to get group nodes: %w", nodesResult.err)
312 }
313
314 if vmsResult.err != nil {
315 return nil, nil, fmt.Errorf("failed to get group VMs: %w", vmsResult.err)
316 }
317
318 return nodesResult.nodes, vmsResult.vms, nil
319}
320
321// GetNodeFromGroup retrieves a specific node from a specific profile.
322// This is useful when you need to perform operations on a node and need to ensure

Callers 3

switchToGroupMethod · 0.95
doManualRefreshMethod · 0.80
autoRefreshDataMethod · 0.80

Calls 4

GetConnectedClientsMethod · 0.95
GetGroupNodesMethod · 0.95
GetGroupVMsMethod · 0.95
ClearClusterCacheMethod · 0.80

Tested by

no test coverage detected