From 54d1cba18122a79ddf1ab9ab9966d3a23f232644 Mon Sep 17 00:00:00 2001 From: danischm Date: Wed, 13 Sep 2023 13:50:42 +0200 Subject: [PATCH] Add route reflector client attribute to bgp neighbor resources --- CHANGELOG.md | 1 + .../router_bgp_neighbor_address_family.md | 1 + .../data-sources/router_bgp_neighbor_group.md | 1 + docs/guides/changelog.md | 1 + .../router_bgp_neighbor_address_family.md | 2 ++ docs/resources/router_bgp_neighbor_group.md | 2 ++ .../resource.tf | 1 + .../resource.tf | 1 + .../router_bgp_neighbor_address_family.yaml | 2 ++ .../router_bgp_neighbor_group.yaml | 2 ++ ...osxr_router_bgp_neighbor_address_family.go | 4 +++ ...router_bgp_neighbor_address_family_test.go | 2 ++ ..._source_iosxr_router_bgp_neighbor_group.go | 4 +++ ...ce_iosxr_router_bgp_neighbor_group_test.go | 2 ++ ...osxr_router_bgp_neighbor_address_family.go | 27 +++++++++++++++++++ .../model_iosxr_router_bgp_neighbor_group.go | 23 ++++++++++++++++ ...osxr_router_bgp_neighbor_address_family.go | 4 +++ ...router_bgp_neighbor_address_family_test.go | 2 ++ ...esource_iosxr_router_bgp_neighbor_group.go | 4 +++ ...ce_iosxr_router_bgp_neighbor_group_test.go | 2 ++ templates/guides/changelog.md.tmpl | 1 + 21 files changed, 89 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 062774b8..69f2a725 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Add support for leaf-lists to `iosxr_gnmi` resource - Add `port` and `operator` attributes to `iosxr_logging_vrf` resource and data source - Add `iosxr_router_hsrp_interface_address_family_ipv6_group_v2` resource and data source +- Add `route_reflector_client` to `iosxr_router_bgp_neighbor_address_family` and `iosxr_router_bgp_neighbor_group` resource and data source ## 0.2.5 diff --git a/docs/data-sources/router_bgp_neighbor_address_family.md b/docs/data-sources/router_bgp_neighbor_address_family.md index 387ea110..71522a34 100644 --- a/docs/data-sources/router_bgp_neighbor_address_family.md +++ b/docs/data-sources/router_bgp_neighbor_address_family.md @@ -40,4 +40,5 @@ data "iosxr_router_bgp_neighbor_address_family" "example" { - `id` (String) The path of the retrieved object. - `import_stitching_rt_re_originate_stitching_rt` (Boolean) Reoriginate imported routes by attaching stitching RTs - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent +- `route_reflector_client` (Boolean) Configure a neighbor as Route Reflector client - `route_reflector_client_inheritance_disable` (Boolean) Prevent route-reflector-client from being inherited from the parent diff --git a/docs/data-sources/router_bgp_neighbor_group.md b/docs/data-sources/router_bgp_neighbor_group.md index 4f5c0cd1..8aa57c06 100644 --- a/docs/data-sources/router_bgp_neighbor_group.md +++ b/docs/data-sources/router_bgp_neighbor_group.md @@ -54,5 +54,6 @@ Read-Only: - `af_name` (String) Enter Address Family command mode - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent +- `route_reflector_client` (Boolean) Configure a neighbor as Route Reflector client - `route_reflector_client_inheritance_disable` (Boolean) Prevent route-reflector-client from being inherited from the parent - `soft_reconfiguration_inbound_always` (Boolean) Always use soft reconfig, even if route refresh is supported diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index ff2ee6b1..8535392b 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -13,6 +13,7 @@ description: |- - Add support for leaf-lists to `iosxr_gnmi` resource - Add `port` and `operator` attributes to `iosxr_logging_vrf` resource and data source - Add `iosxr_router_hsrp_interface_address_family_ipv6_group_v2` resource and data source +- Add `route_reflector_client` to `iosxr_router_bgp_neighbor_address_family` and `iosxr_router_bgp_neighbor_group` resource and data source ## 0.2.5 diff --git a/docs/resources/router_bgp_neighbor_address_family.md b/docs/resources/router_bgp_neighbor_address_family.md index 026dc0e7..f15aba41 100644 --- a/docs/resources/router_bgp_neighbor_address_family.md +++ b/docs/resources/router_bgp_neighbor_address_family.md @@ -18,6 +18,7 @@ resource "iosxr_router_bgp_neighbor_address_family" "example" { neighbor_address = "10.1.1.2" af_name = "vpnv4-unicast" import_stitching_rt_re_originate_stitching_rt = true + route_reflector_client = true route_reflector_client_inheritance_disable = true advertise_vpnv4_unicast_enable_re_originated_stitching_rt = true next_hop_self_inheritance_disable = true @@ -44,6 +45,7 @@ resource "iosxr_router_bgp_neighbor_address_family" "example" { - `encapsulation_type_srv6` (Boolean) SRv6 encapsulation - `import_stitching_rt_re_originate_stitching_rt` (Boolean) Reoriginate imported routes by attaching stitching RTs - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent +- `route_reflector_client` (Boolean) Configure a neighbor as Route Reflector client - `route_reflector_client_inheritance_disable` (Boolean) Prevent route-reflector-client from being inherited from the parent ### Read-Only diff --git a/docs/resources/router_bgp_neighbor_group.md b/docs/resources/router_bgp_neighbor_group.md index 35735f19..082a9ab1 100644 --- a/docs/resources/router_bgp_neighbor_group.md +++ b/docs/resources/router_bgp_neighbor_group.md @@ -29,6 +29,7 @@ resource "iosxr_router_bgp_neighbor_group" "example" { af_name = "ipv4-labeled-unicast" soft_reconfiguration_inbound_always = true next_hop_self_inheritance_disable = true + route_reflector_client = true route_reflector_client_inheritance_disable = true } ] @@ -80,6 +81,7 @@ Required: Optional: - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent +- `route_reflector_client` (Boolean) Configure a neighbor as Route Reflector client - `route_reflector_client_inheritance_disable` (Boolean) Prevent route-reflector-client from being inherited from the parent - `soft_reconfiguration_inbound_always` (Boolean) Always use soft reconfig, even if route refresh is supported diff --git a/examples/resources/iosxr_router_bgp_neighbor_address_family/resource.tf b/examples/resources/iosxr_router_bgp_neighbor_address_family/resource.tf index f4e1fd4f..a7ec4b5c 100644 --- a/examples/resources/iosxr_router_bgp_neighbor_address_family/resource.tf +++ b/examples/resources/iosxr_router_bgp_neighbor_address_family/resource.tf @@ -3,6 +3,7 @@ resource "iosxr_router_bgp_neighbor_address_family" "example" { neighbor_address = "10.1.1.2" af_name = "vpnv4-unicast" import_stitching_rt_re_originate_stitching_rt = true + route_reflector_client = true route_reflector_client_inheritance_disable = true advertise_vpnv4_unicast_enable_re_originated_stitching_rt = true next_hop_self_inheritance_disable = true diff --git a/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf b/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf index d7dd189d..22ce411b 100644 --- a/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf +++ b/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf @@ -14,6 +14,7 @@ resource "iosxr_router_bgp_neighbor_group" "example" { af_name = "ipv4-labeled-unicast" soft_reconfiguration_inbound_always = true next_hop_self_inheritance_disable = true + route_reflector_client = true route_reflector_client_inheritance_disable = true } ] diff --git a/gen/definitions/router_bgp_neighbor_address_family.yaml b/gen/definitions/router_bgp_neighbor_address_family.yaml index 77ecd44e..9b37da5b 100644 --- a/gen/definitions/router_bgp_neighbor_address_family.yaml +++ b/gen/definitions/router_bgp_neighbor_address_family.yaml @@ -11,6 +11,8 @@ attributes: example: vpnv4-unicast - yang_name: import/stitching-rt/re-originate/stitching-rt example: true + - yang_name: route-reflector-client + example: true - yang_name: route-reflector-client/inheritance-disable example: true - yang_name: advertise/vpnv4/unicast/enable/re-originated/stitching-rt diff --git a/gen/definitions/router_bgp_neighbor_group.yaml b/gen/definitions/router_bgp_neighbor_group.yaml index bbd5cd21..4ae926f2 100644 --- a/gen/definitions/router_bgp_neighbor_group.yaml +++ b/gen/definitions/router_bgp_neighbor_group.yaml @@ -49,6 +49,8 @@ attributes: example: true - yang_name: next-hop-self/inheritance-disable example: true + - yang_name: route-reflector-client + example: true - yang_name: route-reflector-client/inheritance-disable example: true diff --git a/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family.go b/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family.go index c1f02a14..d9497d8c 100644 --- a/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family.go +++ b/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family.go @@ -78,6 +78,10 @@ func (d *RouterBGPNeighborAddressFamilyDataSource) Schema(ctx context.Context, r MarkdownDescription: "Reoriginate imported routes by attaching stitching RTs", Computed: true, }, + "route_reflector_client": schema.BoolAttribute{ + MarkdownDescription: "Configure a neighbor as Route Reflector client", + Computed: true, + }, "route_reflector_client_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: "Prevent route-reflector-client from being inherited from the parent", Computed: true, diff --git a/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family_test.go b/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family_test.go index 345ccb34..4679f98a 100644 --- a/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family_test.go +++ b/internal/provider/data_source_iosxr_router_bgp_neighbor_address_family_test.go @@ -28,6 +28,7 @@ import ( func TestAccDataSourceIosxrRouterBGPNeighborAddressFamily(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_address_family.test", "import_stitching_rt_re_originate_stitching_rt", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_address_family.test", "route_reflector_client", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_address_family.test", "route_reflector_client_inheritance_disable", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_address_family.test", "advertise_vpnv4_unicast_enable_re_originated_stitching_rt", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_address_family.test", "next_hop_self_inheritance_disable", "true")) @@ -82,6 +83,7 @@ func testAccDataSourceIosxrRouterBGPNeighborAddressFamilyConfig() string { config += ` neighbor_address = "10.1.1.2"` + "\n" config += ` af_name = "vpnv4-unicast"` + "\n" config += ` import_stitching_rt_re_originate_stitching_rt = true` + "\n" + config += ` route_reflector_client = true` + "\n" config += ` route_reflector_client_inheritance_disable = true` + "\n" config += ` advertise_vpnv4_unicast_enable_re_originated_stitching_rt = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" diff --git a/internal/provider/data_source_iosxr_router_bgp_neighbor_group.go b/internal/provider/data_source_iosxr_router_bgp_neighbor_group.go index 781389ff..5cc37c6b 100644 --- a/internal/provider/data_source_iosxr_router_bgp_neighbor_group.go +++ b/internal/provider/data_source_iosxr_router_bgp_neighbor_group.go @@ -131,6 +131,10 @@ func (d *RouterBGPNeighborGroupDataSource) Schema(ctx context.Context, req datas MarkdownDescription: "Prevent next-hop-self from being inherited from the parent", Computed: true, }, + "route_reflector_client": schema.BoolAttribute{ + MarkdownDescription: "Configure a neighbor as Route Reflector client", + Computed: true, + }, "route_reflector_client_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: "Prevent route-reflector-client from being inherited from the parent", Computed: true, diff --git a/internal/provider/data_source_iosxr_router_bgp_neighbor_group_test.go b/internal/provider/data_source_iosxr_router_bgp_neighbor_group_test.go index 76052e6b..15aa4aa3 100644 --- a/internal/provider/data_source_iosxr_router_bgp_neighbor_group_test.go +++ b/internal/provider/data_source_iosxr_router_bgp_neighbor_group_test.go @@ -38,6 +38,7 @@ func TestAccDataSourceIosxrRouterBGPNeighborGroup(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_group.test", "address_families.0.af_name", "ipv4-labeled-unicast")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_group.test", "address_families.0.soft_reconfiguration_inbound_always", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_group.test", "address_families.0.next_hop_self_inheritance_disable", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_group.test", "address_families.0.route_reflector_client", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_group.test", "address_families.0.route_reflector_client_inheritance_disable", "true")) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -78,6 +79,7 @@ func testAccDataSourceIosxrRouterBGPNeighborGroupConfig() string { config += ` af_name = "ipv4-labeled-unicast"` + "\n" config += ` soft_reconfiguration_inbound_always = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" + config += ` route_reflector_client = true` + "\n" config += ` route_reflector_client_inheritance_disable = true` + "\n" config += ` }]` + "\n" config += ` depends_on = [iosxr_gnmi.PreReq0, ]` + "\n" diff --git a/internal/provider/model_iosxr_router_bgp_neighbor_address_family.go b/internal/provider/model_iosxr_router_bgp_neighbor_address_family.go index 81704943..9d660562 100644 --- a/internal/provider/model_iosxr_router_bgp_neighbor_address_family.go +++ b/internal/provider/model_iosxr_router_bgp_neighbor_address_family.go @@ -36,6 +36,7 @@ type RouterBGPNeighborAddressFamily struct { NeighborAddress types.String `tfsdk:"neighbor_address"` AfName types.String `tfsdk:"af_name"` ImportStitchingRtReOriginateStitchingRt types.Bool `tfsdk:"import_stitching_rt_re_originate_stitching_rt"` + RouteReflectorClient types.Bool `tfsdk:"route_reflector_client"` RouteReflectorClientInheritanceDisable types.Bool `tfsdk:"route_reflector_client_inheritance_disable"` AdvertiseVpnv4UnicastEnableReOriginatedStitchingRt types.Bool `tfsdk:"advertise_vpnv4_unicast_enable_re_originated_stitching_rt"` NextHopSelfInheritanceDisable types.Bool `tfsdk:"next_hop_self_inheritance_disable"` @@ -49,6 +50,7 @@ type RouterBGPNeighborAddressFamilyData struct { NeighborAddress types.String `tfsdk:"neighbor_address"` AfName types.String `tfsdk:"af_name"` ImportStitchingRtReOriginateStitchingRt types.Bool `tfsdk:"import_stitching_rt_re_originate_stitching_rt"` + RouteReflectorClient types.Bool `tfsdk:"route_reflector_client"` RouteReflectorClientInheritanceDisable types.Bool `tfsdk:"route_reflector_client_inheritance_disable"` AdvertiseVpnv4UnicastEnableReOriginatedStitchingRt types.Bool `tfsdk:"advertise_vpnv4_unicast_enable_re_originated_stitching_rt"` NextHopSelfInheritanceDisable types.Bool `tfsdk:"next_hop_self_inheritance_disable"` @@ -73,6 +75,11 @@ func (data RouterBGPNeighborAddressFamily) toBody(ctx context.Context) string { body, _ = sjson.Set(body, "import.stitching-rt.re-originate.stitching-rt", map[string]string{}) } } + if !data.RouteReflectorClient.IsNull() && !data.RouteReflectorClient.IsUnknown() { + if data.RouteReflectorClient.ValueBool() { + body, _ = sjson.Set(body, "route-reflector-client", map[string]string{}) + } + } if !data.RouteReflectorClientInheritanceDisable.IsNull() && !data.RouteReflectorClientInheritanceDisable.IsUnknown() { if data.RouteReflectorClientInheritanceDisable.ValueBool() { body, _ = sjson.Set(body, "route-reflector-client.inheritance-disable", map[string]string{}) @@ -106,6 +113,15 @@ func (data *RouterBGPNeighborAddressFamily) updateFromBody(ctx context.Context, } else { data.ImportStitchingRtReOriginateStitchingRt = types.BoolNull() } + if value := gjson.GetBytes(res, "route-reflector-client"); !data.RouteReflectorClient.IsNull() { + if value.Exists() { + data.RouteReflectorClient = types.BoolValue(true) + } else { + data.RouteReflectorClient = types.BoolValue(false) + } + } else { + data.RouteReflectorClient = types.BoolNull() + } if value := gjson.GetBytes(res, "route-reflector-client.inheritance-disable"); !data.RouteReflectorClientInheritanceDisable.IsNull() { if value.Exists() { data.RouteReflectorClientInheritanceDisable = types.BoolValue(true) @@ -150,6 +166,11 @@ func (data *RouterBGPNeighborAddressFamilyData) fromBody(ctx context.Context, re } else { data.ImportStitchingRtReOriginateStitchingRt = types.BoolValue(false) } + if value := gjson.GetBytes(res, "route-reflector-client"); value.Exists() { + data.RouteReflectorClient = types.BoolValue(true) + } else { + data.RouteReflectorClient = types.BoolValue(false) + } if value := gjson.GetBytes(res, "route-reflector-client.inheritance-disable"); value.Exists() { data.RouteReflectorClientInheritanceDisable = types.BoolValue(true) } else { @@ -182,6 +203,9 @@ func (data *RouterBGPNeighborAddressFamily) getEmptyLeafsDelete(ctx context.Cont if !data.ImportStitchingRtReOriginateStitchingRt.IsNull() && !data.ImportStitchingRtReOriginateStitchingRt.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/import/stitching-rt/re-originate/stitching-rt", data.getPath())) } + if !data.RouteReflectorClient.IsNull() && !data.RouteReflectorClient.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/route-reflector-client", data.getPath())) + } if !data.RouteReflectorClientInheritanceDisable.IsNull() && !data.RouteReflectorClientInheritanceDisable.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/route-reflector-client/inheritance-disable", data.getPath())) } @@ -202,6 +226,9 @@ func (data *RouterBGPNeighborAddressFamily) getDeletePaths(ctx context.Context) if !data.ImportStitchingRtReOriginateStitchingRt.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/import/stitching-rt/re-originate/stitching-rt", data.getPath())) } + if !data.RouteReflectorClient.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/route-reflector-client", data.getPath())) + } if !data.RouteReflectorClientInheritanceDisable.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/route-reflector-client/inheritance-disable", data.getPath())) } diff --git a/internal/provider/model_iosxr_router_bgp_neighbor_group.go b/internal/provider/model_iosxr_router_bgp_neighbor_group.go index 046af093..94e473e7 100644 --- a/internal/provider/model_iosxr_router_bgp_neighbor_group.go +++ b/internal/provider/model_iosxr_router_bgp_neighbor_group.go @@ -72,6 +72,7 @@ type RouterBGPNeighborGroupAddressFamilies struct { AfName types.String `tfsdk:"af_name"` SoftReconfigurationInboundAlways types.Bool `tfsdk:"soft_reconfiguration_inbound_always"` NextHopSelfInheritanceDisable types.Bool `tfsdk:"next_hop_self_inheritance_disable"` + RouteReflectorClient types.Bool `tfsdk:"route_reflector_client"` RouteReflectorClientInheritanceDisable types.Bool `tfsdk:"route_reflector_client_inheritance_disable"` } @@ -145,6 +146,11 @@ func (data RouterBGPNeighborGroup) toBody(ctx context.Context) string { body, _ = sjson.Set(body, "address-families.address-family"+"."+strconv.Itoa(index)+"."+"next-hop-self.inheritance-disable", map[string]string{}) } } + if !item.RouteReflectorClient.IsNull() && !item.RouteReflectorClient.IsUnknown() { + if item.RouteReflectorClient.ValueBool() { + body, _ = sjson.Set(body, "address-families.address-family"+"."+strconv.Itoa(index)+"."+"route-reflector-client", map[string]string{}) + } + } if !item.RouteReflectorClientInheritanceDisable.IsNull() && !item.RouteReflectorClientInheritanceDisable.IsUnknown() { if item.RouteReflectorClientInheritanceDisable.ValueBool() { body, _ = sjson.Set(body, "address-families.address-family"+"."+strconv.Itoa(index)+"."+"route-reflector-client.inheritance-disable", map[string]string{}) @@ -273,6 +279,15 @@ func (data *RouterBGPNeighborGroup) updateFromBody(ctx context.Context, res []by } else { data.AddressFamilies[i].NextHopSelfInheritanceDisable = types.BoolNull() } + if value := r.Get("route-reflector-client"); !data.AddressFamilies[i].RouteReflectorClient.IsNull() { + if value.Exists() { + data.AddressFamilies[i].RouteReflectorClient = types.BoolValue(true) + } else { + data.AddressFamilies[i].RouteReflectorClient = types.BoolValue(false) + } + } else { + data.AddressFamilies[i].RouteReflectorClient = types.BoolNull() + } if value := r.Get("route-reflector-client.inheritance-disable"); !data.AddressFamilies[i].RouteReflectorClientInheritanceDisable.IsNull() { if value.Exists() { data.AddressFamilies[i].RouteReflectorClientInheritanceDisable = types.BoolValue(true) @@ -344,6 +359,11 @@ func (data *RouterBGPNeighborGroupData) fromBody(ctx context.Context, res []byte } else { item.NextHopSelfInheritanceDisable = types.BoolValue(false) } + if cValue := v.Get("route-reflector-client"); cValue.Exists() { + item.RouteReflectorClient = types.BoolValue(true) + } else { + item.RouteReflectorClient = types.BoolValue(false) + } if cValue := v.Get("route-reflector-client.inheritance-disable"); cValue.Exists() { item.RouteReflectorClientInheritanceDisable = types.BoolValue(true) } else { @@ -417,6 +437,9 @@ func (data *RouterBGPNeighborGroup) getEmptyLeafsDelete(ctx context.Context) []s if !data.AddressFamilies[i].NextHopSelfInheritanceDisable.IsNull() && !data.AddressFamilies[i].NextHopSelfInheritanceDisable.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-families/address-family%v/next-hop-self/inheritance-disable", data.getPath(), keyString)) } + if !data.AddressFamilies[i].RouteReflectorClient.IsNull() && !data.AddressFamilies[i].RouteReflectorClient.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-families/address-family%v/route-reflector-client", data.getPath(), keyString)) + } if !data.AddressFamilies[i].RouteReflectorClientInheritanceDisable.IsNull() && !data.AddressFamilies[i].RouteReflectorClientInheritanceDisable.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-families/address-family%v/route-reflector-client/inheritance-disable", data.getPath(), keyString)) } diff --git a/internal/provider/resource_iosxr_router_bgp_neighbor_address_family.go b/internal/provider/resource_iosxr_router_bgp_neighbor_address_family.go index de62dd46..b21478ff 100644 --- a/internal/provider/resource_iosxr_router_bgp_neighbor_address_family.go +++ b/internal/provider/resource_iosxr_router_bgp_neighbor_address_family.go @@ -100,6 +100,10 @@ func (r *RouterBGPNeighborAddressFamilyResource) Schema(ctx context.Context, req MarkdownDescription: helpers.NewAttributeDescription("Reoriginate imported routes by attaching stitching RTs").String, Optional: true, }, + "route_reflector_client": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Configure a neighbor as Route Reflector client").String, + Optional: true, + }, "route_reflector_client_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Prevent route-reflector-client from being inherited from the parent").String, Optional: true, diff --git a/internal/provider/resource_iosxr_router_bgp_neighbor_address_family_test.go b/internal/provider/resource_iosxr_router_bgp_neighbor_address_family_test.go index 3b34d641..8844a53c 100644 --- a/internal/provider/resource_iosxr_router_bgp_neighbor_address_family_test.go +++ b/internal/provider/resource_iosxr_router_bgp_neighbor_address_family_test.go @@ -30,6 +30,7 @@ func TestAccIosxrRouterBGPNeighborAddressFamily(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_address_family.test", "af_name", "vpnv4-unicast")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_address_family.test", "import_stitching_rt_re_originate_stitching_rt", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_address_family.test", "route_reflector_client", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_address_family.test", "route_reflector_client_inheritance_disable", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_address_family.test", "advertise_vpnv4_unicast_enable_re_originated_stitching_rt", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_address_family.test", "next_hop_self_inheritance_disable", "true")) @@ -103,6 +104,7 @@ func testAccIosxrRouterBGPNeighborAddressFamilyConfig_all() string { config += ` neighbor_address = "10.1.1.2"` + "\n" config += ` af_name = "vpnv4-unicast"` + "\n" config += ` import_stitching_rt_re_originate_stitching_rt = true` + "\n" + config += ` route_reflector_client = true` + "\n" config += ` route_reflector_client_inheritance_disable = true` + "\n" config += ` advertise_vpnv4_unicast_enable_re_originated_stitching_rt = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" diff --git a/internal/provider/resource_iosxr_router_bgp_neighbor_group.go b/internal/provider/resource_iosxr_router_bgp_neighbor_group.go index 78d7aa6a..daabbfae 100644 --- a/internal/provider/resource_iosxr_router_bgp_neighbor_group.go +++ b/internal/provider/resource_iosxr_router_bgp_neighbor_group.go @@ -174,6 +174,10 @@ func (r *RouterBGPNeighborGroupResource) Schema(ctx context.Context, req resourc MarkdownDescription: helpers.NewAttributeDescription("Prevent next-hop-self from being inherited from the parent").String, Optional: true, }, + "route_reflector_client": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Configure a neighbor as Route Reflector client").String, + Optional: true, + }, "route_reflector_client_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Prevent route-reflector-client from being inherited from the parent").String, Optional: true, diff --git a/internal/provider/resource_iosxr_router_bgp_neighbor_group_test.go b/internal/provider/resource_iosxr_router_bgp_neighbor_group_test.go index 30e61165..5e85789d 100644 --- a/internal/provider/resource_iosxr_router_bgp_neighbor_group_test.go +++ b/internal/provider/resource_iosxr_router_bgp_neighbor_group_test.go @@ -40,6 +40,7 @@ func TestAccIosxrRouterBGPNeighborGroup(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_group.test", "address_families.0.af_name", "ipv4-labeled-unicast")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_group.test", "address_families.0.soft_reconfiguration_inbound_always", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_group.test", "address_families.0.next_hop_self_inheritance_disable", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_group.test", "address_families.0.route_reflector_client", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_group.test", "address_families.0.route_reflector_client_inheritance_disable", "true")) var steps []resource.TestStep if os.Getenv("SKIP_MINIMUM_TEST") == "" { @@ -99,6 +100,7 @@ func testAccIosxrRouterBGPNeighborGroupConfig_all() string { config += ` af_name = "ipv4-labeled-unicast"` + "\n" config += ` soft_reconfiguration_inbound_always = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" + config += ` route_reflector_client = true` + "\n" config += ` route_reflector_client_inheritance_disable = true` + "\n" config += ` }]` + "\n" config += ` depends_on = [iosxr_gnmi.PreReq0, ]` + "\n" diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index ff2ee6b1..8535392b 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -13,6 +13,7 @@ description: |- - Add support for leaf-lists to `iosxr_gnmi` resource - Add `port` and `operator` attributes to `iosxr_logging_vrf` resource and data source - Add `iosxr_router_hsrp_interface_address_family_ipv6_group_v2` resource and data source +- Add `route_reflector_client` to `iosxr_router_bgp_neighbor_address_family` and `iosxr_router_bgp_neighbor_group` resource and data source ## 0.2.5