From b68cfe3ea2650428ab82220768de54ac5ed53e59 Mon Sep 17 00:00:00 2001 From: danischm Date: Fri, 15 Sep 2023 18:10:56 +0200 Subject: [PATCH] Update bgp address family resources --- CHANGELOG.md | 10 +++ docs/data-sources/bgp_address_family_ipv4.md | 2 + .../bgp_address_family_ipv4_vrf.md | 6 +- docs/data-sources/bgp_address_family_ipv6.md | 2 + .../bgp_address_family_ipv6_vrf.md | 6 +- docs/guides/changelog.md | 10 +++ docs/resources/bgp_address_family_ipv4.md | 8 +- docs/resources/bgp_address_family_ipv4_vrf.md | 14 ++-- docs/resources/bgp_address_family_ipv6.md | 10 ++- docs/resources/bgp_address_family_ipv6_vrf.md | 16 ++-- .../iosxe_bgp_address_family_ipv4/resource.tf | 6 +- .../resource.tf | 8 +- .../iosxe_bgp_address_family_ipv6/resource.tf | 8 +- .../resource.tf | 10 +-- gen/definitions/bgp_address_family_ipv4.yaml | 6 ++ .../bgp_address_family_ipv4_vrf.yaml | 6 +- gen/definitions/bgp_address_family_ipv6.yaml | 8 +- .../bgp_address_family_ipv6_vrf.yaml | 8 +- ...ta_source_iosxe_bgp_address_family_ipv4.go | 8 ++ ...urce_iosxe_bgp_address_family_ipv4_test.go | 4 + ...ource_iosxe_bgp_address_family_ipv4_vrf.go | 6 +- ..._iosxe_bgp_address_family_ipv4_vrf_test.go | 12 +-- ...ta_source_iosxe_bgp_address_family_ipv6.go | 8 ++ ...urce_iosxe_bgp_address_family_ipv6_test.go | 8 +- ...ource_iosxe_bgp_address_family_ipv6_vrf.go | 6 +- ..._iosxe_bgp_address_family_ipv6_vrf_test.go | 16 ++-- .../model_iosxe_bgp_address_family_ipv4.go | 80 ++++++++++++++++--- ...model_iosxe_bgp_address_family_ipv4_vrf.go | 66 +++++++-------- .../model_iosxe_bgp_address_family_ipv6.go | 76 +++++++++++++++--- ...model_iosxe_bgp_address_family_ipv6_vrf.go | 64 +++++++-------- .../resource_iosxe_bgp_address_family_ipv4.go | 8 ++ ...urce_iosxe_bgp_address_family_ipv4_test.go | 4 + ...ource_iosxe_bgp_address_family_ipv4_vrf.go | 6 +- ..._iosxe_bgp_address_family_ipv4_vrf_test.go | 12 +-- .../resource_iosxe_bgp_address_family_ipv6.go | 8 ++ ...urce_iosxe_bgp_address_family_ipv6_test.go | 8 +- ...ource_iosxe_bgp_address_family_ipv6_vrf.go | 6 +- ..._iosxe_bgp_address_family_ipv6_vrf_test.go | 16 ++-- templates/guides/changelog.md.tmpl | 10 +++ 39 files changed, 395 insertions(+), 181 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ec7037..b580f587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ - Add `spanning_tree_link_type` and `ip_dhcp_snooping_trust` attributes to `iosxe_interface_port_channel` resource and data source - Add `compress_config`, `sequence_numbers` and `call_home` attributes to `iosxe_service` resource and data source - Add `hosts`, `system_shutdown` and `enable_traps_*` attributes to `iosxe_snmp_server` resource and data source +- BREAKING CHANGE: Rename `advertise_l2vpn_evpn` attribute to `ipv4_unicast_advertise_l2vpn_evpn` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_connected` attribute to `ipv4_unicast_redistribute_connected` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_static` attribute to `ipv4_unicast_redistribute_static` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- Add `ipv4_unicast_redistribute_connected` attribute to `iosxe_bgp_address_family_ipv4` resource and data source +- Add `ipv4_unicast_redistribute_static` attribute to `iosxe_bgp_address_family_ipv4` resource and data source +- BREAKING CHANGE: Rename `advertise_l2vpn_evpn` attribute to `ipv6_unicast_advertise_l2vpn_evpn` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_connected` attribute to `ipv6_unicast_redistribute_connected` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_static` attribute to `ipv6_unicast_redistribute_static` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- Add `ipv6_unicast_redistribute_connected` attribute to `iosxe_bgp_address_family_ipv6` resource and data source +- Add `ipv6_unicast_redistribute_static` attribute to `iosxe_bgp_address_family_ipv6` resource and data source ## 0.4.0 diff --git a/docs/data-sources/bgp_address_family_ipv4.md b/docs/data-sources/bgp_address_family_ipv4.md index 0b5add7a..a972746c 100644 --- a/docs/data-sources/bgp_address_family_ipv4.md +++ b/docs/data-sources/bgp_address_family_ipv4.md @@ -36,6 +36,8 @@ data "iosxe_bgp_address_family_ipv4" "example" { - `id` (String) The path of the retrieved object. - `ipv4_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--ipv4_unicast_networks)) - `ipv4_unicast_networks_mask` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--ipv4_unicast_networks_mask)) +- `ipv4_unicast_redistribute_connected` (Boolean) Connected +- `ipv4_unicast_redistribute_static` (Boolean) Static routes ### Nested Schema for `ipv4_unicast_networks` diff --git a/docs/data-sources/bgp_address_family_ipv4_vrf.md b/docs/data-sources/bgp_address_family_ipv4_vrf.md index 562d4557..583ff5f1 100644 --- a/docs/data-sources/bgp_address_family_ipv4_vrf.md +++ b/docs/data-sources/bgp_address_family_ipv4_vrf.md @@ -41,12 +41,12 @@ data "iosxe_bgp_address_family_ipv4_vrf" "example" { Read-Only: -- `advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table +- `ipv4_unicast_advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table - `ipv4_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--vrfs--ipv4_unicast_networks)) - `ipv4_unicast_networks_mask` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--vrfs--ipv4_unicast_networks_mask)) +- `ipv4_unicast_redistribute_connected` (Boolean) Connected +- `ipv4_unicast_redistribute_static` (Boolean) Static routes - `name` (String) -- `redistribute_connected` (Boolean) Connected -- `redistribute_static` (Boolean) Static routes ### Nested Schema for `vrfs.ipv4_unicast_networks` diff --git a/docs/data-sources/bgp_address_family_ipv6.md b/docs/data-sources/bgp_address_family_ipv6.md index 1a1a594a..54e2eda2 100644 --- a/docs/data-sources/bgp_address_family_ipv6.md +++ b/docs/data-sources/bgp_address_family_ipv6.md @@ -35,6 +35,8 @@ data "iosxe_bgp_address_family_ipv6" "example" { - `id` (String) The path of the retrieved object. - `ipv6_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--ipv6_unicast_networks)) +- `ipv6_unicast_redistribute_connected` (Boolean) Connected +- `ipv6_unicast_redistribute_static` (Boolean) Static routes ### Nested Schema for `ipv6_unicast_networks` diff --git a/docs/data-sources/bgp_address_family_ipv6_vrf.md b/docs/data-sources/bgp_address_family_ipv6_vrf.md index 09277535..97a7887a 100644 --- a/docs/data-sources/bgp_address_family_ipv6_vrf.md +++ b/docs/data-sources/bgp_address_family_ipv6_vrf.md @@ -41,11 +41,11 @@ data "iosxe_bgp_address_family_ipv6_vrf" "example" { Read-Only: -- `advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table +- `ipv6_unicast_advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table - `ipv6_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--vrfs--ipv6_unicast_networks)) +- `ipv6_unicast_redistribute_connected` (Boolean) Connected +- `ipv6_unicast_redistribute_static` (Boolean) Static routes - `name` (String) -- `redistribute_connected` (Boolean) Connected -- `redistribute_static` (Boolean) Static routes ### Nested Schema for `vrfs.ipv6_unicast_networks` diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 91201bdc..ed38132b 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -14,6 +14,16 @@ description: |- - Add `spanning_tree_link_type` and `ip_dhcp_snooping_trust` attributes to `iosxe_interface_port_channel` resource and data source - Add `compress_config`, `sequence_numbers` and `call_home` attributes to `iosxe_service` resource and data source - Add `hosts`, `system_shutdown` and `enable_traps_*` attributes to `iosxe_snmp_server` resource and data source +- BREAKING CHANGE: Rename `advertise_l2vpn_evpn` attribute to `ipv4_unicast_advertise_l2vpn_evpn` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_connected` attribute to `ipv4_unicast_redistribute_connected` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_static` attribute to `ipv4_unicast_redistribute_static` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- Add `ipv4_unicast_redistribute_connected` attribute to `iosxe_bgp_address_family_ipv4` resource and data source +- Add `ipv4_unicast_redistribute_static` attribute to `iosxe_bgp_address_family_ipv4` resource and data source +- BREAKING CHANGE: Rename `advertise_l2vpn_evpn` attribute to `ipv6_unicast_advertise_l2vpn_evpn` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_connected` attribute to `ipv6_unicast_redistribute_connected` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_static` attribute to `ipv6_unicast_redistribute_static` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- Add `ipv6_unicast_redistribute_connected` attribute to `iosxe_bgp_address_family_ipv6` resource and data source +- Add `ipv6_unicast_redistribute_static` attribute to `iosxe_bgp_address_family_ipv6` resource and data source ## 0.4.0 diff --git a/docs/resources/bgp_address_family_ipv4.md b/docs/resources/bgp_address_family_ipv4.md index 780dc72e..54122c23 100644 --- a/docs/resources/bgp_address_family_ipv4.md +++ b/docs/resources/bgp_address_family_ipv4.md @@ -14,8 +14,10 @@ This resource can manage the BGP Address Family IPv4 configuration. ```terraform resource "iosxe_bgp_address_family_ipv4" "example" { - asn = "65000" - af_name = "unicast" + asn = "65000" + af_name = "unicast" + ipv4_unicast_redistribute_connected = true + ipv4_unicast_redistribute_static = true ipv4_unicast_networks_mask = [ { network = "12.0.0.0" @@ -49,6 +51,8 @@ resource "iosxe_bgp_address_family_ipv4" "example" { - `device` (String) A device name from the provider configuration. - `ipv4_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--ipv4_unicast_networks)) - `ipv4_unicast_networks_mask` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--ipv4_unicast_networks_mask)) +- `ipv4_unicast_redistribute_connected` (Boolean) Connected +- `ipv4_unicast_redistribute_static` (Boolean) Static routes ### Read-Only diff --git a/docs/resources/bgp_address_family_ipv4_vrf.md b/docs/resources/bgp_address_family_ipv4_vrf.md index b89915d7..1a7974eb 100644 --- a/docs/resources/bgp_address_family_ipv4_vrf.md +++ b/docs/resources/bgp_address_family_ipv4_vrf.md @@ -18,10 +18,10 @@ resource "iosxe_bgp_address_family_ipv4_vrf" "example" { af_name = "unicast" vrfs = [ { - name = "VRF1" - advertise_l2vpn_evpn = true - redistribute_connected = true - redistribute_static = true + name = "VRF1" + ipv4_unicast_advertise_l2vpn_evpn = true + ipv4_unicast_redistribute_connected = true + ipv4_unicast_redistribute_static = true ipv4_unicast_networks_mask = [ { network = "12.0.0.0" @@ -70,11 +70,11 @@ Required: Optional: -- `advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table +- `ipv4_unicast_advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table - `ipv4_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--vrfs--ipv4_unicast_networks)) - `ipv4_unicast_networks_mask` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--vrfs--ipv4_unicast_networks_mask)) -- `redistribute_connected` (Boolean) Connected -- `redistribute_static` (Boolean) Static routes +- `ipv4_unicast_redistribute_connected` (Boolean) Connected +- `ipv4_unicast_redistribute_static` (Boolean) Static routes ### Nested Schema for `vrfs.ipv4_unicast_networks` diff --git a/docs/resources/bgp_address_family_ipv6.md b/docs/resources/bgp_address_family_ipv6.md index 62a143b8..7a543f87 100644 --- a/docs/resources/bgp_address_family_ipv6.md +++ b/docs/resources/bgp_address_family_ipv6.md @@ -14,11 +14,13 @@ This resource can manage the BGP Address Family IPv6 configuration. ```terraform resource "iosxe_bgp_address_family_ipv6" "example" { - asn = "65000" - af_name = "unicast" + asn = "65000" + af_name = "unicast" + ipv6_unicast_redistribute_connected = true + ipv6_unicast_redistribute_static = true ipv6_unicast_networks = [ { - network = "2001:1234::0/64" + network = "2001:1234::/64" route_map = "RM1" backdoor = true } @@ -40,6 +42,8 @@ resource "iosxe_bgp_address_family_ipv6" "example" { - Choices: `all`, `attributes` - `device` (String) A device name from the provider configuration. - `ipv6_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--ipv6_unicast_networks)) +- `ipv6_unicast_redistribute_connected` (Boolean) Connected +- `ipv6_unicast_redistribute_static` (Boolean) Static routes ### Read-Only diff --git a/docs/resources/bgp_address_family_ipv6_vrf.md b/docs/resources/bgp_address_family_ipv6_vrf.md index b0fd156f..ede1c31d 100644 --- a/docs/resources/bgp_address_family_ipv6_vrf.md +++ b/docs/resources/bgp_address_family_ipv6_vrf.md @@ -18,13 +18,13 @@ resource "iosxe_bgp_address_family_ipv6_vrf" "example" { af_name = "unicast" vrfs = [ { - name = "VRF1" - advertise_l2vpn_evpn = true - redistribute_connected = true - redistribute_static = true + name = "VRF1" + ipv6_unicast_advertise_l2vpn_evpn = true + ipv6_unicast_redistribute_connected = true + ipv6_unicast_redistribute_static = true ipv6_unicast_networks = [ { - network = "2001:1234::0/64" + network = "2001:1234::/64" route_map = "RM1" backdoor = true evpn = false @@ -63,10 +63,10 @@ Required: Optional: -- `advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table +- `ipv6_unicast_advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table - `ipv6_unicast_networks` (Attributes List) Specify a network to announce via BGP (see [below for nested schema](#nestedatt--vrfs--ipv6_unicast_networks)) -- `redistribute_connected` (Boolean) Connected -- `redistribute_static` (Boolean) Static routes +- `ipv6_unicast_redistribute_connected` (Boolean) Connected +- `ipv6_unicast_redistribute_static` (Boolean) Static routes ### Nested Schema for `vrfs.ipv6_unicast_networks` diff --git a/examples/resources/iosxe_bgp_address_family_ipv4/resource.tf b/examples/resources/iosxe_bgp_address_family_ipv4/resource.tf index ef30f4a8..804ce481 100644 --- a/examples/resources/iosxe_bgp_address_family_ipv4/resource.tf +++ b/examples/resources/iosxe_bgp_address_family_ipv4/resource.tf @@ -1,6 +1,8 @@ resource "iosxe_bgp_address_family_ipv4" "example" { - asn = "65000" - af_name = "unicast" + asn = "65000" + af_name = "unicast" + ipv4_unicast_redistribute_connected = true + ipv4_unicast_redistribute_static = true ipv4_unicast_networks_mask = [ { network = "12.0.0.0" diff --git a/examples/resources/iosxe_bgp_address_family_ipv4_vrf/resource.tf b/examples/resources/iosxe_bgp_address_family_ipv4_vrf/resource.tf index cb3fd76e..b1854b08 100644 --- a/examples/resources/iosxe_bgp_address_family_ipv4_vrf/resource.tf +++ b/examples/resources/iosxe_bgp_address_family_ipv4_vrf/resource.tf @@ -3,10 +3,10 @@ resource "iosxe_bgp_address_family_ipv4_vrf" "example" { af_name = "unicast" vrfs = [ { - name = "VRF1" - advertise_l2vpn_evpn = true - redistribute_connected = true - redistribute_static = true + name = "VRF1" + ipv4_unicast_advertise_l2vpn_evpn = true + ipv4_unicast_redistribute_connected = true + ipv4_unicast_redistribute_static = true ipv4_unicast_networks_mask = [ { network = "12.0.0.0" diff --git a/examples/resources/iosxe_bgp_address_family_ipv6/resource.tf b/examples/resources/iosxe_bgp_address_family_ipv6/resource.tf index 4cb37c5d..c37b4238 100644 --- a/examples/resources/iosxe_bgp_address_family_ipv6/resource.tf +++ b/examples/resources/iosxe_bgp_address_family_ipv6/resource.tf @@ -1,9 +1,11 @@ resource "iosxe_bgp_address_family_ipv6" "example" { - asn = "65000" - af_name = "unicast" + asn = "65000" + af_name = "unicast" + ipv6_unicast_redistribute_connected = true + ipv6_unicast_redistribute_static = true ipv6_unicast_networks = [ { - network = "2001:1234::0/64" + network = "2001:1234::/64" route_map = "RM1" backdoor = true } diff --git a/examples/resources/iosxe_bgp_address_family_ipv6_vrf/resource.tf b/examples/resources/iosxe_bgp_address_family_ipv6_vrf/resource.tf index ebea7d5d..51a7715c 100644 --- a/examples/resources/iosxe_bgp_address_family_ipv6_vrf/resource.tf +++ b/examples/resources/iosxe_bgp_address_family_ipv6_vrf/resource.tf @@ -3,13 +3,13 @@ resource "iosxe_bgp_address_family_ipv6_vrf" "example" { af_name = "unicast" vrfs = [ { - name = "VRF1" - advertise_l2vpn_evpn = true - redistribute_connected = true - redistribute_static = true + name = "VRF1" + ipv6_unicast_advertise_l2vpn_evpn = true + ipv6_unicast_redistribute_connected = true + ipv6_unicast_redistribute_static = true ipv6_unicast_networks = [ { - network = "2001:1234::0/64" + network = "2001:1234::/64" route_map = "RM1" backdoor = true evpn = false diff --git a/gen/definitions/bgp_address_family_ipv4.yaml b/gen/definitions/bgp_address_family_ipv4.yaml index 35e1fb8b..eca96a36 100644 --- a/gen/definitions/bgp_address_family_ipv4.yaml +++ b/gen/definitions/bgp_address_family_ipv4.yaml @@ -8,6 +8,12 @@ attributes: example: 65000 - yang_name: af-name example: unicast + - yang_name: ipv4-unicast/redistribute/connected + tf_name: ipv4_unicast_redistribute_connected + example: true + - yang_name: ipv4-unicast/redistribute/static + tf_name: ipv4_unicast_redistribute_static + example: true - yang_name: ipv4-unicast/network/with-mask tf_name: ipv4_unicast_networks_mask type: List diff --git a/gen/definitions/bgp_address_family_ipv4_vrf.yaml b/gen/definitions/bgp_address_family_ipv4_vrf.yaml index 628d253c..29c348b2 100644 --- a/gen/definitions/bgp_address_family_ipv4_vrf.yaml +++ b/gen/definitions/bgp_address_family_ipv4_vrf.yaml @@ -17,13 +17,13 @@ attributes: example: VRF1 id: true - yang_name: ipv4-unicast/advertise/l2vpn/evpn - tf_name: advertise_l2vpn_evpn + tf_name: ipv4_unicast_advertise_l2vpn_evpn example: true - yang_name: ipv4-unicast/redistribute-vrf/connected - tf_name: redistribute_connected + tf_name: ipv4_unicast_redistribute_connected example: true - yang_name: ipv4-unicast/redistribute-vrf/static - tf_name: redistribute_static + tf_name: ipv4_unicast_redistribute_static example: true - yang_name: ipv4-unicast/network/with-mask tf_name: ipv4_unicast_networks_mask diff --git a/gen/definitions/bgp_address_family_ipv6.yaml b/gen/definitions/bgp_address_family_ipv6.yaml index 6e5f24d5..0044965c 100644 --- a/gen/definitions/bgp_address_family_ipv6.yaml +++ b/gen/definitions/bgp_address_family_ipv6.yaml @@ -8,6 +8,12 @@ attributes: example: 65000 - yang_name: af-name example: unicast + - yang_name: ipv6-unicast/redistribute-v6/connected + tf_name: ipv6_unicast_redistribute_connected + example: true + - yang_name: ipv6-unicast/redistribute-v6/static + tf_name: ipv6_unicast_redistribute_static + example: true - yang_name: ipv6-unicast/network tf_name: ipv6_unicast_networks type: List @@ -15,7 +21,7 @@ attributes: - yang_name: number tf_name: network id: true - example: 2001:1234::0/64 + example: 2001:1234::/64 - yang_name: route-map example: RM1 - yang_name: backdoor diff --git a/gen/definitions/bgp_address_family_ipv6_vrf.yaml b/gen/definitions/bgp_address_family_ipv6_vrf.yaml index d5f5b75e..57ab184f 100644 --- a/gen/definitions/bgp_address_family_ipv6_vrf.yaml +++ b/gen/definitions/bgp_address_family_ipv6_vrf.yaml @@ -17,13 +17,13 @@ attributes: example: VRF1 id: true - yang_name: ipv6-unicast/advertise/l2vpn/evpn - tf_name: advertise_l2vpn_evpn + tf_name: ipv6_unicast_advertise_l2vpn_evpn example: true - yang_name: ipv6-unicast/redistribute-v6/connected - tf_name: redistribute_connected + tf_name: ipv6_unicast_redistribute_connected example: true - yang_name: ipv6-unicast/redistribute-v6/static - tf_name: redistribute_static + tf_name: ipv6_unicast_redistribute_static example: true - yang_name: ipv6-unicast/network tf_name: ipv6_unicast_networks @@ -32,7 +32,7 @@ attributes: - yang_name: number tf_name: network id: true - example: 2001:1234::0/64 + example: 2001:1234::/64 - yang_name: route-map example: RM1 - yang_name: backdoor diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go index 22a7e775..d29d3b2a 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go @@ -71,6 +71,14 @@ func (d *BGPAddressFamilyIPv4DataSource) Schema(ctx context.Context, req datasou MarkdownDescription: "", Required: true, }, + "ipv4_unicast_redistribute_connected": schema.BoolAttribute{ + MarkdownDescription: "Connected", + Computed: true, + }, + "ipv4_unicast_redistribute_static": schema.BoolAttribute{ + MarkdownDescription: "Static routes", + Computed: true, + }, "ipv4_unicast_networks_mask": schema.ListNestedAttribute{ MarkdownDescription: "Specify a network to announce via BGP", Computed: true, diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go index 96191f37..c39994cb 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_test.go @@ -27,6 +27,8 @@ import ( func TestAccDataSourceIosxeBGPAddressFamilyIPv4(t *testing.T) { var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_redistribute_static", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_networks_mask.0.network", "12.0.0.0")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_networks_mask.0.mask", "255.255.0.0")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_networks_mask.0.route_map", "RM1")) @@ -61,6 +63,8 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv4Config() string { config += ` delete_mode = "attributes"` + "\n" config += ` asn = "65000"` + "\n" config += ` af_name = "unicast"` + "\n" + config += ` ipv4_unicast_redistribute_connected = true` + "\n" + config += ` ipv4_unicast_redistribute_static = true` + "\n" config += ` ipv4_unicast_networks_mask = [{` + "\n" config += ` network = "12.0.0.0"` + "\n" config += ` mask = "255.255.0.0"` + "\n" diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go index 96d3ab1d..cc641b8b 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf.go @@ -80,15 +80,15 @@ func (d *BGPAddressFamilyIPv4VRFDataSource) Schema(ctx context.Context, req data MarkdownDescription: "", Computed: true, }, - "advertise_l2vpn_evpn": schema.BoolAttribute{ + "ipv4_unicast_advertise_l2vpn_evpn": schema.BoolAttribute{ MarkdownDescription: "Advertise/export prefixes to l2vpn evpn table", Computed: true, }, - "redistribute_connected": schema.BoolAttribute{ + "ipv4_unicast_redistribute_connected": schema.BoolAttribute{ MarkdownDescription: "Connected", Computed: true, }, - "redistribute_static": schema.BoolAttribute{ + "ipv4_unicast_redistribute_static": schema.BoolAttribute{ MarkdownDescription: "Static routes", Computed: true, }, diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go index 8e41dcee..c73d3362 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4_vrf_test.go @@ -28,9 +28,9 @@ import ( func TestAccDataSourceIosxeBGPAddressFamilyIPv4VRF(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.name", "VRF1")) - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.advertise_l2vpn_evpn", "true")) - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.redistribute_connected", "true")) - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.redistribute_static", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_advertise_l2vpn_evpn", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_redistribute_static", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.network", "12.0.0.0")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.mask", "255.255.0.0")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.route_map", "RM1")) @@ -78,9 +78,9 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv4VRFConfig() string { config += ` af_name = "unicast"` + "\n" config += ` vrfs = [{` + "\n" config += ` name = "VRF1"` + "\n" - config += ` advertise_l2vpn_evpn = true` + "\n" - config += ` redistribute_connected = true` + "\n" - config += ` redistribute_static = true` + "\n" + config += ` ipv4_unicast_advertise_l2vpn_evpn = true` + "\n" + config += ` ipv4_unicast_redistribute_connected = true` + "\n" + config += ` ipv4_unicast_redistribute_static = true` + "\n" config += ` ipv4_unicast_networks_mask = [{` + "\n" config += ` network = "12.0.0.0"` + "\n" config += ` mask = "255.255.0.0"` + "\n" diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go index 085f73c1..6e15373e 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6.go @@ -71,6 +71,14 @@ func (d *BGPAddressFamilyIPv6DataSource) Schema(ctx context.Context, req datasou MarkdownDescription: "", Required: true, }, + "ipv6_unicast_redistribute_connected": schema.BoolAttribute{ + MarkdownDescription: "Connected", + Computed: true, + }, + "ipv6_unicast_redistribute_static": schema.BoolAttribute{ + MarkdownDescription: "Static routes", + Computed: true, + }, "ipv6_unicast_networks": schema.ListNestedAttribute{ MarkdownDescription: "Specify a network to announce via BGP", Computed: true, diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go index 4b71d475..ad0c8440 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_test.go @@ -27,7 +27,9 @@ import ( func TestAccDataSourceIosxeBGPAddressFamilyIPv6(t *testing.T) { var checks []resource.TestCheckFunc - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.network", "2001:1234::0/64")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_redistribute_static", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.network", "2001:1234::/64")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.route_map", "RM1")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.backdoor", "true")) resource.Test(t, resource.TestCase{ @@ -64,8 +66,10 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv6Config() string { config += ` delete_mode = "attributes"` + "\n" config += ` asn = "65000"` + "\n" config += ` af_name = "unicast"` + "\n" + config += ` ipv6_unicast_redistribute_connected = true` + "\n" + config += ` ipv6_unicast_redistribute_static = true` + "\n" config += ` ipv6_unicast_networks = [{` + "\n" - config += ` network = "2001:1234::0/64"` + "\n" + config += ` network = "2001:1234::/64"` + "\n" config += ` route_map = "RM1"` + "\n" config += ` backdoor = true` + "\n" config += ` }]` + "\n" diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go index dd321966..0e49a5da 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf.go @@ -80,15 +80,15 @@ func (d *BGPAddressFamilyIPv6VRFDataSource) Schema(ctx context.Context, req data MarkdownDescription: "", Computed: true, }, - "advertise_l2vpn_evpn": schema.BoolAttribute{ + "ipv6_unicast_advertise_l2vpn_evpn": schema.BoolAttribute{ MarkdownDescription: "Advertise/export prefixes to l2vpn evpn table", Computed: true, }, - "redistribute_connected": schema.BoolAttribute{ + "ipv6_unicast_redistribute_connected": schema.BoolAttribute{ MarkdownDescription: "Connected", Computed: true, }, - "redistribute_static": schema.BoolAttribute{ + "ipv6_unicast_redistribute_static": schema.BoolAttribute{ MarkdownDescription: "Static routes", Computed: true, }, diff --git a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go index a555654d..3eac60a0 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv6_vrf_test.go @@ -28,10 +28,10 @@ import ( func TestAccDataSourceIosxeBGPAddressFamilyIPv6VRF(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.name", "VRF1")) - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.advertise_l2vpn_evpn", "true")) - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.redistribute_connected", "true")) - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.redistribute_static", "true")) - checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.network", "2001:1234::0/64")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_advertise_l2vpn_evpn", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_redistribute_static", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.network", "2001:1234::/64")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.route_map", "RM1")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.backdoor", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.evpn", "false")) @@ -83,11 +83,11 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv6VRFConfig() string { config += ` af_name = "unicast"` + "\n" config += ` vrfs = [{` + "\n" config += ` name = "VRF1"` + "\n" - config += ` advertise_l2vpn_evpn = true` + "\n" - config += ` redistribute_connected = true` + "\n" - config += ` redistribute_static = true` + "\n" + config += ` ipv6_unicast_advertise_l2vpn_evpn = true` + "\n" + config += ` ipv6_unicast_redistribute_connected = true` + "\n" + config += ` ipv6_unicast_redistribute_static = true` + "\n" config += ` ipv6_unicast_networks = [{` + "\n" - config += ` network = "2001:1234::0/64"` + "\n" + config += ` network = "2001:1234::/64"` + "\n" config += ` route_map = "RM1"` + "\n" config += ` backdoor = true` + "\n" config += ` evpn = false` + "\n" diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv4.go b/internal/provider/model_iosxe_bgp_address_family_ipv4.go index c104dd98..246e4beb 100644 --- a/internal/provider/model_iosxe_bgp_address_family_ipv4.go +++ b/internal/provider/model_iosxe_bgp_address_family_ipv4.go @@ -35,22 +35,26 @@ import ( ) type BGPAddressFamilyIPv4 struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - DeleteMode types.String `tfsdk:"delete_mode"` - Asn types.String `tfsdk:"asn"` - AfName types.String `tfsdk:"af_name"` - Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4Ipv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` - Ipv4UnicastNetworks []BGPAddressFamilyIPv4Ipv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + DeleteMode types.String `tfsdk:"delete_mode"` + Asn types.String `tfsdk:"asn"` + AfName types.String `tfsdk:"af_name"` + Ipv4UnicastRedistributeConnected types.Bool `tfsdk:"ipv4_unicast_redistribute_connected"` + Ipv4UnicastRedistributeStatic types.Bool `tfsdk:"ipv4_unicast_redistribute_static"` + Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4Ipv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` + Ipv4UnicastNetworks []BGPAddressFamilyIPv4Ipv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` } type BGPAddressFamilyIPv4Data struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - Asn types.String `tfsdk:"asn"` - AfName types.String `tfsdk:"af_name"` - Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4Ipv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` - Ipv4UnicastNetworks []BGPAddressFamilyIPv4Ipv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + Asn types.String `tfsdk:"asn"` + AfName types.String `tfsdk:"af_name"` + Ipv4UnicastRedistributeConnected types.Bool `tfsdk:"ipv4_unicast_redistribute_connected"` + Ipv4UnicastRedistributeStatic types.Bool `tfsdk:"ipv4_unicast_redistribute_static"` + Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4Ipv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` + Ipv4UnicastNetworks []BGPAddressFamilyIPv4Ipv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` } type BGPAddressFamilyIPv4Ipv4UnicastNetworksMask struct { Network types.String `tfsdk:"network"` @@ -88,6 +92,16 @@ func (data BGPAddressFamilyIPv4) toBody(ctx context.Context) string { if !data.AfName.IsNull() && !data.AfName.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"af-name", data.AfName.ValueString()) } + if !data.Ipv4UnicastRedistributeConnected.IsNull() && !data.Ipv4UnicastRedistributeConnected.IsUnknown() { + if data.Ipv4UnicastRedistributeConnected.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv4-unicast.redistribute.connected", map[string]string{}) + } + } + if !data.Ipv4UnicastRedistributeStatic.IsNull() && !data.Ipv4UnicastRedistributeStatic.IsUnknown() { + if data.Ipv4UnicastRedistributeStatic.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv4-unicast.redistribute.static", map[string]string{}) + } + } if len(data.Ipv4UnicastNetworksMask) > 0 { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv4-unicast.network.with-mask", []interface{}{}) for index, item := range data.Ipv4UnicastNetworksMask { @@ -136,6 +150,24 @@ func (data *BGPAddressFamilyIPv4) updateFromBody(ctx context.Context, res gjson. } else { data.AfName = types.StringNull() } + if value := res.Get(prefix + "ipv4-unicast.redistribute.connected"); !data.Ipv4UnicastRedistributeConnected.IsNull() { + if value.Exists() { + data.Ipv4UnicastRedistributeConnected = types.BoolValue(true) + } else { + data.Ipv4UnicastRedistributeConnected = types.BoolValue(false) + } + } else { + data.Ipv4UnicastRedistributeConnected = types.BoolNull() + } + if value := res.Get(prefix + "ipv4-unicast.redistribute.static"); !data.Ipv4UnicastRedistributeStatic.IsNull() { + if value.Exists() { + data.Ipv4UnicastRedistributeStatic = types.BoolValue(true) + } else { + data.Ipv4UnicastRedistributeStatic = types.BoolValue(false) + } + } else { + data.Ipv4UnicastRedistributeStatic = types.BoolNull() + } for i := range data.Ipv4UnicastNetworksMask { keys := [...]string{"number", "mask"} keyValues := [...]string{data.Ipv4UnicastNetworksMask[i].Network.ValueString(), data.Ipv4UnicastNetworksMask[i].Mask.ValueString()} @@ -234,6 +266,16 @@ func (data *BGPAddressFamilyIPv4Data) fromBody(ctx context.Context, res gjson.Re if res.Get(helpers.LastElement(data.getPath())).IsArray() { prefix += "0." } + if value := res.Get(prefix + "ipv4-unicast.redistribute.connected"); value.Exists() { + data.Ipv4UnicastRedistributeConnected = types.BoolValue(true) + } else { + data.Ipv4UnicastRedistributeConnected = types.BoolValue(false) + } + if value := res.Get(prefix + "ipv4-unicast.redistribute.static"); value.Exists() { + data.Ipv4UnicastRedistributeStatic = types.BoolValue(true) + } else { + data.Ipv4UnicastRedistributeStatic = types.BoolValue(false) + } if value := res.Get(prefix + "ipv4-unicast.network.with-mask"); value.Exists() { data.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4Ipv4UnicastNetworksMask, 0) value.ForEach(func(k, v gjson.Result) bool { @@ -340,6 +382,12 @@ func (data *BGPAddressFamilyIPv4) getDeletedListItems(ctx context.Context, state func (data *BGPAddressFamilyIPv4) getEmptyLeafsDelete(ctx context.Context) []string { emptyLeafsDelete := make([]string, 0) + if !data.Ipv4UnicastRedistributeConnected.IsNull() && !data.Ipv4UnicastRedistributeConnected.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv4-unicast/redistribute/connected", data.getPath())) + } + if !data.Ipv4UnicastRedistributeStatic.IsNull() && !data.Ipv4UnicastRedistributeStatic.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv4-unicast/redistribute/static", data.getPath())) + } for i := range data.Ipv4UnicastNetworksMask { keyValues := [...]string{data.Ipv4UnicastNetworksMask[i].Network.ValueString(), data.Ipv4UnicastNetworksMask[i].Mask.ValueString()} @@ -359,6 +407,12 @@ func (data *BGPAddressFamilyIPv4) getEmptyLeafsDelete(ctx context.Context) []str func (data *BGPAddressFamilyIPv4) getDeletePaths(ctx context.Context) []string { var deletePaths []string + if !data.Ipv4UnicastRedistributeConnected.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv4-unicast/redistribute/connected", data.getPath())) + } + if !data.Ipv4UnicastRedistributeStatic.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv4-unicast/redistribute/static", data.getPath())) + } for i := range data.Ipv4UnicastNetworksMask { keyValues := [...]string{data.Ipv4UnicastNetworksMask[i].Network.ValueString(), data.Ipv4UnicastNetworksMask[i].Mask.ValueString()} diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go b/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go index 2d2eb3e4..094f657a 100644 --- a/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go +++ b/internal/provider/model_iosxe_bgp_address_family_ipv4_vrf.go @@ -51,12 +51,12 @@ type BGPAddressFamilyIPv4VRFData struct { Vrfs []BGPAddressFamilyIPv4VRFVrfs `tfsdk:"vrfs"` } type BGPAddressFamilyIPv4VRFVrfs struct { - Name types.String `tfsdk:"name"` - AdvertiseL2vpnEvpn types.Bool `tfsdk:"advertise_l2vpn_evpn"` - RedistributeConnected types.Bool `tfsdk:"redistribute_connected"` - RedistributeStatic types.Bool `tfsdk:"redistribute_static"` - Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` - Ipv4UnicastNetworks []BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` + Name types.String `tfsdk:"name"` + Ipv4UnicastAdvertiseL2vpnEvpn types.Bool `tfsdk:"ipv4_unicast_advertise_l2vpn_evpn"` + Ipv4UnicastRedistributeConnected types.Bool `tfsdk:"ipv4_unicast_redistribute_connected"` + Ipv4UnicastRedistributeStatic types.Bool `tfsdk:"ipv4_unicast_redistribute_static"` + Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` + Ipv4UnicastNetworks []BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` } type BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask struct { Network types.String `tfsdk:"network"` @@ -102,18 +102,18 @@ func (data BGPAddressFamilyIPv4VRF) toBody(ctx context.Context) string { if !item.Name.IsNull() && !item.Name.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString()) } - if !item.AdvertiseL2vpnEvpn.IsNull() && !item.AdvertiseL2vpnEvpn.IsUnknown() { - if item.AdvertiseL2vpnEvpn.ValueBool() { + if !item.Ipv4UnicastAdvertiseL2vpnEvpn.IsNull() && !item.Ipv4UnicastAdvertiseL2vpnEvpn.IsUnknown() { + if item.Ipv4UnicastAdvertiseL2vpnEvpn.ValueBool() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.advertise.l2vpn.evpn", map[string]string{}) } } - if !item.RedistributeConnected.IsNull() && !item.RedistributeConnected.IsUnknown() { - if item.RedistributeConnected.ValueBool() { + if !item.Ipv4UnicastRedistributeConnected.IsNull() && !item.Ipv4UnicastRedistributeConnected.IsUnknown() { + if item.Ipv4UnicastRedistributeConnected.ValueBool() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.redistribute-vrf.connected", map[string]string{}) } } - if !item.RedistributeStatic.IsNull() && !item.RedistributeStatic.IsUnknown() { - if item.RedistributeStatic.ValueBool() { + if !item.Ipv4UnicastRedistributeStatic.IsNull() && !item.Ipv4UnicastRedistributeStatic.IsUnknown() { + if item.Ipv4UnicastRedistributeStatic.ValueBool() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.redistribute-vrf.static", map[string]string{}) } } @@ -205,32 +205,32 @@ func (data *BGPAddressFamilyIPv4VRF) updateFromBody(ctx context.Context, res gjs } else { data.Vrfs[i].Name = types.StringNull() } - if value := r.Get("ipv4-unicast.advertise.l2vpn.evpn"); !data.Vrfs[i].AdvertiseL2vpnEvpn.IsNull() { + if value := r.Get("ipv4-unicast.advertise.l2vpn.evpn"); !data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn.IsNull() { if value.Exists() { - data.Vrfs[i].AdvertiseL2vpnEvpn = types.BoolValue(true) + data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true) } else { - data.Vrfs[i].AdvertiseL2vpnEvpn = types.BoolValue(false) + data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false) } } else { - data.Vrfs[i].AdvertiseL2vpnEvpn = types.BoolNull() + data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolNull() } - if value := r.Get("ipv4-unicast.redistribute-vrf.connected"); !data.Vrfs[i].RedistributeConnected.IsNull() { + if value := r.Get("ipv4-unicast.redistribute-vrf.connected"); !data.Vrfs[i].Ipv4UnicastRedistributeConnected.IsNull() { if value.Exists() { - data.Vrfs[i].RedistributeConnected = types.BoolValue(true) + data.Vrfs[i].Ipv4UnicastRedistributeConnected = types.BoolValue(true) } else { - data.Vrfs[i].RedistributeConnected = types.BoolValue(false) + data.Vrfs[i].Ipv4UnicastRedistributeConnected = types.BoolValue(false) } } else { - data.Vrfs[i].RedistributeConnected = types.BoolNull() + data.Vrfs[i].Ipv4UnicastRedistributeConnected = types.BoolNull() } - if value := r.Get("ipv4-unicast.redistribute-vrf.static"); !data.Vrfs[i].RedistributeStatic.IsNull() { + if value := r.Get("ipv4-unicast.redistribute-vrf.static"); !data.Vrfs[i].Ipv4UnicastRedistributeStatic.IsNull() { if value.Exists() { - data.Vrfs[i].RedistributeStatic = types.BoolValue(true) + data.Vrfs[i].Ipv4UnicastRedistributeStatic = types.BoolValue(true) } else { - data.Vrfs[i].RedistributeStatic = types.BoolValue(false) + data.Vrfs[i].Ipv4UnicastRedistributeStatic = types.BoolValue(false) } } else { - data.Vrfs[i].RedistributeStatic = types.BoolNull() + data.Vrfs[i].Ipv4UnicastRedistributeStatic = types.BoolNull() } for ci := range data.Vrfs[i].Ipv4UnicastNetworksMask { keys := [...]string{"number", "mask"} @@ -357,19 +357,19 @@ func (data *BGPAddressFamilyIPv4VRFData) fromBody(ctx context.Context, res gjson item.Name = types.StringValue(cValue.String()) } if cValue := v.Get("ipv4-unicast.advertise.l2vpn.evpn"); cValue.Exists() { - item.AdvertiseL2vpnEvpn = types.BoolValue(true) + item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(true) } else { - item.AdvertiseL2vpnEvpn = types.BoolValue(false) + item.Ipv4UnicastAdvertiseL2vpnEvpn = types.BoolValue(false) } if cValue := v.Get("ipv4-unicast.redistribute-vrf.connected"); cValue.Exists() { - item.RedistributeConnected = types.BoolValue(true) + item.Ipv4UnicastRedistributeConnected = types.BoolValue(true) } else { - item.RedistributeConnected = types.BoolValue(false) + item.Ipv4UnicastRedistributeConnected = types.BoolValue(false) } if cValue := v.Get("ipv4-unicast.redistribute-vrf.static"); cValue.Exists() { - item.RedistributeStatic = types.BoolValue(true) + item.Ipv4UnicastRedistributeStatic = types.BoolValue(true) } else { - item.RedistributeStatic = types.BoolValue(false) + item.Ipv4UnicastRedistributeStatic = types.BoolValue(false) } if cValue := v.Get("ipv4-unicast.network.with-mask"); cValue.Exists() { item.Ipv4UnicastNetworksMask = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask, 0) @@ -519,13 +519,13 @@ func (data *BGPAddressFamilyIPv4VRF) getEmptyLeafsDelete(ctx context.Context) [] for i := range data.Vrfs { keyValues := [...]string{data.Vrfs[i].Name.ValueString()} - if !data.Vrfs[i].AdvertiseL2vpnEvpn.IsNull() && !data.Vrfs[i].AdvertiseL2vpnEvpn.ValueBool() { + if !data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn.IsNull() && !data.Vrfs[i].Ipv4UnicastAdvertiseL2vpnEvpn.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/vrf=%v/ipv4-unicast/advertise/l2vpn/evpn", data.getPath(), strings.Join(keyValues[:], ","))) } - if !data.Vrfs[i].RedistributeConnected.IsNull() && !data.Vrfs[i].RedistributeConnected.ValueBool() { + if !data.Vrfs[i].Ipv4UnicastRedistributeConnected.IsNull() && !data.Vrfs[i].Ipv4UnicastRedistributeConnected.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/vrf=%v/ipv4-unicast/redistribute-vrf/connected", data.getPath(), strings.Join(keyValues[:], ","))) } - if !data.Vrfs[i].RedistributeStatic.IsNull() && !data.Vrfs[i].RedistributeStatic.ValueBool() { + if !data.Vrfs[i].Ipv4UnicastRedistributeStatic.IsNull() && !data.Vrfs[i].Ipv4UnicastRedistributeStatic.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/vrf=%v/ipv4-unicast/redistribute-vrf/static", data.getPath(), strings.Join(keyValues[:], ","))) } diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv6.go b/internal/provider/model_iosxe_bgp_address_family_ipv6.go index 633372f8..30539025 100644 --- a/internal/provider/model_iosxe_bgp_address_family_ipv6.go +++ b/internal/provider/model_iosxe_bgp_address_family_ipv6.go @@ -35,20 +35,24 @@ import ( ) type BGPAddressFamilyIPv6 struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - DeleteMode types.String `tfsdk:"delete_mode"` - Asn types.String `tfsdk:"asn"` - AfName types.String `tfsdk:"af_name"` - Ipv6UnicastNetworks []BGPAddressFamilyIPv6Ipv6UnicastNetworks `tfsdk:"ipv6_unicast_networks"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + DeleteMode types.String `tfsdk:"delete_mode"` + Asn types.String `tfsdk:"asn"` + AfName types.String `tfsdk:"af_name"` + Ipv6UnicastRedistributeConnected types.Bool `tfsdk:"ipv6_unicast_redistribute_connected"` + Ipv6UnicastRedistributeStatic types.Bool `tfsdk:"ipv6_unicast_redistribute_static"` + Ipv6UnicastNetworks []BGPAddressFamilyIPv6Ipv6UnicastNetworks `tfsdk:"ipv6_unicast_networks"` } type BGPAddressFamilyIPv6Data struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - Asn types.String `tfsdk:"asn"` - AfName types.String `tfsdk:"af_name"` - Ipv6UnicastNetworks []BGPAddressFamilyIPv6Ipv6UnicastNetworks `tfsdk:"ipv6_unicast_networks"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + Asn types.String `tfsdk:"asn"` + AfName types.String `tfsdk:"af_name"` + Ipv6UnicastRedistributeConnected types.Bool `tfsdk:"ipv6_unicast_redistribute_connected"` + Ipv6UnicastRedistributeStatic types.Bool `tfsdk:"ipv6_unicast_redistribute_static"` + Ipv6UnicastNetworks []BGPAddressFamilyIPv6Ipv6UnicastNetworks `tfsdk:"ipv6_unicast_networks"` } type BGPAddressFamilyIPv6Ipv6UnicastNetworks struct { Network types.String `tfsdk:"network"` @@ -80,6 +84,16 @@ func (data BGPAddressFamilyIPv6) toBody(ctx context.Context) string { if !data.AfName.IsNull() && !data.AfName.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"af-name", data.AfName.ValueString()) } + if !data.Ipv6UnicastRedistributeConnected.IsNull() && !data.Ipv6UnicastRedistributeConnected.IsUnknown() { + if data.Ipv6UnicastRedistributeConnected.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv6-unicast.redistribute-v6.connected", map[string]string{}) + } + } + if !data.Ipv6UnicastRedistributeStatic.IsNull() && !data.Ipv6UnicastRedistributeStatic.IsUnknown() { + if data.Ipv6UnicastRedistributeStatic.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv6-unicast.redistribute-v6.static", map[string]string{}) + } + } if len(data.Ipv6UnicastNetworks) > 0 { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv6-unicast.network", []interface{}{}) for index, item := range data.Ipv6UnicastNetworks { @@ -109,6 +123,24 @@ func (data *BGPAddressFamilyIPv6) updateFromBody(ctx context.Context, res gjson. } else { data.AfName = types.StringNull() } + if value := res.Get(prefix + "ipv6-unicast.redistribute-v6.connected"); !data.Ipv6UnicastRedistributeConnected.IsNull() { + if value.Exists() { + data.Ipv6UnicastRedistributeConnected = types.BoolValue(true) + } else { + data.Ipv6UnicastRedistributeConnected = types.BoolValue(false) + } + } else { + data.Ipv6UnicastRedistributeConnected = types.BoolNull() + } + if value := res.Get(prefix + "ipv6-unicast.redistribute-v6.static"); !data.Ipv6UnicastRedistributeStatic.IsNull() { + if value.Exists() { + data.Ipv6UnicastRedistributeStatic = types.BoolValue(true) + } else { + data.Ipv6UnicastRedistributeStatic = types.BoolValue(false) + } + } else { + data.Ipv6UnicastRedistributeStatic = types.BoolNull() + } for i := range data.Ipv6UnicastNetworks { keys := [...]string{"number"} keyValues := [...]string{data.Ipv6UnicastNetworks[i].Network.ValueString()} @@ -159,6 +191,16 @@ func (data *BGPAddressFamilyIPv6Data) fromBody(ctx context.Context, res gjson.Re if res.Get(helpers.LastElement(data.getPath())).IsArray() { prefix += "0." } + if value := res.Get(prefix + "ipv6-unicast.redistribute-v6.connected"); value.Exists() { + data.Ipv6UnicastRedistributeConnected = types.BoolValue(true) + } else { + data.Ipv6UnicastRedistributeConnected = types.BoolValue(false) + } + if value := res.Get(prefix + "ipv6-unicast.redistribute-v6.static"); value.Exists() { + data.Ipv6UnicastRedistributeStatic = types.BoolValue(true) + } else { + data.Ipv6UnicastRedistributeStatic = types.BoolValue(false) + } if value := res.Get(prefix + "ipv6-unicast.network"); value.Exists() { data.Ipv6UnicastNetworks = make([]BGPAddressFamilyIPv6Ipv6UnicastNetworks, 0) value.ForEach(func(k, v gjson.Result) bool { @@ -212,6 +254,12 @@ func (data *BGPAddressFamilyIPv6) getDeletedListItems(ctx context.Context, state func (data *BGPAddressFamilyIPv6) getEmptyLeafsDelete(ctx context.Context) []string { emptyLeafsDelete := make([]string, 0) + if !data.Ipv6UnicastRedistributeConnected.IsNull() && !data.Ipv6UnicastRedistributeConnected.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6-unicast/redistribute-v6/connected", data.getPath())) + } + if !data.Ipv6UnicastRedistributeStatic.IsNull() && !data.Ipv6UnicastRedistributeStatic.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/ipv6-unicast/redistribute-v6/static", data.getPath())) + } for i := range data.Ipv6UnicastNetworks { keyValues := [...]string{data.Ipv6UnicastNetworks[i].Network.ValueString()} @@ -224,6 +272,12 @@ func (data *BGPAddressFamilyIPv6) getEmptyLeafsDelete(ctx context.Context) []str func (data *BGPAddressFamilyIPv6) getDeletePaths(ctx context.Context) []string { var deletePaths []string + if !data.Ipv6UnicastRedistributeConnected.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6-unicast/redistribute-v6/connected", data.getPath())) + } + if !data.Ipv6UnicastRedistributeStatic.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv6-unicast/redistribute-v6/static", data.getPath())) + } for i := range data.Ipv6UnicastNetworks { keyValues := [...]string{data.Ipv6UnicastNetworks[i].Network.ValueString()} diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go b/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go index 17101bba..e404cc75 100644 --- a/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go +++ b/internal/provider/model_iosxe_bgp_address_family_ipv6_vrf.go @@ -51,11 +51,11 @@ type BGPAddressFamilyIPv6VRFData struct { Vrfs []BGPAddressFamilyIPv6VRFVrfs `tfsdk:"vrfs"` } type BGPAddressFamilyIPv6VRFVrfs struct { - Name types.String `tfsdk:"name"` - AdvertiseL2vpnEvpn types.Bool `tfsdk:"advertise_l2vpn_evpn"` - RedistributeConnected types.Bool `tfsdk:"redistribute_connected"` - RedistributeStatic types.Bool `tfsdk:"redistribute_static"` - Ipv6UnicastNetworks []BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks `tfsdk:"ipv6_unicast_networks"` + Name types.String `tfsdk:"name"` + Ipv6UnicastAdvertiseL2vpnEvpn types.Bool `tfsdk:"ipv6_unicast_advertise_l2vpn_evpn"` + Ipv6UnicastRedistributeConnected types.Bool `tfsdk:"ipv6_unicast_redistribute_connected"` + Ipv6UnicastRedistributeStatic types.Bool `tfsdk:"ipv6_unicast_redistribute_static"` + Ipv6UnicastNetworks []BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks `tfsdk:"ipv6_unicast_networks"` } type BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks struct { Network types.String `tfsdk:"network"` @@ -94,18 +94,18 @@ func (data BGPAddressFamilyIPv6VRF) toBody(ctx context.Context) string { if !item.Name.IsNull() && !item.Name.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"name", item.Name.ValueString()) } - if !item.AdvertiseL2vpnEvpn.IsNull() && !item.AdvertiseL2vpnEvpn.IsUnknown() { - if item.AdvertiseL2vpnEvpn.ValueBool() { + if !item.Ipv6UnicastAdvertiseL2vpnEvpn.IsNull() && !item.Ipv6UnicastAdvertiseL2vpnEvpn.IsUnknown() { + if item.Ipv6UnicastAdvertiseL2vpnEvpn.ValueBool() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv6-unicast.advertise.l2vpn.evpn", map[string]string{}) } } - if !item.RedistributeConnected.IsNull() && !item.RedistributeConnected.IsUnknown() { - if item.RedistributeConnected.ValueBool() { + if !item.Ipv6UnicastRedistributeConnected.IsNull() && !item.Ipv6UnicastRedistributeConnected.IsUnknown() { + if item.Ipv6UnicastRedistributeConnected.ValueBool() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv6-unicast.redistribute-v6.connected", map[string]string{}) } } - if !item.RedistributeStatic.IsNull() && !item.RedistributeStatic.IsUnknown() { - if item.RedistributeStatic.ValueBool() { + if !item.Ipv6UnicastRedistributeStatic.IsNull() && !item.Ipv6UnicastRedistributeStatic.IsUnknown() { + if item.Ipv6UnicastRedistributeStatic.ValueBool() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv6-unicast.redistribute-v6.static", map[string]string{}) } } @@ -173,32 +173,32 @@ func (data *BGPAddressFamilyIPv6VRF) updateFromBody(ctx context.Context, res gjs } else { data.Vrfs[i].Name = types.StringNull() } - if value := r.Get("ipv6-unicast.advertise.l2vpn.evpn"); !data.Vrfs[i].AdvertiseL2vpnEvpn.IsNull() { + if value := r.Get("ipv6-unicast.advertise.l2vpn.evpn"); !data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn.IsNull() { if value.Exists() { - data.Vrfs[i].AdvertiseL2vpnEvpn = types.BoolValue(true) + data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(true) } else { - data.Vrfs[i].AdvertiseL2vpnEvpn = types.BoolValue(false) + data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(false) } } else { - data.Vrfs[i].AdvertiseL2vpnEvpn = types.BoolNull() + data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolNull() } - if value := r.Get("ipv6-unicast.redistribute-v6.connected"); !data.Vrfs[i].RedistributeConnected.IsNull() { + if value := r.Get("ipv6-unicast.redistribute-v6.connected"); !data.Vrfs[i].Ipv6UnicastRedistributeConnected.IsNull() { if value.Exists() { - data.Vrfs[i].RedistributeConnected = types.BoolValue(true) + data.Vrfs[i].Ipv6UnicastRedistributeConnected = types.BoolValue(true) } else { - data.Vrfs[i].RedistributeConnected = types.BoolValue(false) + data.Vrfs[i].Ipv6UnicastRedistributeConnected = types.BoolValue(false) } } else { - data.Vrfs[i].RedistributeConnected = types.BoolNull() + data.Vrfs[i].Ipv6UnicastRedistributeConnected = types.BoolNull() } - if value := r.Get("ipv6-unicast.redistribute-v6.static"); !data.Vrfs[i].RedistributeStatic.IsNull() { + if value := r.Get("ipv6-unicast.redistribute-v6.static"); !data.Vrfs[i].Ipv6UnicastRedistributeStatic.IsNull() { if value.Exists() { - data.Vrfs[i].RedistributeStatic = types.BoolValue(true) + data.Vrfs[i].Ipv6UnicastRedistributeStatic = types.BoolValue(true) } else { - data.Vrfs[i].RedistributeStatic = types.BoolValue(false) + data.Vrfs[i].Ipv6UnicastRedistributeStatic = types.BoolValue(false) } } else { - data.Vrfs[i].RedistributeStatic = types.BoolNull() + data.Vrfs[i].Ipv6UnicastRedistributeStatic = types.BoolNull() } for ci := range data.Vrfs[i].Ipv6UnicastNetworks { keys := [...]string{"number"} @@ -268,19 +268,19 @@ func (data *BGPAddressFamilyIPv6VRFData) fromBody(ctx context.Context, res gjson item.Name = types.StringValue(cValue.String()) } if cValue := v.Get("ipv6-unicast.advertise.l2vpn.evpn"); cValue.Exists() { - item.AdvertiseL2vpnEvpn = types.BoolValue(true) + item.Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(true) } else { - item.AdvertiseL2vpnEvpn = types.BoolValue(false) + item.Ipv6UnicastAdvertiseL2vpnEvpn = types.BoolValue(false) } if cValue := v.Get("ipv6-unicast.redistribute-v6.connected"); cValue.Exists() { - item.RedistributeConnected = types.BoolValue(true) + item.Ipv6UnicastRedistributeConnected = types.BoolValue(true) } else { - item.RedistributeConnected = types.BoolValue(false) + item.Ipv6UnicastRedistributeConnected = types.BoolValue(false) } if cValue := v.Get("ipv6-unicast.redistribute-v6.static"); cValue.Exists() { - item.RedistributeStatic = types.BoolValue(true) + item.Ipv6UnicastRedistributeStatic = types.BoolValue(true) } else { - item.RedistributeStatic = types.BoolValue(false) + item.Ipv6UnicastRedistributeStatic = types.BoolValue(false) } if cValue := v.Get("ipv6-unicast.network"); cValue.Exists() { item.Ipv6UnicastNetworks = make([]BGPAddressFamilyIPv6VRFVrfsIpv6UnicastNetworks, 0) @@ -372,13 +372,13 @@ func (data *BGPAddressFamilyIPv6VRF) getEmptyLeafsDelete(ctx context.Context) [] for i := range data.Vrfs { keyValues := [...]string{data.Vrfs[i].Name.ValueString()} - if !data.Vrfs[i].AdvertiseL2vpnEvpn.IsNull() && !data.Vrfs[i].AdvertiseL2vpnEvpn.ValueBool() { + if !data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn.IsNull() && !data.Vrfs[i].Ipv6UnicastAdvertiseL2vpnEvpn.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/vrf=%v/ipv6-unicast/advertise/l2vpn/evpn", data.getPath(), strings.Join(keyValues[:], ","))) } - if !data.Vrfs[i].RedistributeConnected.IsNull() && !data.Vrfs[i].RedistributeConnected.ValueBool() { + if !data.Vrfs[i].Ipv6UnicastRedistributeConnected.IsNull() && !data.Vrfs[i].Ipv6UnicastRedistributeConnected.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/vrf=%v/ipv6-unicast/redistribute-v6/connected", data.getPath(), strings.Join(keyValues[:], ","))) } - if !data.Vrfs[i].RedistributeStatic.IsNull() && !data.Vrfs[i].RedistributeStatic.ValueBool() { + if !data.Vrfs[i].Ipv6UnicastRedistributeStatic.IsNull() && !data.Vrfs[i].Ipv6UnicastRedistributeStatic.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/vrf=%v/ipv6-unicast/redistribute-v6/static", data.getPath(), strings.Join(keyValues[:], ","))) } diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4.go index 42eec011..d4a6872f 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv4.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4.go @@ -90,6 +90,14 @@ func (r *BGPAddressFamilyIPv4Resource) Schema(ctx context.Context, req resource. stringplanmodifier.RequiresReplace(), }, }, + "ipv4_unicast_redistribute_connected": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Connected").String, + Optional: true, + }, + "ipv4_unicast_redistribute_static": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Static routes").String, + Optional: true, + }, "ipv4_unicast_networks_mask": schema.ListNestedAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Specify a network to announce via BGP").String, Optional: true, diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go index d542683a..89994403 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go @@ -28,6 +28,8 @@ import ( func TestAccIosxeBGPAddressFamilyIPv4(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4.test", "af_name", "unicast")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_redistribute_static", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_networks_mask.0.network", "12.0.0.0")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_networks_mask.0.mask", "255.255.0.0")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_networks_mask.0.route_map", "RM1")) @@ -78,6 +80,8 @@ func testAccIosxeBGPAddressFamilyIPv4Config_all() string { config := `resource "iosxe_bgp_address_family_ipv4" "test" {` + "\n" config += ` asn = "65000"` + "\n" config += ` af_name = "unicast"` + "\n" + config += ` ipv4_unicast_redistribute_connected = true` + "\n" + config += ` ipv4_unicast_redistribute_static = true` + "\n" config += ` ipv4_unicast_networks_mask = [{` + "\n" config += ` network = "12.0.0.0"` + "\n" config += ` mask = "255.255.0.0"` + "\n" diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go index f5bc0b37..f83c715a 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go @@ -99,15 +99,15 @@ func (r *BGPAddressFamilyIPv4VRFResource) Schema(ctx context.Context, req resour MarkdownDescription: helpers.NewAttributeDescription("").String, Required: true, }, - "advertise_l2vpn_evpn": schema.BoolAttribute{ + "ipv4_unicast_advertise_l2vpn_evpn": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Advertise/export prefixes to l2vpn evpn table").String, Optional: true, }, - "redistribute_connected": schema.BoolAttribute{ + "ipv4_unicast_redistribute_connected": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Connected").String, Optional: true, }, - "redistribute_static": schema.BoolAttribute{ + "ipv4_unicast_redistribute_static": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Static routes").String, Optional: true, }, diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go index a1525d39..ec0391f7 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf_test.go @@ -29,9 +29,9 @@ func TestAccIosxeBGPAddressFamilyIPv4VRF(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "af_name", "unicast")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.name", "VRF1")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.advertise_l2vpn_evpn", "true")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.redistribute_connected", "true")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.redistribute_static", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_advertise_l2vpn_evpn", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_redistribute_static", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.network", "12.0.0.0")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.mask", "255.255.0.0")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_networks_mask.0.route_map", "RM1")) @@ -92,9 +92,9 @@ func testAccIosxeBGPAddressFamilyIPv4VRFConfig_all() string { config += ` af_name = "unicast"` + "\n" config += ` vrfs = [{` + "\n" config += ` name = "VRF1"` + "\n" - config += ` advertise_l2vpn_evpn = true` + "\n" - config += ` redistribute_connected = true` + "\n" - config += ` redistribute_static = true` + "\n" + config += ` ipv4_unicast_advertise_l2vpn_evpn = true` + "\n" + config += ` ipv4_unicast_redistribute_connected = true` + "\n" + config += ` ipv4_unicast_redistribute_static = true` + "\n" config += ` ipv4_unicast_networks_mask = [{` + "\n" config += ` network = "12.0.0.0"` + "\n" config += ` mask = "255.255.0.0"` + "\n" diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6.go index 733effd6..93c64eea 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv6.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6.go @@ -90,6 +90,14 @@ func (r *BGPAddressFamilyIPv6Resource) Schema(ctx context.Context, req resource. stringplanmodifier.RequiresReplace(), }, }, + "ipv6_unicast_redistribute_connected": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Connected").String, + Optional: true, + }, + "ipv6_unicast_redistribute_static": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Static routes").String, + Optional: true, + }, "ipv6_unicast_networks": schema.ListNestedAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Specify a network to announce via BGP").String, Optional: true, diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go index c61d0f5d..78ca3e74 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6_test.go @@ -28,7 +28,9 @@ import ( func TestAccIosxeBGPAddressFamilyIPv6(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6.test", "af_name", "unicast")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.network", "2001:1234::0/64")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_redistribute_static", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.network", "2001:1234::/64")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.route_map", "RM1")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6.test", "ipv6_unicast_networks.0.backdoor", "true")) resource.Test(t, resource.TestCase{ @@ -81,8 +83,10 @@ func testAccIosxeBGPAddressFamilyIPv6Config_all() string { config := `resource "iosxe_bgp_address_family_ipv6" "test" {` + "\n" config += ` asn = "65000"` + "\n" config += ` af_name = "unicast"` + "\n" + config += ` ipv6_unicast_redistribute_connected = true` + "\n" + config += ` ipv6_unicast_redistribute_static = true` + "\n" config += ` ipv6_unicast_networks = [{` + "\n" - config += ` network = "2001:1234::0/64"` + "\n" + config += ` network = "2001:1234::/64"` + "\n" config += ` route_map = "RM1"` + "\n" config += ` backdoor = true` + "\n" config += ` }]` + "\n" diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go index 26c73493..4815745b 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf.go @@ -99,15 +99,15 @@ func (r *BGPAddressFamilyIPv6VRFResource) Schema(ctx context.Context, req resour MarkdownDescription: helpers.NewAttributeDescription("").String, Required: true, }, - "advertise_l2vpn_evpn": schema.BoolAttribute{ + "ipv6_unicast_advertise_l2vpn_evpn": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Advertise/export prefixes to l2vpn evpn table").String, Optional: true, }, - "redistribute_connected": schema.BoolAttribute{ + "ipv6_unicast_redistribute_connected": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Connected").String, Optional: true, }, - "redistribute_static": schema.BoolAttribute{ + "ipv6_unicast_redistribute_static": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Static routes").String, Optional: true, }, diff --git a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go index c42b80ea..61f0354d 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv6_vrf_test.go @@ -29,10 +29,10 @@ func TestAccIosxeBGPAddressFamilyIPv6VRF(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "af_name", "unicast")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.name", "VRF1")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.advertise_l2vpn_evpn", "true")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.redistribute_connected", "true")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.redistribute_static", "true")) - checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.network", "2001:1234::0/64")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_advertise_l2vpn_evpn", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_redistribute_connected", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_redistribute_static", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.network", "2001:1234::/64")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.route_map", "RM1")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.backdoor", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv6_vrf.test", "vrfs.0.ipv6_unicast_networks.0.evpn", "false")) @@ -97,11 +97,11 @@ func testAccIosxeBGPAddressFamilyIPv6VRFConfig_all() string { config += ` af_name = "unicast"` + "\n" config += ` vrfs = [{` + "\n" config += ` name = "VRF1"` + "\n" - config += ` advertise_l2vpn_evpn = true` + "\n" - config += ` redistribute_connected = true` + "\n" - config += ` redistribute_static = true` + "\n" + config += ` ipv6_unicast_advertise_l2vpn_evpn = true` + "\n" + config += ` ipv6_unicast_redistribute_connected = true` + "\n" + config += ` ipv6_unicast_redistribute_static = true` + "\n" config += ` ipv6_unicast_networks = [{` + "\n" - config += ` network = "2001:1234::0/64"` + "\n" + config += ` network = "2001:1234::/64"` + "\n" config += ` route_map = "RM1"` + "\n" config += ` backdoor = true` + "\n" config += ` evpn = false` + "\n" diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 91201bdc..ed38132b 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -14,6 +14,16 @@ description: |- - Add `spanning_tree_link_type` and `ip_dhcp_snooping_trust` attributes to `iosxe_interface_port_channel` resource and data source - Add `compress_config`, `sequence_numbers` and `call_home` attributes to `iosxe_service` resource and data source - Add `hosts`, `system_shutdown` and `enable_traps_*` attributes to `iosxe_snmp_server` resource and data source +- BREAKING CHANGE: Rename `advertise_l2vpn_evpn` attribute to `ipv4_unicast_advertise_l2vpn_evpn` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_connected` attribute to `ipv4_unicast_redistribute_connected` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_static` attribute to `ipv4_unicast_redistribute_static` of `iosxe_bgp_address_family_ipv4_vrf` resource and data source +- Add `ipv4_unicast_redistribute_connected` attribute to `iosxe_bgp_address_family_ipv4` resource and data source +- Add `ipv4_unicast_redistribute_static` attribute to `iosxe_bgp_address_family_ipv4` resource and data source +- BREAKING CHANGE: Rename `advertise_l2vpn_evpn` attribute to `ipv6_unicast_advertise_l2vpn_evpn` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_connected` attribute to `ipv6_unicast_redistribute_connected` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- BREAKING CHANGE: Rename `redistribute_static` attribute to `ipv6_unicast_redistribute_static` of `iosxe_bgp_address_family_ipv6_vrf` resource and data source +- Add `ipv6_unicast_redistribute_connected` attribute to `iosxe_bgp_address_family_ipv6` resource and data source +- Add `ipv6_unicast_redistribute_static` attribute to `iosxe_bgp_address_family_ipv6` resource and data source ## 0.4.0