GetNodeFromGroup retrieves a specific node from a specific profile. This is useful when you need to perform operations on a node and need to ensure you're using the correct profile's client.
( ctx context.Context, profileName string, nodeName string, )
| 322 | // This is useful when you need to perform operations on a node and need to ensure |
| 323 | // you're using the correct profile's client. |
| 324 | func (m *GroupClientManager) GetNodeFromGroup( |
| 325 | ctx context.Context, |
| 326 | profileName string, |
| 327 | nodeName string, |
| 328 | ) (*Node, error) { |
| 329 | operation := func(pName string, client *Client) (interface{}, error) { |
| 330 | // Selectively invalidate this node's cache keys instead of wiping the entire cache. |
| 331 | // This preserves disk/update/VM caches for other nodes in the same profile. |
| 332 | client.ClearNodeCache(nodeName) |
| 333 | |
| 334 | node, err := client.GetNodeStatus(nodeName) |
| 335 | if err != nil { |
| 336 | return nil, fmt.Errorf("failed to get node status: %w", err) |
| 337 | } |
| 338 | node.SourceProfile = pName |
| 339 | return node, nil |
| 340 | } |
| 341 | |
| 342 | data, err := m.ExecuteOnProfile(ctx, profileName, operation) |
| 343 | if err != nil { |
| 344 | return nil, err |
| 345 | } |
| 346 | |
| 347 | node, ok := data.(*Node) |
| 348 | if !ok { |
| 349 | return nil, fmt.Errorf("unexpected data type returned") |
| 350 | } |
| 351 | |
| 352 | return node, nil |
| 353 | } |
| 354 | |
| 355 | // GetVMFromGroup retrieves detailed VM information from a specific profile. |
| 356 | // This is useful when you need to perform operations on a VM and need to ensure |
no test coverage detected