diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc169cb..1dd5950a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ - Add `iosxr_router_static_vrf_ipv4_multicast` resource and data source - Add `iosxr_router_static_vrf_ipv6_unicast` resource and data source - Add `iosxr_router_static_vrf_ipv6_multicast` resource and data source +- Add `next_hop_self` to `iosxr_router_bgp_neighbor_group` resource and data source +- Add `next_hop_self` to `iosxr_router_bgp_vrf_neighbor_address_family` resource and data source ## 0.4.0 diff --git a/docs/data-sources/router_bgp_neighbor_group.md b/docs/data-sources/router_bgp_neighbor_group.md index 0d31223e..8f42e31f 100644 --- a/docs/data-sources/router_bgp_neighbor_group.md +++ b/docs/data-sources/router_bgp_neighbor_group.md @@ -56,6 +56,7 @@ data "iosxr_router_bgp_neighbor_group" "example" { Read-Only: - `af_name` (String) Enter Address Family command mode +- `next_hop_self` (Boolean) Disable the next hop calculation for this neighbor - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent - `route_policy_in` (String) Apply route policy to inbound routes - `route_policy_out` (String) Apply route policy to outbound routes diff --git a/docs/data-sources/router_bgp_vrf_neighbor_address_family.md b/docs/data-sources/router_bgp_vrf_neighbor_address_family.md index 257443b4..433c3750 100644 --- a/docs/data-sources/router_bgp_vrf_neighbor_address_family.md +++ b/docs/data-sources/router_bgp_vrf_neighbor_address_family.md @@ -40,6 +40,7 @@ data "iosxr_router_bgp_vrf_neighbor_address_family" "example" { - `default_originate_inheritance_disable` (Boolean) Prevent default-originate being inherited from a parent group - `default_originate_route_policy` (String) Route policy to specify criteria to originate default - `id` (String) The path of the retrieved object. +- `next_hop_self` (Boolean) Disable the next hop calculation for this neighbor - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent - `remove_private_as_inheritance_disable` (Boolean) Prevent remove-private-AS from being inherited from the parent - `route_policy_in` (String) Apply route policy to inbound routes diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index c12fd023..95ec8b8d 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -16,6 +16,8 @@ description: |- - Add `iosxr_router_static_vrf_ipv4_multicast` resource and data source - Add `iosxr_router_static_vrf_ipv6_unicast` resource and data source - Add `iosxr_router_static_vrf_ipv6_multicast` resource and data source +- Add `next_hop_self` to `iosxr_router_bgp_neighbor_group` resource and data source +- Add `next_hop_self` to `iosxr_router_bgp_vrf_neighbor_address_family` resource and data source ## 0.4.0 diff --git a/docs/resources/router_bgp_neighbor_group.md b/docs/resources/router_bgp_neighbor_group.md index bd2c7ce8..45fba2db 100644 --- a/docs/resources/router_bgp_neighbor_group.md +++ b/docs/resources/router_bgp_neighbor_group.md @@ -28,6 +28,7 @@ resource "iosxr_router_bgp_neighbor_group" "example" { { af_name = "ipv4-labeled-unicast" soft_reconfiguration_inbound_always = true + next_hop_self = true next_hop_self_inheritance_disable = true route_reflector_client = true route_reflector_client_inheritance_disable = true @@ -89,6 +90,7 @@ Required: Optional: +- `next_hop_self` (Boolean) Disable the next hop calculation for this neighbor - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent - `route_policy_in` (String) Apply route policy to inbound routes - `route_policy_out` (String) Apply route policy to outbound routes diff --git a/docs/resources/router_bgp_vrf_neighbor_address_family.md b/docs/resources/router_bgp_vrf_neighbor_address_family.md index 96ed17c3..058555dd 100644 --- a/docs/resources/router_bgp_vrf_neighbor_address_family.md +++ b/docs/resources/router_bgp_vrf_neighbor_address_family.md @@ -21,6 +21,7 @@ resource "iosxr_router_bgp_vrf_neighbor_address_family" "example" { route_policy_in = "ROUTE_POLICY_1" route_policy_out = "ROUTE_POLICY_1" default_originate_route_policy = "ROUTE_POLICY_1" + next_hop_self = true next_hop_self_inheritance_disable = true soft_reconfiguration_inbound_always = true send_community_ebgp_inheritance_disable = true @@ -46,6 +47,7 @@ resource "iosxr_router_bgp_vrf_neighbor_address_family" "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. +- `next_hop_self` (Boolean) Disable the next hop calculation for this neighbor - `next_hop_self_inheritance_disable` (Boolean) Prevent next-hop-self from being inherited from the parent - `remove_private_as_inheritance_disable` (Boolean) Prevent remove-private-AS from being inherited from the parent - `route_policy_in` (String) Apply route policy to inbound routes diff --git a/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf b/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf index 0130eb3e..a8bb73ad 100644 --- a/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf +++ b/examples/resources/iosxr_router_bgp_neighbor_group/resource.tf @@ -13,6 +13,7 @@ resource "iosxr_router_bgp_neighbor_group" "example" { { af_name = "ipv4-labeled-unicast" soft_reconfiguration_inbound_always = true + next_hop_self = true next_hop_self_inheritance_disable = true route_reflector_client = true route_reflector_client_inheritance_disable = true diff --git a/examples/resources/iosxr_router_bgp_vrf_neighbor_address_family/resource.tf b/examples/resources/iosxr_router_bgp_vrf_neighbor_address_family/resource.tf index 87f25ff0..20c51ceb 100644 --- a/examples/resources/iosxr_router_bgp_vrf_neighbor_address_family/resource.tf +++ b/examples/resources/iosxr_router_bgp_vrf_neighbor_address_family/resource.tf @@ -6,6 +6,7 @@ resource "iosxr_router_bgp_vrf_neighbor_address_family" "example" { route_policy_in = "ROUTE_POLICY_1" route_policy_out = "ROUTE_POLICY_1" default_originate_route_policy = "ROUTE_POLICY_1" + next_hop_self = true next_hop_self_inheritance_disable = true soft_reconfiguration_inbound_always = true send_community_ebgp_inheritance_disable = true diff --git a/gen/definitions/router_bgp_neighbor_group.yaml b/gen/definitions/router_bgp_neighbor_group.yaml index 2d575c6f..45eff568 100644 --- a/gen/definitions/router_bgp_neighbor_group.yaml +++ b/gen/definitions/router_bgp_neighbor_group.yaml @@ -48,6 +48,8 @@ attributes: example: ipv4-labeled-unicast - yang_name: soft-reconfiguration/inbound/always example: true + - yang_name: next-hop-self + example: true - yang_name: next-hop-self/inheritance-disable example: true - yang_name: route-reflector-client diff --git a/gen/definitions/router_bgp_vrf_neighbor_address_family.yaml b/gen/definitions/router_bgp_vrf_neighbor_address_family.yaml index 3b9bb7fd..b13b7859 100644 --- a/gen/definitions/router_bgp_vrf_neighbor_address_family.yaml +++ b/gen/definitions/router_bgp_vrf_neighbor_address_family.yaml @@ -20,6 +20,8 @@ attributes: - yang_name: default-originate/inheritance-disable example: true exclude_test: true + - yang_name: next-hop-self + example: true - yang_name: next-hop-self/inheritance-disable example: true - yang_name: soft-reconfiguration/inbound/always 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 8d2caab1..311471ca 100644 --- a/internal/provider/data_source_iosxr_router_bgp_neighbor_group.go +++ b/internal/provider/data_source_iosxr_router_bgp_neighbor_group.go @@ -127,6 +127,10 @@ func (d *RouterBGPNeighborGroupDataSource) Schema(ctx context.Context, req datas MarkdownDescription: "Always use soft reconfig, even if route refresh is supported", Computed: true, }, + "next_hop_self": schema.BoolAttribute{ + MarkdownDescription: "Disable the next hop calculation for this neighbor", + Computed: true, + }, "next_hop_self_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: "Prevent next-hop-self 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 dd7980ab..a01939e3 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 @@ -37,6 +37,7 @@ func TestAccDataSourceIosxrRouterBGPNeighborGroup(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_neighbor_group.test", "bfd_fast_detect_inheritance_disable", "false")) 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", "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")) @@ -91,6 +92,7 @@ func testAccDataSourceIosxrRouterBGPNeighborGroupConfig() string { config += ` address_families = [{` + "\n" config += ` af_name = "ipv4-labeled-unicast"` + "\n" config += ` soft_reconfiguration_inbound_always = true` + "\n" + config += ` next_hop_self = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" config += ` route_reflector_client = true` + "\n" config += ` route_reflector_client_inheritance_disable = true` + "\n" diff --git a/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family.go b/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family.go index 9699a746..3adb92d1 100644 --- a/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family.go +++ b/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family.go @@ -94,6 +94,10 @@ func (d *RouterBGPVRFNeighborAddressFamilyDataSource) Schema(ctx context.Context MarkdownDescription: "Prevent default-originate being inherited from a parent group", Computed: true, }, + "next_hop_self": schema.BoolAttribute{ + MarkdownDescription: "Disable the next hop calculation for this neighbor", + Computed: true, + }, "next_hop_self_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: "Prevent next-hop-self from being inherited from the parent", Computed: true, diff --git a/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family_test.go b/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family_test.go index 4b9d38fa..896ebefc 100644 --- a/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family_test.go +++ b/internal/provider/data_source_iosxr_router_bgp_vrf_neighbor_address_family_test.go @@ -30,6 +30,7 @@ func TestAccDataSourceIosxrRouterBGPVRFNeighborAddressFamily(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_vrf_neighbor_address_family.test", "route_policy_in", "ROUTE_POLICY_1")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_vrf_neighbor_address_family.test", "route_policy_out", "ROUTE_POLICY_1")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_vrf_neighbor_address_family.test", "default_originate_route_policy", "ROUTE_POLICY_1")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_vrf_neighbor_address_family.test", "next_hop_self", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_vrf_neighbor_address_family.test", "next_hop_self_inheritance_disable", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_vrf_neighbor_address_family.test", "soft_reconfiguration_inbound_always", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_bgp_vrf_neighbor_address_family.test", "send_community_ebgp_inheritance_disable", "true")) @@ -123,6 +124,7 @@ func testAccDataSourceIosxrRouterBGPVRFNeighborAddressFamilyConfig() string { config += ` route_policy_in = "ROUTE_POLICY_1"` + "\n" config += ` route_policy_out = "ROUTE_POLICY_1"` + "\n" config += ` default_originate_route_policy = "ROUTE_POLICY_1"` + "\n" + config += ` next_hop_self = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" config += ` soft_reconfiguration_inbound_always = true` + "\n" config += ` send_community_ebgp_inheritance_disable = true` + "\n" diff --git a/internal/provider/model_iosxr_router_bgp_neighbor_group.go b/internal/provider/model_iosxr_router_bgp_neighbor_group.go index f718f517..c8265309 100644 --- a/internal/provider/model_iosxr_router_bgp_neighbor_group.go +++ b/internal/provider/model_iosxr_router_bgp_neighbor_group.go @@ -77,6 +77,7 @@ type RouterBGPNeighborGroupData struct { type RouterBGPNeighborGroupAddressFamilies struct { AfName types.String `tfsdk:"af_name"` SoftReconfigurationInboundAlways types.Bool `tfsdk:"soft_reconfiguration_inbound_always"` + NextHopSelf types.Bool `tfsdk:"next_hop_self"` 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"` @@ -158,6 +159,11 @@ func (data RouterBGPNeighborGroup) toBody(ctx context.Context) string { body, _ = sjson.Set(body, "address-families.address-family"+"."+strconv.Itoa(index)+"."+"soft-reconfiguration.inbound.always", map[string]string{}) } } + if !item.NextHopSelf.IsNull() && !item.NextHopSelf.IsUnknown() { + if item.NextHopSelf.ValueBool() { + body, _ = sjson.Set(body, "address-families.address-family"+"."+strconv.Itoa(index)+"."+"next-hop-self", map[string]string{}) + } + } if !item.NextHopSelfInheritanceDisable.IsNull() && !item.NextHopSelfInheritanceDisable.IsUnknown() { if item.NextHopSelfInheritanceDisable.ValueBool() { body, _ = sjson.Set(body, "address-families.address-family"+"."+strconv.Itoa(index)+"."+"next-hop-self.inheritance-disable", map[string]string{}) @@ -293,6 +299,15 @@ func (data *RouterBGPNeighborGroup) updateFromBody(ctx context.Context, res []by } else { data.AddressFamilies[i].SoftReconfigurationInboundAlways = types.BoolNull() } + if value := r.Get("next-hop-self"); !data.AddressFamilies[i].NextHopSelf.IsNull() { + if value.Exists() { + data.AddressFamilies[i].NextHopSelf = types.BoolValue(true) + } else { + data.AddressFamilies[i].NextHopSelf = types.BoolValue(false) + } + } else { + data.AddressFamilies[i].NextHopSelf = types.BoolNull() + } if value := r.Get("next-hop-self.inheritance-disable"); !data.AddressFamilies[i].NextHopSelfInheritanceDisable.IsNull() { if value.Exists() { data.AddressFamilies[i].NextHopSelfInheritanceDisable = types.BoolValue(true) @@ -402,6 +417,11 @@ func (data *RouterBGPNeighborGroup) fromBody(ctx context.Context, res []byte) { } else { item.SoftReconfigurationInboundAlways = types.BoolValue(false) } + if cValue := v.Get("next-hop-self"); cValue.Exists() { + item.NextHopSelf = types.BoolValue(true) + } else { + item.NextHopSelf = types.BoolValue(false) + } if cValue := v.Get("next-hop-self.inheritance-disable"); cValue.Exists() { item.NextHopSelfInheritanceDisable = types.BoolValue(true) } else { @@ -492,6 +512,11 @@ func (data *RouterBGPNeighborGroupData) fromBody(ctx context.Context, res []byte } else { item.SoftReconfigurationInboundAlways = types.BoolValue(false) } + if cValue := v.Get("next-hop-self"); cValue.Exists() { + item.NextHopSelf = types.BoolValue(true) + } else { + item.NextHopSelf = types.BoolValue(false) + } if cValue := v.Get("next-hop-self.inheritance-disable"); cValue.Exists() { item.NextHopSelfInheritanceDisable = types.BoolValue(true) } else { @@ -589,6 +614,9 @@ func (data *RouterBGPNeighborGroup) getDeletedItems(ctx context.Context, state R if !state.AddressFamilies[i].SoftReconfigurationInboundAlways.IsNull() && data.AddressFamilies[j].SoftReconfigurationInboundAlways.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/address-families/address-family%v/soft-reconfiguration/inbound/always", state.getPath(), keyString)) } + if !state.AddressFamilies[i].NextHopSelf.IsNull() && data.AddressFamilies[j].NextHopSelf.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/address-families/address-family%v/next-hop-self", state.getPath(), keyString)) + } if !state.AddressFamilies[i].NextHopSelfInheritanceDisable.IsNull() && data.AddressFamilies[j].NextHopSelfInheritanceDisable.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/address-families/address-family%v/next-hop-self/inheritance-disable", state.getPath(), keyString)) } @@ -647,6 +675,9 @@ func (data *RouterBGPNeighborGroup) getEmptyLeafsDelete(ctx context.Context) []s if !data.AddressFamilies[i].SoftReconfigurationInboundAlways.IsNull() && !data.AddressFamilies[i].SoftReconfigurationInboundAlways.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-families/address-family%v/soft-reconfiguration/inbound/always", data.getPath(), keyString)) } + if !data.AddressFamilies[i].NextHopSelf.IsNull() && !data.AddressFamilies[i].NextHopSelf.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/address-families/address-family%v/next-hop-self", data.getPath(), keyString)) + } 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)) } diff --git a/internal/provider/model_iosxr_router_bgp_vrf_neighbor_address_family.go b/internal/provider/model_iosxr_router_bgp_vrf_neighbor_address_family.go index 6311d0b9..cba190d6 100644 --- a/internal/provider/model_iosxr_router_bgp_vrf_neighbor_address_family.go +++ b/internal/provider/model_iosxr_router_bgp_vrf_neighbor_address_family.go @@ -40,6 +40,7 @@ type RouterBGPVRFNeighborAddressFamily struct { RoutePolicyOut types.String `tfsdk:"route_policy_out"` DefaultOriginateRoutePolicy types.String `tfsdk:"default_originate_route_policy"` DefaultOriginateInheritanceDisable types.Bool `tfsdk:"default_originate_inheritance_disable"` + NextHopSelf types.Bool `tfsdk:"next_hop_self"` NextHopSelfInheritanceDisable types.Bool `tfsdk:"next_hop_self_inheritance_disable"` SoftReconfigurationInboundAlways types.Bool `tfsdk:"soft_reconfiguration_inbound_always"` SendCommunityEbgpInheritanceDisable types.Bool `tfsdk:"send_community_ebgp_inheritance_disable"` @@ -57,6 +58,7 @@ type RouterBGPVRFNeighborAddressFamilyData struct { RoutePolicyOut types.String `tfsdk:"route_policy_out"` DefaultOriginateRoutePolicy types.String `tfsdk:"default_originate_route_policy"` DefaultOriginateInheritanceDisable types.Bool `tfsdk:"default_originate_inheritance_disable"` + NextHopSelf types.Bool `tfsdk:"next_hop_self"` NextHopSelfInheritanceDisable types.Bool `tfsdk:"next_hop_self_inheritance_disable"` SoftReconfigurationInboundAlways types.Bool `tfsdk:"soft_reconfiguration_inbound_always"` SendCommunityEbgpInheritanceDisable types.Bool `tfsdk:"send_community_ebgp_inheritance_disable"` @@ -90,6 +92,11 @@ func (data RouterBGPVRFNeighborAddressFamily) toBody(ctx context.Context) string body, _ = sjson.Set(body, "default-originate.inheritance-disable", map[string]string{}) } } + if !data.NextHopSelf.IsNull() && !data.NextHopSelf.IsUnknown() { + if data.NextHopSelf.ValueBool() { + body, _ = sjson.Set(body, "next-hop-self", map[string]string{}) + } + } if !data.NextHopSelfInheritanceDisable.IsNull() && !data.NextHopSelfInheritanceDisable.IsUnknown() { if data.NextHopSelfInheritanceDisable.ValueBool() { body, _ = sjson.Set(body, "next-hop-self.inheritance-disable", map[string]string{}) @@ -138,6 +145,15 @@ func (data *RouterBGPVRFNeighborAddressFamily) updateFromBody(ctx context.Contex } else { data.DefaultOriginateInheritanceDisable = types.BoolNull() } + if value := gjson.GetBytes(res, "next-hop-self"); !data.NextHopSelf.IsNull() { + if value.Exists() { + data.NextHopSelf = types.BoolValue(true) + } else { + data.NextHopSelf = types.BoolValue(false) + } + } else { + data.NextHopSelf = types.BoolNull() + } if value := gjson.GetBytes(res, "next-hop-self.inheritance-disable"); !data.NextHopSelfInheritanceDisable.IsNull() { if value.Exists() { data.NextHopSelfInheritanceDisable = types.BoolValue(true) @@ -191,6 +207,11 @@ func (data *RouterBGPVRFNeighborAddressFamily) fromBody(ctx context.Context, res } else { data.DefaultOriginateInheritanceDisable = types.BoolValue(false) } + if value := gjson.GetBytes(res, "next-hop-self"); value.Exists() { + data.NextHopSelf = types.BoolValue(true) + } else { + data.NextHopSelf = types.BoolValue(false) + } if value := gjson.GetBytes(res, "next-hop-self.inheritance-disable"); value.Exists() { data.NextHopSelfInheritanceDisable = types.BoolValue(true) } else { @@ -228,6 +249,11 @@ func (data *RouterBGPVRFNeighborAddressFamilyData) fromBody(ctx context.Context, } else { data.DefaultOriginateInheritanceDisable = types.BoolValue(false) } + if value := gjson.GetBytes(res, "next-hop-self"); value.Exists() { + data.NextHopSelf = types.BoolValue(true) + } else { + data.NextHopSelf = types.BoolValue(false) + } if value := gjson.GetBytes(res, "next-hop-self.inheritance-disable"); value.Exists() { data.NextHopSelfInheritanceDisable = types.BoolValue(true) } else { @@ -264,6 +290,9 @@ func (data *RouterBGPVRFNeighborAddressFamily) getDeletedItems(ctx context.Conte if !state.DefaultOriginateInheritanceDisable.IsNull() && data.DefaultOriginateInheritanceDisable.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/default-originate/inheritance-disable", state.getPath())) } + if !state.NextHopSelf.IsNull() && data.NextHopSelf.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/next-hop-self", state.getPath())) + } if !state.NextHopSelfInheritanceDisable.IsNull() && data.NextHopSelfInheritanceDisable.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/next-hop-self/inheritance-disable", state.getPath())) } @@ -284,6 +313,9 @@ func (data *RouterBGPVRFNeighborAddressFamily) getEmptyLeafsDelete(ctx context.C if !data.DefaultOriginateInheritanceDisable.IsNull() && !data.DefaultOriginateInheritanceDisable.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/default-originate/inheritance-disable", data.getPath())) } + if !data.NextHopSelf.IsNull() && !data.NextHopSelf.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/next-hop-self", data.getPath())) + } if !data.NextHopSelfInheritanceDisable.IsNull() && !data.NextHopSelfInheritanceDisable.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/next-hop-self/inheritance-disable", data.getPath())) } @@ -313,6 +345,9 @@ func (data *RouterBGPVRFNeighborAddressFamily) getDeletePaths(ctx context.Contex if !data.DefaultOriginateInheritanceDisable.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/default-originate/inheritance-disable", data.getPath())) } + if !data.NextHopSelf.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/next-hop-self", data.getPath())) + } if !data.NextHopSelfInheritanceDisable.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/next-hop-self/inheritance-disable", data.getPath())) } diff --git a/internal/provider/resource_iosxr_router_bgp_neighbor_group.go b/internal/provider/resource_iosxr_router_bgp_neighbor_group.go index 59d747b6..26212836 100644 --- a/internal/provider/resource_iosxr_router_bgp_neighbor_group.go +++ b/internal/provider/resource_iosxr_router_bgp_neighbor_group.go @@ -171,6 +171,10 @@ func (r *RouterBGPNeighborGroupResource) Schema(ctx context.Context, req resourc MarkdownDescription: helpers.NewAttributeDescription("Always use soft reconfig, even if route refresh is supported").String, Optional: true, }, + "next_hop_self": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Disable the next hop calculation for this neighbor").String, + Optional: true, + }, "next_hop_self_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Prevent next-hop-self 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 078ba86c..cc2c7c09 100644 --- a/internal/provider/resource_iosxr_router_bgp_neighbor_group_test.go +++ b/internal/provider/resource_iosxr_router_bgp_neighbor_group_test.go @@ -39,6 +39,7 @@ func TestAccIosxrRouterBGPNeighborGroup(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_neighbor_group.test", "bfd_fast_detect_inheritance_disable", "false")) 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", "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")) @@ -112,6 +113,7 @@ func testAccIosxrRouterBGPNeighborGroupConfig_all() string { config += ` address_families = [{` + "\n" config += ` af_name = "ipv4-labeled-unicast"` + "\n" config += ` soft_reconfiguration_inbound_always = true` + "\n" + config += ` next_hop_self = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" config += ` route_reflector_client = true` + "\n" config += ` route_reflector_client_inheritance_disable = true` + "\n" diff --git a/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family.go b/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family.go index cee24fd4..8f192fa1 100644 --- a/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family.go +++ b/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family.go @@ -134,6 +134,10 @@ func (r *RouterBGPVRFNeighborAddressFamilyResource) Schema(ctx context.Context, MarkdownDescription: helpers.NewAttributeDescription("Prevent default-originate being inherited from a parent group").String, Optional: true, }, + "next_hop_self": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Disable the next hop calculation for this neighbor").String, + Optional: true, + }, "next_hop_self_inheritance_disable": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Prevent next-hop-self from being inherited from the parent").String, Optional: true, diff --git a/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family_test.go b/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family_test.go index 52284f75..83e6bfc1 100644 --- a/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family_test.go +++ b/internal/provider/resource_iosxr_router_bgp_vrf_neighbor_address_family_test.go @@ -32,6 +32,7 @@ func TestAccIosxrRouterBGPVRFNeighborAddressFamily(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_vrf_neighbor_address_family.test", "route_policy_in", "ROUTE_POLICY_1")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_vrf_neighbor_address_family.test", "route_policy_out", "ROUTE_POLICY_1")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_vrf_neighbor_address_family.test", "default_originate_route_policy", "ROUTE_POLICY_1")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_vrf_neighbor_address_family.test", "next_hop_self", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_vrf_neighbor_address_family.test", "next_hop_self_inheritance_disable", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_vrf_neighbor_address_family.test", "soft_reconfiguration_inbound_always", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_bgp_vrf_neighbor_address_family.test", "send_community_ebgp_inheritance_disable", "true")) @@ -146,6 +147,7 @@ func testAccIosxrRouterBGPVRFNeighborAddressFamilyConfig_all() string { config += ` route_policy_in = "ROUTE_POLICY_1"` + "\n" config += ` route_policy_out = "ROUTE_POLICY_1"` + "\n" config += ` default_originate_route_policy = "ROUTE_POLICY_1"` + "\n" + config += ` next_hop_self = true` + "\n" config += ` next_hop_self_inheritance_disable = true` + "\n" config += ` soft_reconfiguration_inbound_always = true` + "\n" config += ` send_community_ebgp_inheritance_disable = true` + "\n" diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index c12fd023..95ec8b8d 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -16,6 +16,8 @@ description: |- - Add `iosxr_router_static_vrf_ipv4_multicast` resource and data source - Add `iosxr_router_static_vrf_ipv6_unicast` resource and data source - Add `iosxr_router_static_vrf_ipv6_multicast` resource and data source +- Add `next_hop_self` to `iosxr_router_bgp_neighbor_group` resource and data source +- Add `next_hop_self` to `iosxr_router_bgp_vrf_neighbor_address_family` resource and data source ## 0.4.0