GetVMConfig fetches the configuration for a VM or container.
(vm *VM)
| 54 | |
| 55 | // GetVMConfig fetches the configuration for a VM or container. |
| 56 | func (c *Client) GetVMConfig(vm *VM) (*VMConfig, error) { |
| 57 | var result map[string]interface{} |
| 58 | |
| 59 | endpoint := fmt.Sprintf("/nodes/%s/%s/%d/config", vm.Node, vm.Type, vm.ID) |
| 60 | if err := c.Get(endpoint, &result); err != nil { |
| 61 | return nil, fmt.Errorf("failed to get config: %w", err) |
| 62 | } |
| 63 | |
| 64 | data, ok := result["data"].(map[string]interface{}) |
| 65 | if !ok { |
| 66 | return nil, fmt.Errorf("unexpected config response format") |
| 67 | } |
| 68 | |
| 69 | return parseVMConfig(vm.Type, data), nil |
| 70 | } |
| 71 | |
| 72 | // UpdateVMConfig updates the configuration for a VM or container. |
| 73 | // For LXC: uses PUT (synchronous, no task ID) |