Add support for host-managed parameter in LXC networks #1467
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for Proxmox VE 9.1's
host-managedparameter in LXC network configurations, enabling creation and management of OCI-based containers.Problem
Proxmox VE 9.1 introduced support for OCI (Open Container Initiative) images, allowing users to run Docker Hub images as LXC containers. When creating these containers, Proxmox automatically sets a
host-managed=1parameter on network interfaces. The provider rejected this parameter with an error:This prevented users from using OCI images with Terraform.
Changes
Schema Update
host_managedfield to LXC network schema as an optional, computed booleanValidation Enhancement
AssertNoNonSchemaValues()to handle API keys with hyphens that map to schema keys with underscoresKey Normalization
adaptDeviceToConf()to normalize all keys by replacing hyphens with underscoresFlattenDevicesList()to normalize keys and convert integer boolean values to actual booleansTechnical Details
Proxmox uses hyphenated keys in the API (
host-managed), while Terraform schemas conventionally use underscores (host_managed). Additionally, Proxmox returns boolean values as integers (1/0), requiring type conversion for Terraform's boolean fields.The changes implement a translation layer that:
Example
OCI Container (nginx)
After applying, the state will show:
Traditional Container (Debian)
Traditional containers continue to work as before, with
host_managed = false.Testing
Tested on Proxmox VE 9.1.1 with:
host_managedstatusBackward Compatibility
Fully backward compatible:
host_managedfield is optional and computedDependencies
Requires the corresponding SDK PR: Telmate/proxmox-api-go#530
References
man pctdocuments thehost-managedparameterGET /nodes/{node}/lxc/{vmid}/config