From 4b54eb1efd7cf59d15fc6f0935bd03d8a8592ecb Mon Sep 17 00:00:00 2001 From: Shankar Date: Mon, 13 Nov 2023 21:11:56 +0530 Subject: [PATCH] US-DIGITIZE-1349 --- docs/data-sources/bgp_address_family_ipv4.md | 10 ++ .../bgp_address_family_ipv4_vrf.md | 10 ++ docs/resources/bgp_address_family_ipv4.md | 16 +++ docs/resources/bgp_address_family_ipv4_vrf.md | 18 ++- .../iosxe_bgp_address_family_ipv4/resource.tf | 6 + .../resource.tf | 8 +- gen/definitions/bgp_address_family_ipv4.yaml | 11 ++ .../bgp_address_family_ipv4_vrf.yaml | 10 ++ ...ta_source_iosxe_bgp_address_family_ipv4.go | 16 +++ ...urce_iosxe_bgp_address_family_ipv4_test.go | 6 + ...ource_iosxe_bgp_address_family_ipv4_vrf.go | 16 +++ ..._iosxe_bgp_address_family_ipv4_vrf_test.go | 6 + .../model_iosxe_bgp_address_family_ipv4.go | 135 +++++++++++++++--- ...model_iosxe_bgp_address_family_ipv4_vrf.go | 108 +++++++++++++- .../resource_iosxe_bgp_address_family_ipv4.go | 22 +++ ...urce_iosxe_bgp_address_family_ipv4_test.go | 6 + ...ource_iosxe_bgp_address_family_ipv4_vrf.go | 22 +++ ..._iosxe_bgp_address_family_ipv4_vrf_test.go | 6 + 18 files changed, 407 insertions(+), 25 deletions(-) diff --git a/docs/data-sources/bgp_address_family_ipv4.md b/docs/data-sources/bgp_address_family_ipv4.md index a972746c..d4adbd4c 100644 --- a/docs/data-sources/bgp_address_family_ipv4.md +++ b/docs/data-sources/bgp_address_family_ipv4.md @@ -34,11 +34,21 @@ data "iosxe_bgp_address_family_ipv4" "example" { ### Read-Only - `id` (String) The path of the retrieved object. +- `ipv4_unicast_aggregate_address` (Attributes List) Configure BGP aggregate entries (see [below for nested schema](#nestedatt--ipv4_unicast_aggregate_address)) - `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_aggregate_address` + +Read-Only: + +- `ipv4_address` (String) +- `ipv4_mask` (String) + + ### 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 583ff5f1..fe297234 100644 --- a/docs/data-sources/bgp_address_family_ipv4_vrf.md +++ b/docs/data-sources/bgp_address_family_ipv4_vrf.md @@ -42,12 +42,22 @@ data "iosxe_bgp_address_family_ipv4_vrf" "example" { Read-Only: - `ipv4_unicast_advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table +- `ipv4_unicast_aggregate_address` (Attributes List) Configure BGP aggregate entries (see [below for nested schema](#nestedatt--vrfs--ipv4_unicast_aggregate_address)) - `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) + +### Nested Schema for `vrfs.ipv4_unicast_aggregate_address` + +Read-Only: + +- `ipv4_address` (String) +- `ipv4_mask` (String) + + ### Nested Schema for `vrfs.ipv4_unicast_networks` diff --git a/docs/resources/bgp_address_family_ipv4.md b/docs/resources/bgp_address_family_ipv4.md index 54122c23..990f17d4 100644 --- a/docs/resources/bgp_address_family_ipv4.md +++ b/docs/resources/bgp_address_family_ipv4.md @@ -18,6 +18,12 @@ resource "iosxe_bgp_address_family_ipv4" "example" { af_name = "unicast" ipv4_unicast_redistribute_connected = true ipv4_unicast_redistribute_static = true + ipv4_unicast_aggregate_address = [ + { + ipv4_address = "10.0.0.0" + ipv4_mask = "255.255.0.0" + } + ] ipv4_unicast_networks_mask = [ { network = "12.0.0.0" @@ -49,6 +55,7 @@ resource "iosxe_bgp_address_family_ipv4" "example" { - `delete_mode` (String) Configure behavior when deleting/destroying the resource. Either delete the entire object (YANG container) being managed, or only delete the individual resource attributes configured explicitly and leave everything else as-is. Default value is `all`. - Choices: `all`, `attributes` - `device` (String) A device name from the provider configuration. +- `ipv4_unicast_aggregate_address` (Attributes List) Configure BGP aggregate entries (see [below for nested schema](#nestedatt--ipv4_unicast_aggregate_address)) - `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 @@ -58,6 +65,15 @@ resource "iosxe_bgp_address_family_ipv4" "example" { - `id` (String) The path of the object. + +### Nested Schema for `ipv4_unicast_aggregate_address` + +Required: + +- `ipv4_address` (String) +- `ipv4_mask` (String) + + ### Nested Schema for `ipv4_unicast_networks` diff --git a/docs/resources/bgp_address_family_ipv4_vrf.md b/docs/resources/bgp_address_family_ipv4_vrf.md index 1a7974eb..64c0f4df 100644 --- a/docs/resources/bgp_address_family_ipv4_vrf.md +++ b/docs/resources/bgp_address_family_ipv4_vrf.md @@ -21,7 +21,13 @@ resource "iosxe_bgp_address_family_ipv4_vrf" "example" { name = "VRF1" ipv4_unicast_advertise_l2vpn_evpn = true ipv4_unicast_redistribute_connected = true - ipv4_unicast_redistribute_static = true + ipv4_unicast_aggregate_address = [ + { + ipv4_address = "50.0.0.0" + ipv4_mask = "255.255.0.0" + } + ] + ipv4_unicast_redistribute_static = true ipv4_unicast_networks_mask = [ { network = "12.0.0.0" @@ -71,11 +77,21 @@ Required: Optional: - `ipv4_unicast_advertise_l2vpn_evpn` (Boolean) Advertise/export prefixes to l2vpn evpn table +- `ipv4_unicast_aggregate_address` (Attributes List) Configure BGP aggregate entries (see [below for nested schema](#nestedatt--vrfs--ipv4_unicast_aggregate_address)) - `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 + +### Nested Schema for `vrfs.ipv4_unicast_aggregate_address` + +Required: + +- `ipv4_address` (String) +- `ipv4_mask` (String) + + ### Nested Schema for `vrfs.ipv4_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 804ce481..ff03c2ed 100644 --- a/examples/resources/iosxe_bgp_address_family_ipv4/resource.tf +++ b/examples/resources/iosxe_bgp_address_family_ipv4/resource.tf @@ -3,6 +3,12 @@ resource "iosxe_bgp_address_family_ipv4" "example" { af_name = "unicast" ipv4_unicast_redistribute_connected = true ipv4_unicast_redistribute_static = true + ipv4_unicast_aggregate_address = [ + { + ipv4_address = "10.0.0.0" + ipv4_mask = "255.255.0.0" + } + ] 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 b1854b08..ba556ac6 100644 --- a/examples/resources/iosxe_bgp_address_family_ipv4_vrf/resource.tf +++ b/examples/resources/iosxe_bgp_address_family_ipv4_vrf/resource.tf @@ -6,7 +6,13 @@ resource "iosxe_bgp_address_family_ipv4_vrf" "example" { name = "VRF1" ipv4_unicast_advertise_l2vpn_evpn = true ipv4_unicast_redistribute_connected = true - ipv4_unicast_redistribute_static = true + ipv4_unicast_aggregate_address = [ + { + ipv4_address = "50.0.0.0" + ipv4_mask = "255.255.0.0" + } + ] + ipv4_unicast_redistribute_static = true ipv4_unicast_networks_mask = [ { network = "12.0.0.0" diff --git a/gen/definitions/bgp_address_family_ipv4.yaml b/gen/definitions/bgp_address_family_ipv4.yaml index eca96a36..4737e674 100644 --- a/gen/definitions/bgp_address_family_ipv4.yaml +++ b/gen/definitions/bgp_address_family_ipv4.yaml @@ -14,6 +14,17 @@ attributes: - yang_name: ipv4-unicast/redistribute/static tf_name: ipv4_unicast_redistribute_static example: true + - yang_name: ipv4-unicast/aggregate-address + tf_name: ipv4_unicast_aggregate_address + type: List + attributes: + - yang_name: ipv4-address + id: true + example: 10.0.0.0 + - yang_name: ipv4-mask + id: true + example: 255.255.0.0 + - 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 29c348b2..b69d9b77 100644 --- a/gen/definitions/bgp_address_family_ipv4_vrf.yaml +++ b/gen/definitions/bgp_address_family_ipv4_vrf.yaml @@ -22,6 +22,16 @@ attributes: - yang_name: ipv4-unicast/redistribute-vrf/connected tf_name: ipv4_unicast_redistribute_connected example: true + - yang_name: ipv4-unicast/aggregate-address + tf_name: ipv4_unicast_aggregate_address + type: List + attributes: + - yang_name: ipv4-address + id: true + example: 50.0.0.0 + - yang_name: ipv4-mask + id: true + example: 255.255.0.0 - yang_name: ipv4-unicast/redistribute-vrf/static tf_name: ipv4_unicast_redistribute_static example: true 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 d29d3b2a..d2ee6625 100644 --- a/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go +++ b/internal/provider/data_source_iosxe_bgp_address_family_ipv4.go @@ -79,6 +79,22 @@ func (d *BGPAddressFamilyIPv4DataSource) Schema(ctx context.Context, req datasou MarkdownDescription: "Static routes", Computed: true, }, + "ipv4_unicast_aggregate_address": schema.ListNestedAttribute{ + MarkdownDescription: "Configure BGP aggregate entries", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "ipv4_address": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "ipv4_mask": schema.StringAttribute{ + MarkdownDescription: "", + 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 c39994cb..59590f10 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 @@ -29,6 +29,8 @@ 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_aggregate_address.0.ipv4_address", "10.0.0.0")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_aggregate_address.0.ipv4_mask", "255.255.0.0")) 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")) @@ -65,6 +67,10 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv4Config() string { config += ` af_name = "unicast"` + "\n" config += ` ipv4_unicast_redistribute_connected = true` + "\n" config += ` ipv4_unicast_redistribute_static = true` + "\n" + config += ` ipv4_unicast_aggregate_address = [{` + "\n" + config += ` ipv4_address = "10.0.0.0"` + "\n" + config += ` ipv4_mask = "255.255.0.0"` + "\n" + config += ` }]` + "\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 cc641b8b..4226e7d0 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 @@ -88,6 +88,22 @@ func (d *BGPAddressFamilyIPv4VRFDataSource) Schema(ctx context.Context, req data MarkdownDescription: "Connected", Computed: true, }, + "ipv4_unicast_aggregate_address": schema.ListNestedAttribute{ + MarkdownDescription: "Configure BGP aggregate entries", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "ipv4_address": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + "ipv4_mask": schema.StringAttribute{ + MarkdownDescription: "", + Computed: true, + }, + }, + }, + }, "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 c73d3362..9716b178 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 @@ -30,6 +30,8 @@ func TestAccDataSourceIosxeBGPAddressFamilyIPv4VRF(t *testing.T) { 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.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_aggregate_address.0.ipv4_address", "50.0.0.0")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_aggregate_address.0.ipv4_mask", "255.255.0.0")) 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")) @@ -80,6 +82,10 @@ func testAccDataSourceIosxeBGPAddressFamilyIPv4VRFConfig() string { config += ` name = "VRF1"` + "\n" config += ` ipv4_unicast_advertise_l2vpn_evpn = true` + "\n" config += ` ipv4_unicast_redistribute_connected = true` + "\n" + config += ` ipv4_unicast_aggregate_address = [{` + "\n" + config += ` ipv4_address = "50.0.0.0"` + "\n" + config += ` ipv4_mask = "255.255.0.0"` + "\n" + config += ` }]` + "\n" config += ` ipv4_unicast_redistribute_static = true` + "\n" config += ` ipv4_unicast_networks_mask = [{` + "\n" config += ` network = "12.0.0.0"` + "\n" diff --git a/internal/provider/model_iosxe_bgp_address_family_ipv4.go b/internal/provider/model_iosxe_bgp_address_family_ipv4.go index 03f2a788..60e77705 100644 --- a/internal/provider/model_iosxe_bgp_address_family_ipv4.go +++ b/internal/provider/model_iosxe_bgp_address_family_ipv4.go @@ -35,26 +35,32 @@ 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"` - 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"` + 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"` + Ipv4UnicastAggregateAddress []BGPAddressFamilyIPv4Ipv4UnicastAggregateAddress `tfsdk:"ipv4_unicast_aggregate_address"` + 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"` - 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"` + 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"` + Ipv4UnicastAggregateAddress []BGPAddressFamilyIPv4Ipv4UnicastAggregateAddress `tfsdk:"ipv4_unicast_aggregate_address"` + Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4Ipv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` + Ipv4UnicastNetworks []BGPAddressFamilyIPv4Ipv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` +} +type BGPAddressFamilyIPv4Ipv4UnicastAggregateAddress struct { + Ipv4Address types.String `tfsdk:"ipv4_address"` + Ipv4Mask types.String `tfsdk:"ipv4_mask"` } type BGPAddressFamilyIPv4Ipv4UnicastNetworksMask struct { Network types.String `tfsdk:"network"` @@ -102,6 +108,17 @@ func (data BGPAddressFamilyIPv4) toBody(ctx context.Context) string { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv4-unicast.redistribute.static", map[string]string{}) } } + if len(data.Ipv4UnicastAggregateAddress) > 0 { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv4-unicast.aggregate-address", []interface{}{}) + for index, item := range data.Ipv4UnicastAggregateAddress { + if !item.Ipv4Address.IsNull() && !item.Ipv4Address.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv4-unicast.aggregate-address"+"."+strconv.Itoa(index)+"."+"ipv4-address", item.Ipv4Address.ValueString()) + } + if !item.Ipv4Mask.IsNull() && !item.Ipv4Mask.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"ipv4-unicast.aggregate-address"+"."+strconv.Itoa(index)+"."+"ipv4-mask", item.Ipv4Mask.ValueString()) + } + } + } 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 { @@ -168,6 +185,40 @@ func (data *BGPAddressFamilyIPv4) updateFromBody(ctx context.Context, res gjson. } else { data.Ipv4UnicastRedistributeStatic = types.BoolNull() } + for i := range data.Ipv4UnicastAggregateAddress { + keys := [...]string{"ipv4-address", "ipv4-mask"} + keyValues := [...]string{data.Ipv4UnicastAggregateAddress[i].Ipv4Address.ValueString(), data.Ipv4UnicastAggregateAddress[i].Ipv4Mask.ValueString()} + + var r gjson.Result + res.Get(prefix + "ipv4-unicast.aggregate-address").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + if v.Get(keys[ik]).String() == keyValues[ik] { + found = true + continue + } + found = false + break + } + if found { + r = v + return false + } + return true + }, + ) + if value := r.Get("ipv4-address"); value.Exists() && !data.Ipv4UnicastAggregateAddress[i].Ipv4Address.IsNull() { + data.Ipv4UnicastAggregateAddress[i].Ipv4Address = types.StringValue(value.String()) + } else { + data.Ipv4UnicastAggregateAddress[i].Ipv4Address = types.StringNull() + } + if value := r.Get("ipv4-mask"); value.Exists() && !data.Ipv4UnicastAggregateAddress[i].Ipv4Mask.IsNull() { + data.Ipv4UnicastAggregateAddress[i].Ipv4Mask = types.StringValue(value.String()) + } else { + data.Ipv4UnicastAggregateAddress[i].Ipv4Mask = types.StringNull() + } + } for i := range data.Ipv4UnicastNetworksMask { keys := [...]string{"number", "mask"} keyValues := [...]string{data.Ipv4UnicastNetworksMask[i].Network.ValueString(), data.Ipv4UnicastNetworksMask[i].Mask.ValueString()} @@ -276,6 +327,20 @@ func (data *BGPAddressFamilyIPv4Data) fromBody(ctx context.Context, res gjson.Re } else { data.Ipv4UnicastRedistributeStatic = types.BoolValue(false) } + if value := res.Get(prefix + "ipv4-unicast.aggregate-address"); value.Exists() { + data.Ipv4UnicastAggregateAddress = make([]BGPAddressFamilyIPv4Ipv4UnicastAggregateAddress, 0) + value.ForEach(func(k, v gjson.Result) bool { + item := BGPAddressFamilyIPv4Ipv4UnicastAggregateAddress{} + if cValue := v.Get("ipv4-address"); cValue.Exists() { + item.Ipv4Address = types.StringValue(cValue.String()) + } + if cValue := v.Get("ipv4-mask"); cValue.Exists() { + item.Ipv4Mask = types.StringValue(cValue.String()) + } + data.Ipv4UnicastAggregateAddress = append(data.Ipv4UnicastAggregateAddress, item) + return true + }) + } 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 { @@ -327,6 +392,37 @@ func (data *BGPAddressFamilyIPv4) getDeletedItems(ctx context.Context, state BGP if !state.Ipv4UnicastRedistributeStatic.IsNull() && data.Ipv4UnicastRedistributeStatic.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv4-unicast/redistribute/static", state.getPath())) } + for i := range state.Ipv4UnicastAggregateAddress { + stateKeyValues := [...]string{state.Ipv4UnicastAggregateAddress[i].Ipv4Address.ValueString(), state.Ipv4UnicastAggregateAddress[i].Ipv4Mask.ValueString()} + + emptyKeys := true + if !reflect.ValueOf(state.Ipv4UnicastAggregateAddress[i].Ipv4Address.ValueString()).IsZero() { + emptyKeys = false + } + if !reflect.ValueOf(state.Ipv4UnicastAggregateAddress[i].Ipv4Mask.ValueString()).IsZero() { + emptyKeys = false + } + if emptyKeys { + continue + } + + found := false + for j := range data.Ipv4UnicastAggregateAddress { + found = true + if state.Ipv4UnicastAggregateAddress[i].Ipv4Address.ValueString() != data.Ipv4UnicastAggregateAddress[j].Ipv4Address.ValueString() { + found = false + } + if state.Ipv4UnicastAggregateAddress[i].Ipv4Mask.ValueString() != data.Ipv4UnicastAggregateAddress[j].Ipv4Mask.ValueString() { + found = false + } + if found { + break + } + } + if !found { + deletedItems = append(deletedItems, fmt.Sprintf("%v/ipv4-unicast/aggregate-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","))) + } + } for i := range state.Ipv4UnicastNetworksMask { stateKeyValues := [...]string{state.Ipv4UnicastNetworksMask[i].Network.ValueString(), state.Ipv4UnicastNetworksMask[i].Mask.ValueString()} @@ -431,6 +527,11 @@ func (data *BGPAddressFamilyIPv4) getDeletePaths(ctx context.Context) []string { if !data.Ipv4UnicastRedistributeStatic.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv4-unicast/redistribute/static", data.getPath())) } + for i := range data.Ipv4UnicastAggregateAddress { + keyValues := [...]string{data.Ipv4UnicastAggregateAddress[i].Ipv4Address.ValueString(), data.Ipv4UnicastAggregateAddress[i].Ipv4Mask.ValueString()} + + deletePaths = append(deletePaths, fmt.Sprintf("%v/ipv4-unicast/aggregate-address=%v", data.getPath(), strings.Join(keyValues[:], ","))) + } 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 75733c45..3c94f1e8 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,17 @@ type BGPAddressFamilyIPv4VRFData struct { Vrfs []BGPAddressFamilyIPv4VRFVrfs `tfsdk:"vrfs"` } type BGPAddressFamilyIPv4VRFVrfs struct { - 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"` + Name types.String `tfsdk:"name"` + Ipv4UnicastAdvertiseL2vpnEvpn types.Bool `tfsdk:"ipv4_unicast_advertise_l2vpn_evpn"` + Ipv4UnicastRedistributeConnected types.Bool `tfsdk:"ipv4_unicast_redistribute_connected"` + Ipv4UnicastAggregateAddress []BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddress `tfsdk:"ipv4_unicast_aggregate_address"` + Ipv4UnicastRedistributeStatic types.Bool `tfsdk:"ipv4_unicast_redistribute_static"` + Ipv4UnicastNetworksMask []BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask `tfsdk:"ipv4_unicast_networks_mask"` + Ipv4UnicastNetworks []BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworks `tfsdk:"ipv4_unicast_networks"` +} +type BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddress struct { + Ipv4Address types.String `tfsdk:"ipv4_address"` + Ipv4Mask types.String `tfsdk:"ipv4_mask"` } type BGPAddressFamilyIPv4VRFVrfsIpv4UnicastNetworksMask struct { Network types.String `tfsdk:"network"` @@ -117,6 +122,17 @@ func (data BGPAddressFamilyIPv4VRF) toBody(ctx context.Context) string { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.redistribute-vrf.static", map[string]string{}) } } + if len(item.Ipv4UnicastAggregateAddress) > 0 { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.aggregate-address", []interface{}{}) + for cindex, citem := range item.Ipv4UnicastAggregateAddress { + if !citem.Ipv4Address.IsNull() && !citem.Ipv4Address.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.aggregate-address"+"."+strconv.Itoa(cindex)+"."+"ipv4-address", citem.Ipv4Address.ValueString()) + } + if !citem.Ipv4Mask.IsNull() && !citem.Ipv4Mask.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.aggregate-address"+"."+strconv.Itoa(cindex)+"."+"ipv4-mask", citem.Ipv4Mask.ValueString()) + } + } + } if len(item.Ipv4UnicastNetworksMask) > 0 { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"vrf"+"."+strconv.Itoa(index)+"."+"ipv4-unicast.network.with-mask", []interface{}{}) for cindex, citem := range item.Ipv4UnicastNetworksMask { @@ -223,6 +239,40 @@ func (data *BGPAddressFamilyIPv4VRF) updateFromBody(ctx context.Context, res gjs } else { data.Vrfs[i].Ipv4UnicastRedistributeConnected = types.BoolNull() } + for ci := range data.Vrfs[i].Ipv4UnicastAggregateAddress { + keys := [...]string{"ipv4-address", "ipv4-mask"} + keyValues := [...]string{data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Address.ValueString(), data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Mask.ValueString()} + + var cr gjson.Result + r.Get("ipv4-unicast.aggregate-address").ForEach( + func(_, v gjson.Result) bool { + found := false + for ik := range keys { + if v.Get(keys[ik]).String() == keyValues[ik] { + found = true + continue + } + found = false + break + } + if found { + cr = v + return false + } + return true + }, + ) + if value := cr.Get("ipv4-address"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Address.IsNull() { + data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Address = types.StringValue(value.String()) + } else { + data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Address = types.StringNull() + } + if value := cr.Get("ipv4-mask"); value.Exists() && !data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Mask.IsNull() { + data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Mask = types.StringValue(value.String()) + } else { + data.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Mask = types.StringNull() + } + } if value := r.Get("ipv4-unicast.redistribute-vrf.static"); !data.Vrfs[i].Ipv4UnicastRedistributeStatic.IsNull() { if value.Exists() { data.Vrfs[i].Ipv4UnicastRedistributeStatic = types.BoolValue(true) @@ -366,6 +416,20 @@ func (data *BGPAddressFamilyIPv4VRFData) fromBody(ctx context.Context, res gjson } else { item.Ipv4UnicastRedistributeConnected = types.BoolValue(false) } + if cValue := v.Get("ipv4-unicast.aggregate-address"); cValue.Exists() { + item.Ipv4UnicastAggregateAddress = make([]BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddress, 0) + cValue.ForEach(func(ck, cv gjson.Result) bool { + cItem := BGPAddressFamilyIPv4VRFVrfsIpv4UnicastAggregateAddress{} + if ccValue := cv.Get("ipv4-address"); ccValue.Exists() { + cItem.Ipv4Address = types.StringValue(ccValue.String()) + } + if ccValue := cv.Get("ipv4-mask"); ccValue.Exists() { + cItem.Ipv4Mask = types.StringValue(ccValue.String()) + } + item.Ipv4UnicastAggregateAddress = append(item.Ipv4UnicastAggregateAddress, cItem) + return true + }) + } if cValue := v.Get("ipv4-unicast.redistribute-vrf.static"); cValue.Exists() { item.Ipv4UnicastRedistributeStatic = types.BoolValue(true) } else { @@ -454,6 +518,37 @@ func (data *BGPAddressFamilyIPv4VRF) getDeletedItems(ctx context.Context, state if !state.Vrfs[i].Ipv4UnicastRedistributeConnected.IsNull() && data.Vrfs[j].Ipv4UnicastRedistributeConnected.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf=%v/ipv4-unicast/redistribute-vrf/connected", state.getPath(), strings.Join(stateKeyValues[:], ","))) } + for ci := range state.Vrfs[i].Ipv4UnicastAggregateAddress { + cstateKeyValues := [...]string{state.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Address.ValueString(), state.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Mask.ValueString()} + + cemptyKeys := true + if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Address.ValueString()).IsZero() { + cemptyKeys = false + } + if !reflect.ValueOf(state.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Mask.ValueString()).IsZero() { + cemptyKeys = false + } + if cemptyKeys { + continue + } + + found := false + for cj := range data.Vrfs[j].Ipv4UnicastAggregateAddress { + found = true + if state.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Address.ValueString() != data.Vrfs[j].Ipv4UnicastAggregateAddress[cj].Ipv4Address.ValueString() { + found = false + } + if state.Vrfs[i].Ipv4UnicastAggregateAddress[ci].Ipv4Mask.ValueString() != data.Vrfs[j].Ipv4UnicastAggregateAddress[cj].Ipv4Mask.ValueString() { + found = false + } + if found { + break + } + } + if !found { + deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf=%v/ipv4-unicast/aggregate-address=%v", state.getPath(), strings.Join(stateKeyValues[:], ","), strings.Join(cstateKeyValues[:], ","))) + } + } if !state.Vrfs[i].Ipv4UnicastRedistributeStatic.IsNull() && data.Vrfs[j].Ipv4UnicastRedistributeStatic.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/vrf=%v/ipv4-unicast/redistribute-vrf/static", state.getPath(), strings.Join(stateKeyValues[:], ","))) } @@ -552,6 +647,7 @@ func (data *BGPAddressFamilyIPv4VRF) getEmptyLeafsDelete(ctx context.Context) [] 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].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/resource_iosxe_bgp_address_family_ipv4.go b/internal/provider/resource_iosxe_bgp_address_family_ipv4.go index 9d37609f..9ba56422 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv4.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4.go @@ -98,6 +98,28 @@ func (r *BGPAddressFamilyIPv4Resource) Schema(ctx context.Context, req resource. MarkdownDescription: helpers.NewAttributeDescription("Static routes").String, Optional: true, }, + "ipv4_unicast_aggregate_address": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Configure BGP aggregate entries").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "ipv4_address": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Required: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?`), ""), + }, + }, + "ipv4_mask": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Required: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?`), ""), + }, + }, + }, + }, + }, "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 89994403..cb642e8e 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_test.go @@ -30,6 +30,8 @@ func TestAccIosxeBGPAddressFamilyIPv4(t *testing.T) { 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_aggregate_address.0.ipv4_address", "10.0.0.0")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4.test", "ipv4_unicast_aggregate_address.0.ipv4_mask", "255.255.0.0")) 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")) @@ -82,6 +84,10 @@ func testAccIosxeBGPAddressFamilyIPv4Config_all() string { config += ` af_name = "unicast"` + "\n" config += ` ipv4_unicast_redistribute_connected = true` + "\n" config += ` ipv4_unicast_redistribute_static = true` + "\n" + config += ` ipv4_unicast_aggregate_address = [{` + "\n" + config += ` ipv4_address = "10.0.0.0"` + "\n" + config += ` ipv4_mask = "255.255.0.0"` + "\n" + config += ` }]` + "\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 9efc0adc..52f801e1 100644 --- a/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go +++ b/internal/provider/resource_iosxe_bgp_address_family_ipv4_vrf.go @@ -107,6 +107,28 @@ func (r *BGPAddressFamilyIPv4VRFResource) Schema(ctx context.Context, req resour MarkdownDescription: helpers.NewAttributeDescription("Connected").String, Optional: true, }, + "ipv4_unicast_aggregate_address": schema.ListNestedAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Configure BGP aggregate entries").String, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "ipv4_address": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Required: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?`), ""), + }, + }, + "ipv4_mask": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("").String, + Required: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?`), ""), + }, + }, + }, + }, + }, "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 ec0391f7..c496869e 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 @@ -31,6 +31,8 @@ func TestAccIosxeBGPAddressFamilyIPv4VRF(t *testing.T) { 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.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_aggregate_address.0.ipv4_address", "50.0.0.0")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_bgp_address_family_ipv4_vrf.test", "vrfs.0.ipv4_unicast_aggregate_address.0.ipv4_mask", "255.255.0.0")) 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")) @@ -94,6 +96,10 @@ func testAccIosxeBGPAddressFamilyIPv4VRFConfig_all() string { config += ` name = "VRF1"` + "\n" config += ` ipv4_unicast_advertise_l2vpn_evpn = true` + "\n" config += ` ipv4_unicast_redistribute_connected = true` + "\n" + config += ` ipv4_unicast_aggregate_address = [{` + "\n" + config += ` ipv4_address = "50.0.0.0"` + "\n" + config += ` ipv4_mask = "255.255.0.0"` + "\n" + config += ` }]` + "\n" config += ` ipv4_unicast_redistribute_static = true` + "\n" config += ` ipv4_unicast_networks_mask = [{` + "\n" config += ` network = "12.0.0.0"` + "\n"