-
-
Notifications
You must be signed in to change notification settings - Fork 209
feat(sdn): add support for zones, vnets, subnets, validation, and tests #1995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MacherelR
wants to merge
13
commits into
bpg:main
Choose a base branch
from
MacherelR:feature/SDN
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
58ff2ff
feat(sdn)!: add SDN support for zones, vnets, subnets with validation…
MacherelR 48bb57f
fix(sdn): resolve linter warnings and apply gofumpt formatting
MacherelR a76cc62
fix(tests): fix `make example` tests (#2007)
bpg 2d9e0b5
feat: add support for 'import' content type in Proxmox file resources…
Vaneixus 7b26553
docs: add Vaneixus as a contributor for code (#2009)
allcontributors[bot] b601ca3
chore(deps): update module github.com/brianvoe/gofakeit/v7 (v7.2.1 → …
renovate[bot] 8c2a071
chore(docs): minor fixes / updates in guides (#2014)
bpg 264a4e6
feat(sdn)!: add SDN support for zones, vnets, subnets with validation…
MacherelR 0c2aa76
fix(sdn): resolve linter warnings and apply gofumpt formatting
MacherelR 9840cf4
Merge remote-tracking branch 'origin/feature/SDN' into feature/SDN
MacherelR 196e972
fix(sdn): corrected tests
MacherelR 676105e
fix(sdn): corrected tests
MacherelR ce51627
Merge remote-tracking branch 'origin/feature/SDN' into feature/SDN
MacherelR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
layout: page | ||
title: proxmox_virtual_environment_sdn_subnet | ||
parent: Data Sources | ||
subcategory: Virtual Environment | ||
description: |- | ||
Retrieve details about a specific SDN Subnet in Proxmox VE. | ||
--- | ||
|
||
# Data Source: proxmox_virtual_environment_sdn_subnet | ||
|
||
Retrieve details about a specific SDN Subnet in Proxmox VE. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `subnet` (String) | ||
- `vnet` (String) The VNet this subnet belongs to. | ||
|
||
### Read-Only | ||
|
||
- `canonical_name` (String) | ||
- `dhcp_dns_server` (String) The DNS server used for DHCP. | ||
- `dhcp_range` (Attributes List) List of DHCP ranges (start and end IPs). (see [below for nested schema](#nestedatt--dhcp_range)) | ||
- `dnszoneprefix` (String) Prefix used for DNS zone delegation. | ||
- `gateway` (String) The gateway address for the subnet. | ||
- `id` (String) The full ID in the format 'vnet-id/subnet-id'. | ||
- `snat` (Boolean) Whether SNAT is enabled for the subnet. | ||
- `type` (String) | ||
|
||
<a id="nestedatt--dhcp_range"></a> | ||
### Nested Schema for `dhcp_range` | ||
|
||
Read-Only: | ||
|
||
- `end_address` (String) End of the DHCP range. | ||
- `start_address` (String) Start of the DHCP range. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
layout: page | ||
title: proxmox_virtual_environment_sdn_vnet | ||
parent: Data Sources | ||
subcategory: Virtual Environment | ||
description: |- | ||
Retrieves information about an existing SDN Vnet in Proxmox VE. | ||
--- | ||
|
||
# Data Source: proxmox_virtual_environment_sdn_vnet | ||
|
||
Retrieves information about an existing SDN Vnet in Proxmox VE. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The name of the vnet. | ||
|
||
### Read-Only | ||
|
||
- `alias` (String) - An alias for this vnet. | ||
- `id` (String) - The ID of the vnet (usually the name). | ||
- `isolate_ports` (Boolean) - Whether ports are isolated. | ||
- `tag` (Number) - VLAN/VXLAN tag. | ||
- `type` (String) - Type of the vnet. | ||
- `vlanaware` (Boolean) - Whether this vnet is VLAN aware. | ||
- `zone` (String) - The zone associated with the vnet. | ||
- `zonetype` (String) - The type of the zone associated with this vnet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
layout: page | ||
title: proxmox_virtual_environment_sdn_zone | ||
parent: Data Sources | ||
subcategory: Virtual Environment | ||
description: |- | ||
Fetch a Proxmox SDN Zone by name. | ||
--- | ||
|
||
# Data Source: proxmox_virtual_environment_sdn_zone | ||
|
||
|
||
This data source allows you to fetch information about an existing SDN zone in a Proxmox Virtual Environment (PVE) cluster by its name. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Name (ID) of the SDN zone. | ||
|
||
### Read-Only | ||
|
||
- `advertise_subnets` (Boolean) - Whether to advertise subnets to the zone. | ||
- `bridge` (String) – Linux bridge device used (if applicable). | ||
- `controller` (String) – Controller for EVPN zones. | ||
- `disable_arp_nd_suppression` (Boolean) – Whether ARP/ND suppression is disabled. | ||
- `dns` (String) – DNS server configured for the zone. | ||
- `dns_zone` (String) – The DNS zone name used by this SDN zone. | ||
- `exit_nodes` (String) – Nodes designated as exit points. | ||
- `exit_nodes_local_routing` (Boolean) – Whether local routing is enabled for exit nodes. | ||
- `id` (String) - The ID of the SDN zone. | ||
- `ipam` (String) – The IP Address Management (IPAM) method used in the zone. | ||
- `mtu` (Number) – Maximum Transmission Unit for this zone. | ||
- `nodes` (String) – Comma-separated list of node names associated with the zone. | ||
- `peers` (String) – Peers used for some zone types only. | ||
- `primary_exit_node` (String) – The main exit node. | ||
- `reversedns` (String) – Reverse DNS server for the zone. | ||
- `rt_import` (String) – Route targets to import. | ||
- `tag` (Number) – VLAN tag or other numeric identifier. | ||
- `type` (String) – The SDN zone type (e.g., `simple`, `vlan`, `vxlan`, `evpn`). | ||
- `vlan_protocol` (String) – VLAN protocol used. | ||
- `vrf_vxlan` (Number) – VXLAN ID associated with VRF zones. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
layout: page | ||
title: proxmox_virtual_environment_sdn_subnet | ||
parent: Resources | ||
subcategory: Virtual Environment | ||
description: |- | ||
Manages SDN Subnets in Proxmox VE. | ||
--- | ||
|
||
# Resource: proxmox_virtual_environment_sdn_subnet | ||
|
||
Manages SDN Subnets in Proxmox VE. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `subnet` (String) The name/ID of the subnet. | ||
- `vnet` (String) The VNet to which this subnet belongs. | ||
|
||
### Optional | ||
|
||
- `dhcp_dns_server` (String) The DNS server used for DHCP. | ||
- `dhcp_range` (Attributes List) List of DHCP ranges (start and end IPs). (see [below for nested schema](#nestedatt--dhcp_range)) | ||
- `dnszoneprefix` (String) Prefix used for DNS zone delegation. | ||
- `gateway` (String) The gateway address for the subnet. | ||
- `snat` (Boolean) Whether SNAT is enabled for the subnet. | ||
|
||
### Read-Only | ||
|
||
- `canonical_name` (String) Canonical name of the subnet (e.g. zoneM-10.10.0.0-24). | ||
- `id` (String) The unique identifier of this resource. | ||
- `type` (String) Subnet type (set default at 'subnet') | ||
|
||
<a id="nestedatt--dhcp_range"></a> | ||
### Nested Schema for `dhcp_range` | ||
|
||
Required: | ||
|
||
- `end_address` (String) End of the DHCP range. | ||
- `start_address` (String) Start of the DHCP range. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
layout: page | ||
title: proxmox_virtual_environment_sdn_vnet | ||
parent: Resources | ||
subcategory: Virtual Environment | ||
description: |- | ||
Manages Proxmox VE SDN vnet. | ||
--- | ||
|
||
# Resource: proxmox_virtual_environment_sdn_vnet | ||
|
||
Manages Proxmox VE SDN vnet. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) Unique identifier for the vnet. | ||
- `zone` (String) The zone to which this vnet belongs. | ||
- `zonetype` (String) Parent's zone type. MUST be specified. | ||
|
||
### Optional | ||
|
||
- `alias` (String) An optional alias for this vnet. | ||
- `isolate_ports` (Boolean) Whether to isolate ports within this vnet. | ||
- `tag` (Number) Tag value for VLAN/VXLAN (depends on zone type). | ||
- `vlanaware` (Boolean) Whether this vnet is VLAN aware. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The unique identifier of this resource. | ||
- `type` (String) Type of vnet (e.g. 'vnet'). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
layout: page | ||
title: proxmox_virtual_environment_sdn_zone | ||
parent: Resources | ||
subcategory: Virtual Environment | ||
description: |- | ||
Manages SDN Zones in Proxmox VE. | ||
--- | ||
|
||
# Resource: proxmox_virtual_environment_sdn_zone | ||
|
||
Manages SDN Zones in Proxmox VE. | ||
Some attributes in the `proxmox_virtual_environment_sdn_zone` resource or data source are only applicable to certain zone types. For example: | ||
|
||
`bridge` is relevant only for `vlan` zones. | ||
|
||
`peers`, `controller`, `vrf_vxlan`, and related attributes are specific to `vxlan` and `evpn` zone types. | ||
|
||
`service_vlan` and `vlan_protocol` apply to `qinq` zones. | ||
|
||
While the Proxmox API does not explicitly document these constraints, they are enforced by the Proxmox backend and have been validated manually through API experimentation. | ||
|
||
The Terraform provider implements field-level validation to ensure that only compatible attributes are used with each zone type. If incompatible attributes are set, Terraform will raise a configuration error during plan or apply to prevent invalid requests to the Proxmox API. | ||
|
||
This design helps ensure correctness and avoids unexpected API failures when managing SDN zones across different zone types. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The unique ID of the SDN zone. | ||
- `type` (String) Zone type (e.g. simple, vlan, qinq, vxlan, evpn). | ||
|
||
### Optional | ||
|
||
- `advertise_subnets` (Boolean) Enable subnet advertisement for EVPN. | ||
- `bridge` (String) Bridge interface for VLAN/QinQ. | ||
- `controller` (String) EVPN controller address. | ||
- `disable_arp_nd_suppression` (Boolean) Disable ARP/ND suppression for EVPN. | ||
- `dns` (String) DNS server address. | ||
- `dns_zone` (String) DNS zone name. | ||
- `exit_nodes` (String) Comma-separated list of exit nodes for EVPN. | ||
- `exit_nodes_local_routing` (Boolean) Enable local routing for EVPN exit nodes. | ||
- `ipam` (String) IP Address Management system. | ||
- `mtu` (Number) MTU value for the zone. | ||
- `nodes` (String) Comma-separated list of Proxmox node names. | ||
- `peers` (String) Peers list for VXLAN. | ||
- `primary_exit_node` (String) Primary exit node for EVPN. | ||
- `reversedns` (String) Reverse DNS settings. | ||
- `rt_import` (String) Route target import for EVPN. | ||
- `tag` (Number) Service VLAN tag for QinQ. | ||
- `vlan_protocol` (String) Service VLAN protocol for QinQ. | ||
- `vrf_vxlan` (Number) EVPN VRF VXLAN ID. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The unique identifier of this resource. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably indicate here if the target resource does not exist in PVE, the datasource will return an error. It's pretty common (albeit a bad practice) to return a datasource with null attributes in this case, which some users may expect.
It may also be worthwhile to mark the attributes as required as well, as I assume they all (or at least most of them) will be present on the ds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for the other datasources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See what you mean.
For me it seems clearer to return an error when the target resource doesn't exist as it can indicate the user something is wrong... On the other hand, returning resource will null attribute could allow the rest of the deployment to work correctly, but may lead to errors later on.. What do you think is best ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I totally agree with that, and I think we should maintain this approach for all new data sources moving forward.