GetVMFromGroup retrieves detailed VM information from a specific profile. This is useful when you need to perform operations on a VM and need to ensure you're using the correct profile's client.
( ctx context.Context, profileName string, nodeName string, vmType string, vmID int, )
| 356 | // This is useful when you need to perform operations on a VM and need to ensure |
| 357 | // you're using the correct profile's client. |
| 358 | func (m *GroupClientManager) GetVMFromGroup( |
| 359 | ctx context.Context, |
| 360 | profileName string, |
| 361 | nodeName string, |
| 362 | vmType string, |
| 363 | vmID int, |
| 364 | ) (*VM, error) { |
| 365 | operation := func(pName string, client *Client) (interface{}, error) { |
| 366 | vm, err := client.GetDetailedVmInfo(nodeName, vmType, vmID) |
| 367 | if err != nil { |
| 368 | return nil, fmt.Errorf("failed to get VM info: %w", err) |
| 369 | } |
| 370 | vm.SourceProfile = pName |
| 371 | return vm, nil |
| 372 | } |
| 373 | |
| 374 | data, err := m.ExecuteOnProfile(ctx, profileName, operation) |
| 375 | if err != nil { |
| 376 | return nil, err |
| 377 | } |
| 378 | |
| 379 | vm, ok := data.(*VM) |
| 380 | if !ok { |
| 381 | return nil, fmt.Errorf("unexpected data type returned") |
| 382 | } |
| 383 | |
| 384 | return vm, nil |
| 385 | } |
| 386 | |
| 387 | // FindVMByIDInGroup searches for a VM with the given ID across all profiles. |
| 388 | // Returns the VM and its source profile name, or an error if not found. |
nothing calls this directly
no test coverage detected