diff --git a/docs/data-sources/virtual_environment_sdn_zone_evpn.md b/docs/data-sources/virtual_environment_sdn_zone_evpn.md new file mode 100644 index 00000000..14ed2a7a --- /dev/null +++ b/docs/data-sources/virtual_environment_sdn_zone_evpn.md @@ -0,0 +1,64 @@ +--- +layout: page +title: proxmox_virtual_environment_sdn_zone_evpn +parent: Data Sources +subcategory: Virtual Environment +description: |- + Retrieves information about an EVPN Zone in Proxmox SDN. The EVPN zone creates a routable Layer 3 network, capable of spanning across multiple clusters. +--- + +# Data Source: proxmox_virtual_environment_sdn_zone_evpn + +Retrieves information about an EVPN Zone in Proxmox SDN. The EVPN zone creates a routable Layer 3 network, capable of spanning across multiple clusters. + +## Example Usage + +```terraform +data "proxmox_virtual_environment_sdn_zone_evpn" "example" { + id = "evpn1" +} + +output "data_proxmox_virtual_environment_sdn_zone_evpn" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_evpn.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_evpn.example.nodes + controller = data.proxmox_virtual_environment_sdn_zone_evpn.example.controller + vrf_vxlan = data.proxmox_virtual_environment_sdn_zone_evpn.example.vrf_vxlan + advertise_subnets = data.proxmox_virtual_environment_sdn_zone_evpn.example.advertise_subnets + disable_arp_nd_suppression = data.proxmox_virtual_environment_sdn_zone_evpn.example.disable_arp_nd_suppression + exit_nodes = data.proxmox_virtual_environment_sdn_zone_evpn.example.exit_nodes + exit_nodes_local_routing = data.proxmox_virtual_environment_sdn_zone_evpn.example.exit_nodes_local_routing + primary_exit_node = data.proxmox_virtual_environment_sdn_zone_evpn.example.primary_exit_node + rt_import = data.proxmox_virtual_environment_sdn_zone_evpn.example.rt_import + mtu = data.proxmox_virtual_environment_sdn_zone_evpn.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_evpn.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_evpn.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_evpn.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_evpn.example.reverse_dns + } +} +``` + + +## Schema + +### Required + +- `id` (String) The unique identifier of the SDN zone. + +### Read-Only + +- `advertise_subnets` (Boolean) Enable subnet advertisement for EVPN. +- `controller` (String) EVPN controller address. +- `disable_arp_nd_suppression` (Boolean) Disable ARP/ND suppression for EVPN. +- `dns` (String) DNS API server address. +- `dns_zone` (String) DNS domain name. Used to register hostnames, such as `.`. The DNS zone must already exist on the DNS server. +- `exit_nodes` (Set of String) 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` (Set of String) The Proxmox nodes which the zone and associated VNets are deployed on +- `primary_exit_node` (String) Primary exit node for EVPN. +- `reverse_dns` (String) Reverse DNS API server address. +- `rt_import` (String) Route target import for EVPN. Must be in the format ':' (e.g., '65000:65000'). +- `vrf_vxlan` (Number) VRF VXLAN-ID used for dedicated routing interconnect between VNets. It must be different than the VXLAN-ID of the VNets. diff --git a/docs/data-sources/virtual_environment_sdn_zone_qinq.md b/docs/data-sources/virtual_environment_sdn_zone_qinq.md new file mode 100644 index 00000000..b3ad6eba --- /dev/null +++ b/docs/data-sources/virtual_environment_sdn_zone_qinq.md @@ -0,0 +1,54 @@ +--- +layout: page +title: proxmox_virtual_environment_sdn_zone_qinq +parent: Data Sources +subcategory: Virtual Environment +description: |- + Retrieves information about a QinQ Zone in Proxmox SDN. QinQ also known as VLAN stacking, that uses multiple layers of VLAN tags for isolation. The QinQ zone defines the outer VLAN tag (the Service VLAN) whereas the inner VLAN tag is defined by the VNet. Your physical network switches must support stacked VLANs for this configuration. Due to the double stacking of tags, you need 4 more bytes for QinQ VLANs. For example, you must reduce the MTU to 1496 if you physical interface MTU is 1500. +--- + +# Data Source: proxmox_virtual_environment_sdn_zone_qinq + +Retrieves information about a QinQ Zone in Proxmox SDN. QinQ also known as VLAN stacking, that uses multiple layers of VLAN tags for isolation. The QinQ zone defines the outer VLAN tag (the Service VLAN) whereas the inner VLAN tag is defined by the VNet. Your physical network switches must support stacked VLANs for this configuration. Due to the double stacking of tags, you need 4 more bytes for QinQ VLANs. For example, you must reduce the MTU to 1496 if you physical interface MTU is 1500. + +## Example Usage + +```terraform +data "proxmox_virtual_environment_sdn_zone_qinq" "example" { + id = "qinq1" +} + +output "data_proxmox_virtual_environment_sdn_zone_qinq" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_qinq.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_qinq.example.nodes + bridge = data.proxmox_virtual_environment_sdn_zone_qinq.example.bridge + service_vlan = data.proxmox_virtual_environment_sdn_zone_qinq.example.service_vlan + service_vlan_protocol = data.proxmox_virtual_environment_sdn_zone_qinq.example.service_vlan_protocol + mtu = data.proxmox_virtual_environment_sdn_zone_qinq.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_qinq.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_qinq.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_qinq.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_qinq.example.reverse_dns + } +} +``` + + +## Schema + +### Required + +- `id` (String) The unique identifier of the SDN zone. + +### Read-Only + +- `bridge` (String) A local, VLAN-aware bridge that is already configured on each local node +- `dns` (String) DNS API server address. +- `dns_zone` (String) DNS domain name. Used to register hostnames, such as `.`. The DNS zone must already exist on the DNS server. +- `ipam` (String) IP Address Management system. +- `mtu` (Number) MTU value for the zone. +- `nodes` (Set of String) The Proxmox nodes which the zone and associated VNets are deployed on +- `reverse_dns` (String) Reverse DNS API server address. +- `service_vlan` (Number) Service VLAN tag for QinQ. The tag must be between `1` and `4094`. +- `service_vlan_protocol` (String) Service VLAN protocol for QinQ. The protocol must be `802.1ad` or `802.1q`. diff --git a/docs/data-sources/virtual_environment_sdn_zone_simple.md b/docs/data-sources/virtual_environment_sdn_zone_simple.md new file mode 100644 index 00000000..79382c0e --- /dev/null +++ b/docs/data-sources/virtual_environment_sdn_zone_simple.md @@ -0,0 +1,48 @@ +--- +layout: page +title: proxmox_virtual_environment_sdn_zone_simple +parent: Data Sources +subcategory: Virtual Environment +description: |- + Retrieves information about a Simple Zone in Proxmox SDN. It will create an isolated VNet bridge. This bridge is not linked to a physical interface, and VM traffic is only local on each the node. It can be used in NAT or routed setups. +--- + +# Data Source: proxmox_virtual_environment_sdn_zone_simple + +Retrieves information about a Simple Zone in Proxmox SDN. It will create an isolated VNet bridge. This bridge is not linked to a physical interface, and VM traffic is only local on each the node. It can be used in NAT or routed setups. + +## Example Usage + +```terraform +data "proxmox_virtual_environment_sdn_zone_simple" "example" { + id = "simple1" +} + +output "data_proxmox_virtual_environment_sdn_zone_simple" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_simple.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_simple.example.nodes + mtu = data.proxmox_virtual_environment_sdn_zone_simple.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_simple.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_simple.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_simple.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_simple.example.reverse_dns + } +} +``` + + +## Schema + +### Required + +- `id` (String) The unique identifier of the SDN zone. + +### Read-Only + +- `dns` (String) DNS API server address. +- `dns_zone` (String) DNS domain name. Used to register hostnames, such as `.`. The DNS zone must already exist on the DNS server. +- `ipam` (String) IP Address Management system. +- `mtu` (Number) MTU value for the zone. +- `nodes` (Set of String) The Proxmox nodes which the zone and associated VNets are deployed on +- `reverse_dns` (String) Reverse DNS API server address. diff --git a/docs/data-sources/virtual_environment_sdn_zone_vlan.md b/docs/data-sources/virtual_environment_sdn_zone_vlan.md new file mode 100644 index 00000000..83377df2 --- /dev/null +++ b/docs/data-sources/virtual_environment_sdn_zone_vlan.md @@ -0,0 +1,50 @@ +--- +layout: page +title: proxmox_virtual_environment_sdn_zone_vlan +parent: Data Sources +subcategory: Virtual Environment +description: |- + Retrieves information about a VLAN Zone in Proxmox SDN. It uses an existing local Linux or OVS bridge to connect to the node's physical interface. It uses VLAN tagging defined in the VNet to isolate the network segments. This allows connectivity of VMs between different nodes. +--- + +# Data Source: proxmox_virtual_environment_sdn_zone_vlan + +Retrieves information about a VLAN Zone in Proxmox SDN. It uses an existing local Linux or OVS bridge to connect to the node's physical interface. It uses VLAN tagging defined in the VNet to isolate the network segments. This allows connectivity of VMs between different nodes. + +## Example Usage + +```terraform +data "proxmox_virtual_environment_sdn_zone_vlan" "example" { + id = "vlan1" +} + +output "data_proxmox_virtual_environment_sdn_zone_vlan" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_vlan.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_vlan.example.nodes + bridge = data.proxmox_virtual_environment_sdn_zone_vlan.example.bridge + mtu = data.proxmox_virtual_environment_sdn_zone_vlan.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_vlan.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_vlan.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_vlan.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_vlan.example.reverse_dns + } +} +``` + + +## Schema + +### Required + +- `id` (String) The unique identifier of the SDN zone. + +### Read-Only + +- `bridge` (String) The local bridge or OVS switch, already configured on _each_ node that allows node-to-node connection. +- `dns` (String) DNS API server address. +- `dns_zone` (String) DNS domain name. Used to register hostnames, such as `.`. The DNS zone must already exist on the DNS server. +- `ipam` (String) IP Address Management system. +- `mtu` (Number) MTU value for the zone. +- `nodes` (Set of String) The Proxmox nodes which the zone and associated VNets are deployed on +- `reverse_dns` (String) Reverse DNS API server address. diff --git a/docs/data-sources/virtual_environment_sdn_zone_vxlan.md b/docs/data-sources/virtual_environment_sdn_zone_vxlan.md new file mode 100644 index 00000000..a4346333 --- /dev/null +++ b/docs/data-sources/virtual_environment_sdn_zone_vxlan.md @@ -0,0 +1,50 @@ +--- +layout: page +title: proxmox_virtual_environment_sdn_zone_vxlan +parent: Data Sources +subcategory: Virtual Environment +description: |- + Retrieves information about a VXLAN Zone in Proxmox SDN. It establishes a tunnel (overlay) on top of an existing network (underlay). This encapsulates layer 2 Ethernet frames within layer 4 UDP datagrams using the default destination port 4789. You have to configure the underlay network yourself to enable UDP connectivity between all peers. Because VXLAN encapsulation uses 50 bytes, the MTU needs to be 50 bytes lower than the outgoing physical interface. +--- + +# Data Source: proxmox_virtual_environment_sdn_zone_vxlan + +Retrieves information about a VXLAN Zone in Proxmox SDN. It establishes a tunnel (overlay) on top of an existing network (underlay). This encapsulates layer 2 Ethernet frames within layer 4 UDP datagrams using the default destination port 4789. You have to configure the underlay network yourself to enable UDP connectivity between all peers. Because VXLAN encapsulation uses 50 bytes, the MTU needs to be 50 bytes lower than the outgoing physical interface. + +## Example Usage + +```terraform +data "proxmox_virtual_environment_sdn_zone_vxlan" "example" { + id = "vxlan1" +} + +output "data_proxmox_virtual_environment_sdn_zone_vxlan" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_vxlan.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_vxlan.example.nodes + peers = data.proxmox_virtual_environment_sdn_zone_vxlan.example.peers + mtu = data.proxmox_virtual_environment_sdn_zone_vxlan.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_vxlan.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_vxlan.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_vxlan.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_vxlan.example.reverse_dns + } +} +``` + + +## Schema + +### Required + +- `id` (String) The unique identifier of the SDN zone. + +### Read-Only + +- `dns` (String) DNS API server address. +- `dns_zone` (String) DNS domain name. Used to register hostnames, such as `.`. The DNS zone must already exist on the DNS server. +- `ipam` (String) IP Address Management system. +- `mtu` (Number) MTU value for the zone. +- `nodes` (Set of String) The Proxmox nodes which the zone and associated VNets are deployed on +- `peers` (Set of String) A list of IP addresses of each node in the VXLAN zone. This can be external nodes reachable at this IP address. All nodes in the cluster need to be mentioned here +- `reverse_dns` (String) Reverse DNS API server address. diff --git a/docs/data-sources/virtual_environment_sdn_zones.md b/docs/data-sources/virtual_environment_sdn_zones.md new file mode 100644 index 00000000..2997d01b --- /dev/null +++ b/docs/data-sources/virtual_environment_sdn_zones.md @@ -0,0 +1,79 @@ +--- +layout: page +title: proxmox_virtual_environment_sdn_zones +parent: Data Sources +subcategory: Virtual Environment +description: |- + Retrieves information about all SDN Zones in Proxmox. This data source can optionally filter zones by type. +--- + +# Data Source: proxmox_virtual_environment_sdn_zones + +Retrieves information about all SDN Zones in Proxmox. This data source can optionally filter zones by type. + +## Example Usage + +```terraform +# List all SDN zones +data "proxmox_virtual_environment_sdn_zones" "all" {} + +# List only EVPN zones +data "proxmox_virtual_environment_sdn_zones" "evpn_only" { + type = "evpn" +} + +# List only Simple zones +data "proxmox_virtual_environment_sdn_zones" "simple_only" { + type = "simple" +} + +output "data_proxmox_virtual_environment_sdn_zones_all" { + value = { + zones = data.proxmox_virtual_environment_sdn_zones.all.zones + } +} + +output "data_proxmox_virtual_environment_sdn_zones_filtered" { + value = { + evpn_zones = data.proxmox_virtual_environment_sdn_zones.evpn_only.zones + simple_zones = data.proxmox_virtual_environment_sdn_zones.simple_only.zones + } +} +``` + + +## Schema + +### Optional + +- `type` (String) Filter zones by type (simple, vlan, qinq, vxlan, evpn). + +### Read-Only + +- `zones` (List of Object) List of SDN zones. (see [below for nested schema](#nestedatt--zones)) + + +### Nested Schema for `zones` + +Read-Only: + +- `advertise_subnets` (Boolean) +- `bridge` (String) +- `controller` (String) +- `disable_arp_nd_suppression` (Boolean) +- `dns` (String) +- `dns_zone` (String) +- `exit_nodes` (Set of String) +- `exit_nodes_local_routing` (Boolean) +- `id` (String) +- `ipam` (String) +- `mtu` (Number) +- `nodes` (Set of String) +- `peers` (Set of String) +- `primary_exit_node` (String) +- `reverse_dns` (String) +- `rt_import` (String) +- `service_vlan` (Number) +- `service_vlan_protocol` (String) +- `type` (String) +- `vrf_vxlan` (Number) diff --git a/examples/data-sources/proxmox_virtual_environment_sdn_zone_evpn/data-source.tf b/examples/data-sources/proxmox_virtual_environment_sdn_zone_evpn/data-source.tf new file mode 100644 index 00000000..2b70ab68 --- /dev/null +++ b/examples/data-sources/proxmox_virtual_environment_sdn_zone_evpn/data-source.tf @@ -0,0 +1,23 @@ +data "proxmox_virtual_environment_sdn_zone_evpn" "example" { + id = "evpn1" +} + +output "data_proxmox_virtual_environment_sdn_zone_evpn" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_evpn.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_evpn.example.nodes + controller = data.proxmox_virtual_environment_sdn_zone_evpn.example.controller + vrf_vxlan = data.proxmox_virtual_environment_sdn_zone_evpn.example.vrf_vxlan + advertise_subnets = data.proxmox_virtual_environment_sdn_zone_evpn.example.advertise_subnets + disable_arp_nd_suppression = data.proxmox_virtual_environment_sdn_zone_evpn.example.disable_arp_nd_suppression + exit_nodes = data.proxmox_virtual_environment_sdn_zone_evpn.example.exit_nodes + exit_nodes_local_routing = data.proxmox_virtual_environment_sdn_zone_evpn.example.exit_nodes_local_routing + primary_exit_node = data.proxmox_virtual_environment_sdn_zone_evpn.example.primary_exit_node + rt_import = data.proxmox_virtual_environment_sdn_zone_evpn.example.rt_import + mtu = data.proxmox_virtual_environment_sdn_zone_evpn.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_evpn.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_evpn.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_evpn.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_evpn.example.reverse_dns + } +} diff --git a/examples/data-sources/proxmox_virtual_environment_sdn_zone_qinq/data-source.tf b/examples/data-sources/proxmox_virtual_environment_sdn_zone_qinq/data-source.tf new file mode 100644 index 00000000..26f448c1 --- /dev/null +++ b/examples/data-sources/proxmox_virtual_environment_sdn_zone_qinq/data-source.tf @@ -0,0 +1,18 @@ +data "proxmox_virtual_environment_sdn_zone_qinq" "example" { + id = "qinq1" +} + +output "data_proxmox_virtual_environment_sdn_zone_qinq" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_qinq.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_qinq.example.nodes + bridge = data.proxmox_virtual_environment_sdn_zone_qinq.example.bridge + service_vlan = data.proxmox_virtual_environment_sdn_zone_qinq.example.service_vlan + service_vlan_protocol = data.proxmox_virtual_environment_sdn_zone_qinq.example.service_vlan_protocol + mtu = data.proxmox_virtual_environment_sdn_zone_qinq.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_qinq.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_qinq.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_qinq.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_qinq.example.reverse_dns + } +} diff --git a/examples/data-sources/proxmox_virtual_environment_sdn_zone_simple/data-source.tf b/examples/data-sources/proxmox_virtual_environment_sdn_zone_simple/data-source.tf new file mode 100644 index 00000000..452cb88f --- /dev/null +++ b/examples/data-sources/proxmox_virtual_environment_sdn_zone_simple/data-source.tf @@ -0,0 +1,15 @@ +data "proxmox_virtual_environment_sdn_zone_simple" "example" { + id = "simple1" +} + +output "data_proxmox_virtual_environment_sdn_zone_simple" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_simple.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_simple.example.nodes + mtu = data.proxmox_virtual_environment_sdn_zone_simple.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_simple.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_simple.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_simple.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_simple.example.reverse_dns + } +} diff --git a/examples/data-sources/proxmox_virtual_environment_sdn_zone_vlan/data-source.tf b/examples/data-sources/proxmox_virtual_environment_sdn_zone_vlan/data-source.tf new file mode 100644 index 00000000..a1f0f9e4 --- /dev/null +++ b/examples/data-sources/proxmox_virtual_environment_sdn_zone_vlan/data-source.tf @@ -0,0 +1,16 @@ +data "proxmox_virtual_environment_sdn_zone_vlan" "example" { + id = "vlan1" +} + +output "data_proxmox_virtual_environment_sdn_zone_vlan" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_vlan.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_vlan.example.nodes + bridge = data.proxmox_virtual_environment_sdn_zone_vlan.example.bridge + mtu = data.proxmox_virtual_environment_sdn_zone_vlan.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_vlan.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_vlan.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_vlan.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_vlan.example.reverse_dns + } +} diff --git a/examples/data-sources/proxmox_virtual_environment_sdn_zone_vxlan/data-source.tf b/examples/data-sources/proxmox_virtual_environment_sdn_zone_vxlan/data-source.tf new file mode 100644 index 00000000..2ca035e4 --- /dev/null +++ b/examples/data-sources/proxmox_virtual_environment_sdn_zone_vxlan/data-source.tf @@ -0,0 +1,16 @@ +data "proxmox_virtual_environment_sdn_zone_vxlan" "example" { + id = "vxlan1" +} + +output "data_proxmox_virtual_environment_sdn_zone_vxlan" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_vxlan.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_vxlan.example.nodes + peers = data.proxmox_virtual_environment_sdn_zone_vxlan.example.peers + mtu = data.proxmox_virtual_environment_sdn_zone_vxlan.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_vxlan.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_vxlan.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_vxlan.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_vxlan.example.reverse_dns + } +} diff --git a/examples/data-sources/proxmox_virtual_environment_sdn_zones/data-source.tf b/examples/data-sources/proxmox_virtual_environment_sdn_zones/data-source.tf new file mode 100644 index 00000000..a84abd4c --- /dev/null +++ b/examples/data-sources/proxmox_virtual_environment_sdn_zones/data-source.tf @@ -0,0 +1,25 @@ +# List all SDN zones +data "proxmox_virtual_environment_sdn_zones" "all" {} + +# List only EVPN zones +data "proxmox_virtual_environment_sdn_zones" "evpn_only" { + type = "evpn" +} + +# List only Simple zones +data "proxmox_virtual_environment_sdn_zones" "simple_only" { + type = "simple" +} + +output "data_proxmox_virtual_environment_sdn_zones_all" { + value = { + zones = data.proxmox_virtual_environment_sdn_zones.all.zones + } +} + +output "data_proxmox_virtual_environment_sdn_zones_filtered" { + value = { + evpn_zones = data.proxmox_virtual_environment_sdn_zones.evpn_only.zones + simple_zones = data.proxmox_virtual_environment_sdn_zones.simple_only.zones + } +} diff --git a/fwprovider/cluster/sdn/zone/datasource_evpn.go b/fwprovider/cluster/sdn/zone/datasource_evpn.go new file mode 100644 index 00000000..c504360a --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_evpn.go @@ -0,0 +1,99 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/bpg/terraform-provider-proxmox/fwprovider/types/stringset" + "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/sdn/zones" +) + +var ( + _ datasource.DataSource = &EVPNDataSource{} + _ datasource.DataSourceWithConfigure = &EVPNDataSource{} +) + +type EVPNDataSource struct { + generic *genericZoneDataSource +} + +func NewEVPNDataSource() datasource.DataSource { + return &EVPNDataSource{ + generic: newGenericZoneDataSource(zoneDataSourceConfig{ + typeNameSuffix: "_sdn_zone_evpn", + zoneType: zones.TypeEVPN, + modelFunc: func() zoneModel { return &evpnModel{} }, + }), + } +} + +func (d *EVPNDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Retrieves information about an EVPN Zone in Proxmox SDN.", + MarkdownDescription: "Retrieves information about an EVPN Zone in Proxmox SDN. The EVPN zone creates a routable Layer 3 network, capable of " + + "spanning across multiple clusters.", + Attributes: genericDataSourceAttributesWith(map[string]schema.Attribute{ + "advertise_subnets": schema.BoolAttribute{ + Description: "Enable subnet advertisement for EVPN.", + Computed: true, + }, + "controller": schema.StringAttribute{ + Description: "EVPN controller address.", + Computed: true, + }, + "disable_arp_nd_suppression": schema.BoolAttribute{ + Description: "Disable ARP/ND suppression for EVPN.", + Computed: true, + }, + "exit_nodes": schema.SetAttribute{ + CustomType: stringset.Type{ + SetType: types.SetType{ + ElemType: types.StringType, + }, + }, + Description: "List of exit nodes for EVPN.", + ElementType: types.StringType, + Computed: true, + }, + "exit_nodes_local_routing": schema.BoolAttribute{ + Description: "Enable local routing for EVPN exit nodes.", + Computed: true, + }, + "primary_exit_node": schema.StringAttribute{ + Description: "Primary exit node for EVPN.", + Computed: true, + }, + "rt_import": schema.StringAttribute{ + Description: "Route target import for EVPN.", + MarkdownDescription: "Route target import for EVPN. Must be in the format ':' (e.g., '65000:65000').", + Computed: true, + }, + "vrf_vxlan": schema.Int64Attribute{ + Description: "VRF VXLAN-ID used for dedicated routing interconnect between VNets. It must be different " + + "than the VXLAN-ID of the VNets.", + Computed: true, + }, + }), + } +} + +func (d *EVPNDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + d.generic.Metadata(ctx, req, resp) +} + +func (d *EVPNDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + d.generic.Configure(ctx, req, resp) +} + +func (d *EVPNDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + d.generic.Read(ctx, req, resp) +} diff --git a/fwprovider/cluster/sdn/zone/datasource_generic.go b/fwprovider/cluster/sdn/zone/datasource_generic.go new file mode 100644 index 00000000..3547ed87 --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_generic.go @@ -0,0 +1,164 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone + +import ( + "context" + "errors" + "fmt" + "maps" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/bpg/terraform-provider-proxmox/fwprovider/config" + "github.com/bpg/terraform-provider-proxmox/fwprovider/types/stringset" + "github.com/bpg/terraform-provider-proxmox/proxmox/api" + "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/sdn/zones" +) + +type zoneDataSourceConfig struct { + typeNameSuffix string + zoneType string + modelFunc func() zoneModel +} + +type genericZoneDataSource struct { + client *zones.Client + config zoneDataSourceConfig +} + +func newGenericZoneDataSource(cfg zoneDataSourceConfig) *genericZoneDataSource { + return &genericZoneDataSource{config: cfg} +} + +func (d *genericZoneDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + d.config.typeNameSuffix +} + +func (d *genericZoneDataSource) Configure( + _ context.Context, + req datasource.ConfigureRequest, + resp *datasource.ConfigureResponse, +) { + if req.ProviderData == nil { + return + } + + cfg, ok := req.ProviderData.(config.DataSource) + if !ok { + resp.Diagnostics.AddError( + "Unexpected DataSource Configure Type", + fmt.Sprintf( + "Expected config.DataSource, got: %T", + req.ProviderData, + ), + ) + + return + } + + d.client = cfg.Client.Cluster().SDNZones() +} + +func genericDataSourceAttributesWith(extraAttributes map[string]schema.Attribute) map[string]schema.Attribute { + // Start with generic attributes as the base + result := map[string]schema.Attribute{ + "dns": schema.StringAttribute{ + Computed: true, + Description: "DNS API server address.", + }, + "dns_zone": schema.StringAttribute{ + Computed: true, + Description: "DNS domain name. The DNS zone must already exist on the DNS server.", + MarkdownDescription: "DNS domain name. Used to register hostnames, such as `.`. " + + "The DNS zone must already exist on the DNS server.", + }, + "id": schema.StringAttribute{ + Description: "The unique identifier of the SDN zone.", + Required: true, + }, + "ipam": schema.StringAttribute{ + Computed: true, + Description: "IP Address Management system.", + }, + "mtu": schema.Int64Attribute{ + Computed: true, + Description: "MTU value for the zone.", + }, + "nodes": schema.SetAttribute{ + CustomType: stringset.Type{ + SetType: types.SetType{ + ElemType: types.StringType, + }, + }, + Description: "The Proxmox nodes which the zone and associated VNets are deployed on", + ElementType: types.StringType, + Computed: true, + }, + "reverse_dns": schema.StringAttribute{ + Computed: true, + Description: "Reverse DNS API server address.", + }, + } + + // Add extra attributes, allowing them to override generic ones if needed + if extraAttributes != nil { + maps.Copy(result, extraAttributes) + } + + return result +} + +func (d *genericZoneDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + state := d.config.modelFunc() + resp.Diagnostics.Append(req.Config.Get(ctx, state)...) + + if resp.Diagnostics.HasError() { + return + } + + zone, err := d.client.GetZone(ctx, state.getID()) + if err != nil { + if errors.Is(err, api.ErrResourceDoesNotExist) { + resp.Diagnostics.AddError( + "SDN Zone Not Found", + fmt.Sprintf("SDN zone with ID '%s' was not found", state.getID()), + ) + return + } + + resp.Diagnostics.AddError( + "Unable to Read SDN Zone", + err.Error(), + ) + + return + } + + // Verify the zone type matches what this datasource expects + if zone.Type != nil && *zone.Type != d.config.zoneType { + resp.Diagnostics.AddError( + "SDN Zone Type Mismatch", + fmt.Sprintf( + "Expected zone type '%s' but found '%s' for zone '%s'", + d.config.zoneType, + *zone.Type, + zone.ID, + ), + ) + return + } + + readModel := d.config.modelFunc() + diags := &diag.Diagnostics{} + readModel.importFromAPI(zone.ID, zone, diags) + resp.Diagnostics.Append(*diags...) + resp.Diagnostics.Append(resp.State.Set(ctx, readModel)...) +} diff --git a/fwprovider/cluster/sdn/zone/datasource_qinq.go b/fwprovider/cluster/sdn/zone/datasource_qinq.go new file mode 100644 index 00000000..2060e573 --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_qinq.go @@ -0,0 +1,74 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + + "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/sdn/zones" +) + +var ( + _ datasource.DataSource = &QinQDataSource{} + _ datasource.DataSourceWithConfigure = &QinQDataSource{} +) + +type QinQDataSource struct { + generic *genericZoneDataSource +} + +func NewQinQDataSource() datasource.DataSource { + return &QinQDataSource{ + generic: newGenericZoneDataSource(zoneDataSourceConfig{ + typeNameSuffix: "_sdn_zone_qinq", + zoneType: zones.TypeQinQ, + modelFunc: func() zoneModel { return &qinqModel{} }, + }), + } +} + +func (d *QinQDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Retrieves information about a QinQ Zone in Proxmox SDN.", + MarkdownDescription: "Retrieves information about a QinQ Zone in Proxmox SDN. QinQ also known as VLAN stacking, that uses multiple layers of " + + "VLAN tags for isolation. The QinQ zone defines the outer VLAN tag (the Service VLAN) whereas the inner " + + "VLAN tag is defined by the VNet. Your physical network switches must support stacked VLANs for this " + + "configuration. Due to the double stacking of tags, you need 4 more bytes for QinQ VLANs. " + + "For example, you must reduce the MTU to 1496 if you physical interface MTU is 1500.", + Attributes: genericDataSourceAttributesWith(map[string]schema.Attribute{ + "bridge": schema.StringAttribute{ + Description: "A local, VLAN-aware bridge that is already configured on each local node", + Computed: true, + }, + "service_vlan": schema.Int64Attribute{ + Description: "Service VLAN tag for QinQ.", + MarkdownDescription: "Service VLAN tag for QinQ. The tag must be between `1` and `4094`.", + Computed: true, + }, + "service_vlan_protocol": schema.StringAttribute{ + Description: "Service VLAN protocol for QinQ.", + MarkdownDescription: "Service VLAN protocol for QinQ. The protocol must be `802.1ad` or `802.1q`.", + Computed: true, + }, + }), + } +} + +func (d *QinQDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + d.generic.Metadata(ctx, req, resp) +} + +func (d *QinQDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + d.generic.Configure(ctx, req, resp) +} + +func (d *QinQDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + d.generic.Read(ctx, req, resp) +} diff --git a/fwprovider/cluster/sdn/zone/datasource_simple.go b/fwprovider/cluster/sdn/zone/datasource_simple.go new file mode 100644 index 00000000..04a718c3 --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_simple.go @@ -0,0 +1,57 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + + "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/sdn/zones" +) + +var ( + _ datasource.DataSource = &SimpleDataSource{} + _ datasource.DataSourceWithConfigure = &SimpleDataSource{} +) + +type SimpleDataSource struct { + generic *genericZoneDataSource +} + +func NewSimpleDataSource() datasource.DataSource { + return &SimpleDataSource{ + generic: newGenericZoneDataSource(zoneDataSourceConfig{ + typeNameSuffix: "_sdn_zone_simple", + zoneType: zones.TypeSimple, + modelFunc: func() zoneModel { return &simpleModel{} }, + }), + } +} + +func (d *SimpleDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Retrieves information about a Simple Zone in Proxmox SDN.", + MarkdownDescription: "Retrieves information about a Simple Zone in Proxmox SDN. It will create an isolated VNet bridge. " + + "This bridge is not linked to a physical interface, and VM traffic is only local on each the node. " + + "It can be used in NAT or routed setups.", + Attributes: genericDataSourceAttributesWith(nil), + } +} + +func (d *SimpleDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + d.generic.Metadata(ctx, req, resp) +} + +func (d *SimpleDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + d.generic.Configure(ctx, req, resp) +} + +func (d *SimpleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + d.generic.Read(ctx, req, resp) +} diff --git a/fwprovider/cluster/sdn/zone/datasource_vlan.go b/fwprovider/cluster/sdn/zone/datasource_vlan.go new file mode 100644 index 00000000..7cb466f9 --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_vlan.go @@ -0,0 +1,64 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + + "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/sdn/zones" +) + +var ( + _ datasource.DataSource = &VLANDataSource{} + _ datasource.DataSourceWithConfigure = &VLANDataSource{} +) + +type VLANDataSource struct { + generic *genericZoneDataSource +} + +func NewVLANDataSource() datasource.DataSource { + return &VLANDataSource{ + generic: newGenericZoneDataSource(zoneDataSourceConfig{ + typeNameSuffix: "_sdn_zone_vlan", + zoneType: zones.TypeVLAN, + modelFunc: func() zoneModel { return &vlanModel{} }, + }), + } +} + +func (d *VLANDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Retrieves information about a VLAN Zone in Proxmox SDN.", + MarkdownDescription: "Retrieves information about a VLAN Zone in Proxmox SDN. It uses an existing local Linux or OVS bridge to connect to the " + + "node's physical interface. It uses VLAN tagging defined in the VNet to isolate the network segments. " + + "This allows connectivity of VMs between different nodes.", + Attributes: genericDataSourceAttributesWith(map[string]schema.Attribute{ + "bridge": schema.StringAttribute{ + Description: "Bridge interface for VLAN.", + MarkdownDescription: "The local bridge or OVS switch, already configured on _each_ node that allows " + + "node-to-node connection.", + Computed: true, + }, + }), + } +} + +func (d *VLANDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + d.generic.Metadata(ctx, req, resp) +} + +func (d *VLANDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + d.generic.Configure(ctx, req, resp) +} + +func (d *VLANDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + d.generic.Read(ctx, req, resp) +} diff --git a/fwprovider/cluster/sdn/zone/datasource_vxlan.go b/fwprovider/cluster/sdn/zone/datasource_vxlan.go new file mode 100644 index 00000000..5c8d6b3c --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_vxlan.go @@ -0,0 +1,75 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/bpg/terraform-provider-proxmox/fwprovider/types/stringset" + "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/sdn/zones" +) + +var ( + _ datasource.DataSource = &VXLANDataSource{} + _ datasource.DataSourceWithConfigure = &VXLANDataSource{} +) + +type VXLANDataSource struct { + generic *genericZoneDataSource +} + +func NewVXLANDataSource() datasource.DataSource { + return &VXLANDataSource{ + generic: newGenericZoneDataSource(zoneDataSourceConfig{ + typeNameSuffix: "_sdn_zone_vxlan", + zoneType: zones.TypeVXLAN, + modelFunc: func() zoneModel { return &vxlanModel{} }, + }), + } +} + +func (d *VXLANDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Retrieves information about a VXLAN Zone in Proxmox SDN.", + MarkdownDescription: "Retrieves information about a VXLAN Zone in Proxmox SDN. It establishes a tunnel (overlay) on top of an existing network " + + "(underlay). This encapsulates layer 2 Ethernet frames within layer 4 UDP datagrams using the default " + + "destination port 4789. You have to configure the underlay network yourself to enable UDP connectivity " + + "between all peers. Because VXLAN encapsulation uses 50 bytes, the MTU needs to be 50 bytes lower than the " + + "outgoing physical interface.", + Attributes: genericDataSourceAttributesWith(map[string]schema.Attribute{ + "peers": schema.SetAttribute{ + CustomType: stringset.Type{ + SetType: types.SetType{ + ElemType: types.StringType, + }, + }, + Description: "A list of IP addresses of each node in the VXLAN zone.", + MarkdownDescription: "A list of IP addresses of each node in the VXLAN zone. " + + "This can be external nodes reachable at this IP address. All nodes in the cluster need to be " + + "mentioned here", + ElementType: types.StringType, + Computed: true, + }, + }), + } +} + +func (d *VXLANDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + d.generic.Metadata(ctx, req, resp) +} + +func (d *VXLANDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + d.generic.Configure(ctx, req, resp) +} + +func (d *VXLANDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + d.generic.Read(ctx, req, resp) +} diff --git a/fwprovider/cluster/sdn/zone/datasource_zones.go b/fwprovider/cluster/sdn/zone/datasource_zones.go new file mode 100644 index 00000000..c82707c1 --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_zones.go @@ -0,0 +1,279 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/bpg/terraform-provider-proxmox/fwprovider/config" + "github.com/bpg/terraform-provider-proxmox/fwprovider/types/stringset" + "github.com/bpg/terraform-provider-proxmox/proxmox/cluster/sdn/zones" +) + +// Ensure the implementation satisfies the required interfaces. +var ( + _ datasource.DataSource = &zonesDataSource{} + _ datasource.DataSourceWithConfigure = &zonesDataSource{} +) + +// zonesDataSource is the data source implementation for SDN zones. +type zonesDataSource struct { + client *zones.Client +} + +// zonesDataSourceModel represents the data source model for listing zones. +type zonesDataSourceModel struct { + Type types.String `tfsdk:"type"` + Zones types.List `tfsdk:"zones"` +} + +// zoneDataModel represents individual zone data in the list. +type zoneDataModel struct { + ID types.String `tfsdk:"id"` + Type types.String `tfsdk:"type"` + IPAM types.String `tfsdk:"ipam"` + DNS types.String `tfsdk:"dns"` + ReverseDNS types.String `tfsdk:"reverse_dns"` + DNSZone types.String `tfsdk:"dns_zone"` + Nodes stringset.Value `tfsdk:"nodes"` + MTU types.Int64 `tfsdk:"mtu"` + Bridge types.String `tfsdk:"bridge"` + ServiceVLAN types.Int64 `tfsdk:"service_vlan"` + ServiceVLANProtocol types.String `tfsdk:"service_vlan_protocol"` + Peers stringset.Value `tfsdk:"peers"` + AdvertiseSubnets types.Bool `tfsdk:"advertise_subnets"` + Controller types.String `tfsdk:"controller"` + DisableARPNDSuppression types.Bool `tfsdk:"disable_arp_nd_suppression"` + ExitNodes stringset.Value `tfsdk:"exit_nodes"` + ExitNodesLocalRouting types.Bool `tfsdk:"exit_nodes_local_routing"` + PrimaryExitNode types.String `tfsdk:"primary_exit_node"` + RouteTargetImport types.String `tfsdk:"rt_import"` + VRFVXLANID types.Int64 `tfsdk:"vrf_vxlan"` +} + +// Configure adds the provider-configured client to the data source. +func (d *zonesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + cfg, ok := req.ProviderData.(config.DataSource) + if !ok { + resp.Diagnostics.AddError( + "Unexpected DataSource Configure Type", + fmt.Sprintf("Expected config.DataSource, got: %T", req.ProviderData), + ) + + return + } + + d.client = cfg.Client.Cluster().SDNZones() +} + +// Metadata returns the data source type name. +func (d *zonesDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_sdn_zones" +} + +// Schema defines the schema for the data source. +func (d *zonesDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Retrieves information about all SDN Zones in Proxmox.", + MarkdownDescription: "Retrieves information about all SDN Zones in Proxmox. " + + "This data source can optionally filter zones by type.", + Attributes: map[string]schema.Attribute{ + "type": schema.StringAttribute{ + Description: "Filter zones by type (simple, vlan, qinq, vxlan, evpn).", + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("simple", "vlan", "qinq", "vxlan", "evpn"), + }, + }, + "zones": schema.ListAttribute{ + Description: "List of SDN zones.", + Computed: true, + ElementType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "id": types.StringType, + "type": types.StringType, + "ipam": types.StringType, + "dns": types.StringType, + "reverse_dns": types.StringType, + "dns_zone": types.StringType, + "nodes": types.SetType{ + ElemType: types.StringType, + }, + "mtu": types.Int64Type, + "bridge": types.StringType, + "service_vlan": types.Int64Type, + "service_vlan_protocol": types.StringType, + "peers": types.SetType{ + ElemType: types.StringType, + }, + "advertise_subnets": types.BoolType, + "controller": types.StringType, + "disable_arp_nd_suppression": types.BoolType, + "exit_nodes": types.SetType{ + ElemType: types.StringType, + }, + "exit_nodes_local_routing": types.BoolType, + "primary_exit_node": types.StringType, + "rt_import": types.StringType, + "vrf_vxlan": types.Int64Type, + }, + }, + }, + }, + } +} + +// Read fetches all SDN zones from the Proxmox VE API. +func (d *zonesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data zonesDataSourceModel + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + zonesList, err := d.client.GetZones(ctx) + if err != nil { + resp.Diagnostics.AddError( + "Unable to Read SDN Zones", + err.Error(), + ) + return + } + + filteredZones := zonesList + if !data.Type.IsNull() && !data.Type.IsUnknown() { + filterType := data.Type.ValueString() + filteredZones = make([]zones.ZoneData, 0) + for _, zone := range zonesList { + if zone.Type != nil && *zone.Type == filterType { + filteredZones = append(filteredZones, zone) + } + } + } + + // Convert zones to list elements + zoneElements := make([]attr.Value, len(filteredZones)) + for i, zone := range filteredZones { + diags := &resp.Diagnostics + + zoneData := zoneDataModel{ + ID: types.StringValue(zone.ID), + Type: types.StringPointerValue(zone.Type), + IPAM: types.StringPointerValue(zone.IPAM), + DNS: types.StringPointerValue(zone.DNS), + ReverseDNS: types.StringPointerValue(zone.ReverseDNS), + DNSZone: types.StringPointerValue(zone.DNSZone), + Nodes: stringset.NewValueString(zone.Nodes, diags, stringset.WithSeparator(",")), + MTU: types.Int64PointerValue(zone.MTU), + Bridge: types.StringPointerValue(zone.Bridge), + ServiceVLAN: types.Int64PointerValue(zone.ServiceVLAN), + ServiceVLANProtocol: types.StringPointerValue(zone.ServiceVLANProtocol), + Peers: stringset.NewValueString(zone.Peers, diags, stringset.WithSeparator(",")), + AdvertiseSubnets: types.BoolPointerValue(zone.AdvertiseSubnets.PointerBool()), + Controller: types.StringPointerValue(zone.Controller), + DisableARPNDSuppression: types.BoolPointerValue(zone.DisableARPNDSuppression.PointerBool()), + ExitNodes: stringset.NewValueString(zone.ExitNodes, diags, stringset.WithSeparator(",")), + ExitNodesLocalRouting: types.BoolPointerValue(zone.ExitNodesLocalRouting.PointerBool()), + PrimaryExitNode: types.StringPointerValue(zone.ExitNodesPrimary), + RouteTargetImport: types.StringPointerValue(zone.RouteTargetImport), + VRFVXLANID: types.Int64PointerValue(zone.VRFVXLANID), + } + + objValue, objDiag := types.ObjectValueFrom(ctx, map[string]attr.Type{ + "id": types.StringType, + "type": types.StringType, + "ipam": types.StringType, + "dns": types.StringType, + "reverse_dns": types.StringType, + "dns_zone": types.StringType, + "nodes": types.SetType{ + ElemType: types.StringType, + }, + "mtu": types.Int64Type, + "bridge": types.StringType, + "service_vlan": types.Int64Type, + "service_vlan_protocol": types.StringType, + "peers": types.SetType{ + ElemType: types.StringType, + }, + "advertise_subnets": types.BoolType, + "controller": types.StringType, + "disable_arp_nd_suppression": types.BoolType, + "exit_nodes": types.SetType{ + ElemType: types.StringType, + }, + "exit_nodes_local_routing": types.BoolType, + "primary_exit_node": types.StringType, + "rt_import": types.StringType, + "vrf_vxlan": types.Int64Type, + }, zoneData) + resp.Diagnostics.Append(objDiag...) + + if resp.Diagnostics.HasError() { + return + } + + zoneElements[i] = objValue + } + + listValue, listDiag := types.ListValue(types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "id": types.StringType, + "type": types.StringType, + "ipam": types.StringType, + "dns": types.StringType, + "reverse_dns": types.StringType, + "dns_zone": types.StringType, + "nodes": types.SetType{ + ElemType: types.StringType, + }, + "mtu": types.Int64Type, + "bridge": types.StringType, + "service_vlan": types.Int64Type, + "service_vlan_protocol": types.StringType, + "peers": types.SetType{ + ElemType: types.StringType, + }, + "advertise_subnets": types.BoolType, + "controller": types.StringType, + "disable_arp_nd_suppression": types.BoolType, + "exit_nodes": types.SetType{ + ElemType: types.StringType, + }, + "exit_nodes_local_routing": types.BoolType, + "primary_exit_node": types.StringType, + "rt_import": types.StringType, + "vrf_vxlan": types.Int64Type, + }, + }, zoneElements) + resp.Diagnostics.Append(listDiag...) + + if resp.Diagnostics.HasError() { + return + } + + data.Zones = listValue + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +// NewZonesDataSource returns a new data source for SDN zones. +func NewZonesDataSource() datasource.DataSource { + return &zonesDataSource{} +} diff --git a/fwprovider/cluster/sdn/zone/datasource_zones_test.go b/fwprovider/cluster/sdn/zone/datasource_zones_test.go new file mode 100644 index 00000000..6c2140fb --- /dev/null +++ b/fwprovider/cluster/sdn/zone/datasource_zones_test.go @@ -0,0 +1,259 @@ +//go:build acceptance || all + +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package zone_test + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + + "github.com/bpg/terraform-provider-proxmox/fwprovider/test" +) + +func TestAccDataSourceSDNZoneSimple(t *testing.T) { + t.Parallel() + + te := test.InitEnvironment(t) + + tests := []struct { + name string + steps []resource.TestStep + }{ + {"create simple zone and read with datasource", []resource.TestStep{{ + Config: te.RenderConfig(` + resource "proxmox_virtual_environment_sdn_zone_simple" "test" { + id = "dstest1" + nodes = ["pve"] + mtu = 1500 + } + + data "proxmox_virtual_environment_sdn_zone_simple" "test" { + id = proxmox_virtual_environment_sdn_zone_simple.test.id + } + `), + Check: resource.ComposeTestCheckFunc( + test.ResourceAttributes("data.proxmox_virtual_environment_sdn_zone_simple.test", map[string]string{ + "id": "dstest1", + "mtu": "1500", + }), + test.ResourceAttributes("data.proxmox_virtual_environment_sdn_zone_simple.test", map[string]string{ + "nodes.#": "1", + "nodes.0": "pve", + }), + ), + }}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: te.AccProviders, + Steps: tt.steps, + }) + }) + } +} + +func TestAccDataSourceSDNZoneVLAN(t *testing.T) { + t.Parallel() + + te := test.InitEnvironment(t) + + tests := []struct { + name string + steps []resource.TestStep + }{ + {"create VLAN zone and read with datasource", []resource.TestStep{{ + Config: te.RenderConfig(` + resource "proxmox_virtual_environment_sdn_zone_vlan" "test" { + id = "dstest2" + nodes = ["pve"] + bridge = "vmbr0" + mtu = 1496 + } + + data "proxmox_virtual_environment_sdn_zone_vlan" "test" { + id = proxmox_virtual_environment_sdn_zone_vlan.test.id + } + `), + Check: resource.ComposeTestCheckFunc( + test.ResourceAttributes("data.proxmox_virtual_environment_sdn_zone_vlan.test", map[string]string{ + "id": "dstest2", + "bridge": "vmbr0", + "mtu": "1496", + "nodes.#": "1", + "nodes.0": "pve", + }), + ), + }}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: te.AccProviders, + Steps: tt.steps, + }) + }) + } +} + +func TestAccDataSourceSDNZoneQinQ(t *testing.T) { + t.Parallel() + + te := test.InitEnvironment(t) + + tests := []struct { + name string + steps []resource.TestStep + }{ + {"create QinQ zone and read with datasource", []resource.TestStep{{ + Config: te.RenderConfig(` + resource "proxmox_virtual_environment_sdn_zone_qinq" "test" { + id = "dstest3" + nodes = ["pve"] + bridge = "vmbr0" + service_vlan = 100 + service_vlan_protocol = "802.1ad" + mtu = 1492 + } + + data "proxmox_virtual_environment_sdn_zone_qinq" "test" { + id = proxmox_virtual_environment_sdn_zone_qinq.test.id + } + `), + Check: resource.ComposeTestCheckFunc( + test.ResourceAttributes("data.proxmox_virtual_environment_sdn_zone_qinq.test", map[string]string{ + "id": "dstest3", + "bridge": "vmbr0", + "service_vlan": "100", + "service_vlan_protocol": "802.1ad", + "mtu": "1492", + "nodes.#": "1", + "nodes.0": "pve", + }), + ), + }}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: te.AccProviders, + Steps: tt.steps, + }) + }) + } +} + +func TestAccDataSourceSDNZoneVXLAN(t *testing.T) { + t.Parallel() + + te := test.InitEnvironment(t) + + tests := []struct { + name string + steps []resource.TestStep + }{ + {"create VXLAN zone and read with datasource", []resource.TestStep{{ + Config: te.RenderConfig(` + resource "proxmox_virtual_environment_sdn_zone_vxlan" "test" { + id = "dstest4" + nodes = ["pve"] + peers = ["10.0.0.1", "10.0.0.2"] + mtu = 1450 + } + + data "proxmox_virtual_environment_sdn_zone_vxlan" "test" { + id = proxmox_virtual_environment_sdn_zone_vxlan.test.id + } + `), + Check: resource.ComposeTestCheckFunc( + test.ResourceAttributes("data.proxmox_virtual_environment_sdn_zone_vxlan.test", map[string]string{ + "id": "dstest4", + "mtu": "1450", + "nodes.#": "1", + "nodes.0": "pve", + "peers.#": "2", + "peers.0": "10.0.0.1", + "peers.1": "10.0.0.2", + }), + ), + }}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: te.AccProviders, + Steps: tt.steps, + }) + }) + } +} + +func TestAccDataSourceSDNZones(t *testing.T) { + t.Parallel() + + te := test.InitEnvironment(t) + + tests := []struct { + name string + steps []resource.TestStep + }{ + {"create multiple zones and read with zones datasource", []resource.TestStep{{ + Config: te.RenderConfig(` + resource "proxmox_virtual_environment_sdn_zone_simple" "test1" { + id = "dstest6" + nodes = ["pve"] + mtu = 1500 + } + + resource "proxmox_virtual_environment_sdn_zone_vlan" "test2" { + id = "dstest7" + nodes = ["pve"] + bridge = "vmbr0" + mtu = 1496 + } + + data "proxmox_virtual_environment_sdn_zones" "all" { + depends_on = [ + proxmox_virtual_environment_sdn_zone_simple.test1, + proxmox_virtual_environment_sdn_zone_vlan.test2 + ] + } + + data "proxmox_virtual_environment_sdn_zones" "simple_only" { + type = "simple" + depends_on = [ + proxmox_virtual_environment_sdn_zone_simple.test1, + proxmox_virtual_environment_sdn_zone_vlan.test2 + ] + } + `), + Check: resource.ComposeTestCheckFunc( + // Check that all zones datasource returns multiple zones + resource.TestCheckResourceAttrSet("data.proxmox_virtual_environment_sdn_zones.all", "zones.#"), + + // Check that filtered datasource works + resource.TestCheckResourceAttr("data.proxmox_virtual_environment_sdn_zones.simple_only", "type", "simple"), + resource.TestCheckResourceAttrSet("data.proxmox_virtual_environment_sdn_zones.simple_only", "zones.#"), + ), + }}}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + ProtoV6ProviderFactories: te.AccProviders, + Steps: tt.steps, + }) + }) + } +} diff --git a/fwprovider/provider.go b/fwprovider/provider.go index 57098144..98faa4eb 100644 --- a/fwprovider/provider.go +++ b/fwprovider/provider.go @@ -533,9 +533,6 @@ func (p *proxmoxProvider) Resources(_ context.Context) []func() resource.Resourc sdnzone.NewQinQResource, sdnzone.NewVXLANResource, sdnzone.NewEVPNResource, - // - // sdn.NewSDNVnetResource, - // sdn.NewSDNSubnetResource, } } @@ -558,10 +555,13 @@ func (p *proxmoxProvider) DataSources(_ context.Context) []func() datasource.Dat hardwaremapping.NewPCIDataSource, hardwaremapping.NewUSBDataSource, metrics.NewMetricsServerDatasource, + sdnzone.NewSimpleDataSource, + sdnzone.NewVLANDataSource, + sdnzone.NewQinQDataSource, + sdnzone.NewVXLANDataSource, + sdnzone.NewEVPNDataSource, + sdnzone.NewZonesDataSource, vm.NewDataSource, - // sdn.NewSDNZoneDataSource, - // sdn.NewSDNVnetDataSource, - // sdn.NewSDNSubnetDataSource, } } diff --git a/main.go b/main.go index ed774222..7ab7d54a 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,12 @@ import ( //go:generate cp ./build/docs-gen/data-sources/virtual_environment_hardware_mappings.md ./docs/data-sources/ //go:generate cp ./build/docs-gen/data-sources/virtual_environment_haresource.md ./docs/data-sources/ //go:generate cp ./build/docs-gen/data-sources/virtual_environment_haresources.md ./docs/data-sources/ +//go:generate cp ./build/docs-gen/data-sources/virtual_environment_sdn_zones.md ./docs/data-sources/ +//go:generate cp ./build/docs-gen/data-sources/virtual_environment_sdn_zone_simple.md ./docs/data-sources/ +//go:generate cp ./build/docs-gen/data-sources/virtual_environment_sdn_zone_vlan.md ./docs/data-sources/ +//go:generate cp ./build/docs-gen/data-sources/virtual_environment_sdn_zone_qinq.md ./docs/data-sources/ +//go:generate cp ./build/docs-gen/data-sources/virtual_environment_sdn_zone_vxlan.md ./docs/data-sources/ +//go:generate cp ./build/docs-gen/data-sources/virtual_environment_sdn_zone_evpn.md ./docs/data-sources/ //go:generate cp ./build/docs-gen/data-sources/virtual_environment_version.md ./docs/data-sources/ //go:generate cp ./build/docs-gen/data-sources/virtual_environment_vm2.md ./docs/data-sources/ //go:generate cp ./build/docs-gen/data-sources/virtual_environment_metrics_server.md ./docs/data-sources/ diff --git a/proxmox_virtual_environment_sdn_zone_evpn/data-source.tf b/proxmox_virtual_environment_sdn_zone_evpn/data-source.tf new file mode 100644 index 00000000..2b70ab68 --- /dev/null +++ b/proxmox_virtual_environment_sdn_zone_evpn/data-source.tf @@ -0,0 +1,23 @@ +data "proxmox_virtual_environment_sdn_zone_evpn" "example" { + id = "evpn1" +} + +output "data_proxmox_virtual_environment_sdn_zone_evpn" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_evpn.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_evpn.example.nodes + controller = data.proxmox_virtual_environment_sdn_zone_evpn.example.controller + vrf_vxlan = data.proxmox_virtual_environment_sdn_zone_evpn.example.vrf_vxlan + advertise_subnets = data.proxmox_virtual_environment_sdn_zone_evpn.example.advertise_subnets + disable_arp_nd_suppression = data.proxmox_virtual_environment_sdn_zone_evpn.example.disable_arp_nd_suppression + exit_nodes = data.proxmox_virtual_environment_sdn_zone_evpn.example.exit_nodes + exit_nodes_local_routing = data.proxmox_virtual_environment_sdn_zone_evpn.example.exit_nodes_local_routing + primary_exit_node = data.proxmox_virtual_environment_sdn_zone_evpn.example.primary_exit_node + rt_import = data.proxmox_virtual_environment_sdn_zone_evpn.example.rt_import + mtu = data.proxmox_virtual_environment_sdn_zone_evpn.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_evpn.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_evpn.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_evpn.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_evpn.example.reverse_dns + } +} diff --git a/proxmox_virtual_environment_sdn_zone_qinq/data-source.tf b/proxmox_virtual_environment_sdn_zone_qinq/data-source.tf new file mode 100644 index 00000000..26f448c1 --- /dev/null +++ b/proxmox_virtual_environment_sdn_zone_qinq/data-source.tf @@ -0,0 +1,18 @@ +data "proxmox_virtual_environment_sdn_zone_qinq" "example" { + id = "qinq1" +} + +output "data_proxmox_virtual_environment_sdn_zone_qinq" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_qinq.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_qinq.example.nodes + bridge = data.proxmox_virtual_environment_sdn_zone_qinq.example.bridge + service_vlan = data.proxmox_virtual_environment_sdn_zone_qinq.example.service_vlan + service_vlan_protocol = data.proxmox_virtual_environment_sdn_zone_qinq.example.service_vlan_protocol + mtu = data.proxmox_virtual_environment_sdn_zone_qinq.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_qinq.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_qinq.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_qinq.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_qinq.example.reverse_dns + } +} diff --git a/proxmox_virtual_environment_sdn_zone_simple/data-source.tf b/proxmox_virtual_environment_sdn_zone_simple/data-source.tf new file mode 100644 index 00000000..452cb88f --- /dev/null +++ b/proxmox_virtual_environment_sdn_zone_simple/data-source.tf @@ -0,0 +1,15 @@ +data "proxmox_virtual_environment_sdn_zone_simple" "example" { + id = "simple1" +} + +output "data_proxmox_virtual_environment_sdn_zone_simple" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_simple.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_simple.example.nodes + mtu = data.proxmox_virtual_environment_sdn_zone_simple.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_simple.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_simple.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_simple.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_simple.example.reverse_dns + } +} diff --git a/proxmox_virtual_environment_sdn_zone_vlan/data-source.tf b/proxmox_virtual_environment_sdn_zone_vlan/data-source.tf new file mode 100644 index 00000000..a1f0f9e4 --- /dev/null +++ b/proxmox_virtual_environment_sdn_zone_vlan/data-source.tf @@ -0,0 +1,16 @@ +data "proxmox_virtual_environment_sdn_zone_vlan" "example" { + id = "vlan1" +} + +output "data_proxmox_virtual_environment_sdn_zone_vlan" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_vlan.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_vlan.example.nodes + bridge = data.proxmox_virtual_environment_sdn_zone_vlan.example.bridge + mtu = data.proxmox_virtual_environment_sdn_zone_vlan.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_vlan.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_vlan.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_vlan.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_vlan.example.reverse_dns + } +} diff --git a/proxmox_virtual_environment_sdn_zone_vxlan/data-source.tf b/proxmox_virtual_environment_sdn_zone_vxlan/data-source.tf new file mode 100644 index 00000000..2ca035e4 --- /dev/null +++ b/proxmox_virtual_environment_sdn_zone_vxlan/data-source.tf @@ -0,0 +1,16 @@ +data "proxmox_virtual_environment_sdn_zone_vxlan" "example" { + id = "vxlan1" +} + +output "data_proxmox_virtual_environment_sdn_zone_vxlan" { + value = { + id = data.proxmox_virtual_environment_sdn_zone_vxlan.example.id + nodes = data.proxmox_virtual_environment_sdn_zone_vxlan.example.nodes + peers = data.proxmox_virtual_environment_sdn_zone_vxlan.example.peers + mtu = data.proxmox_virtual_environment_sdn_zone_vxlan.example.mtu + dns = data.proxmox_virtual_environment_sdn_zone_vxlan.example.dns + dns_zone = data.proxmox_virtual_environment_sdn_zone_vxlan.example.dns_zone + ipam = data.proxmox_virtual_environment_sdn_zone_vxlan.example.ipam + reverse_dns = data.proxmox_virtual_environment_sdn_zone_vxlan.example.reverse_dns + } +} diff --git a/proxmox_virtual_environment_sdn_zones/data-source.tf b/proxmox_virtual_environment_sdn_zones/data-source.tf new file mode 100644 index 00000000..a84abd4c --- /dev/null +++ b/proxmox_virtual_environment_sdn_zones/data-source.tf @@ -0,0 +1,25 @@ +# List all SDN zones +data "proxmox_virtual_environment_sdn_zones" "all" {} + +# List only EVPN zones +data "proxmox_virtual_environment_sdn_zones" "evpn_only" { + type = "evpn" +} + +# List only Simple zones +data "proxmox_virtual_environment_sdn_zones" "simple_only" { + type = "simple" +} + +output "data_proxmox_virtual_environment_sdn_zones_all" { + value = { + zones = data.proxmox_virtual_environment_sdn_zones.all.zones + } +} + +output "data_proxmox_virtual_environment_sdn_zones_filtered" { + value = { + evpn_zones = data.proxmox_virtual_environment_sdn_zones.evpn_only.zones + simple_zones = data.proxmox_virtual_environment_sdn_zones.simple_only.zones + } +}