diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d7d6d26..2285aa73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.2.4 (unreleased) - Add `record_ipv4`, `record_ipv6`, `record_mpls` and `sflow_options` attributes to `iosxr_flow_monitor_map` resource and data source +- Add `set_overload_bit` attributes to `iosxr_router_isis` resource and data source ## 0.2.3 diff --git a/docs/data-sources/router_isis.md b/docs/data-sources/router_isis.md index dfafbec9..335debd0 100644 --- a/docs/data-sources/router_isis.md +++ b/docs/data-sources/router_isis.md @@ -53,7 +53,12 @@ data "iosxr_router_isis" "example" { - `nsf_interface_timer` (Number) Timer used to wait for a restart ACK (seconds) - `nsf_lifetime` (Number) Maximum route lifetime following restart (seconds) - `nsr` (Boolean) Enable NSR +- `set_overload_bit_advertise_external` (Boolean) If overload-bit set advertise IP prefixes learned from other protocols +- `set_overload_bit_advertise_interlevel` (Boolean) If overload-bit set advertise IP prefixes learned from another ISIS level - `set_overload_bit_levels` (Attributes List) Set overload-bit for one level only (see [below for nested schema](#nestedatt--set_overload_bit_levels)) +- `set_overload_bit_on_startup_advertise_as_overloaded` (Boolean) Time in seconds to advertise ourself as overloaded after reboot +- `set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise` (Number) Time in seconds to advertise ourself as overloaded after reboot +- `set_overload_bit_on_startup_wait_for_bgp` (Boolean) Set overload bit on startup until BGP signals convergence, or timeout ### Nested Schema for `affinity_maps` diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 70db9202..5d375a76 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -10,6 +10,7 @@ description: |- ## 0.2.4 (unreleased) - Add `record_ipv4`, `record_ipv6`, `record_mpls` and `sflow_options` attributes to `iosxr_flow_monitor_map` resource and data source +- Add `set_overload_bit` attributes to `iosxr_router_isis` resource and data source ## 0.2.3 diff --git a/docs/resources/router_isis.md b/docs/resources/router_isis.md index b4bd0e80..736b7afb 100644 --- a/docs/resources/router_isis.md +++ b/docs/resources/router_isis.md @@ -14,8 +14,13 @@ This resource can manage the Router ISIS configuration. ```terraform resource "iosxr_router_isis" "example" { - process_id = "P1" - is_type = "level-1" + process_id = "P1" + is_type = "level-1" + set_overload_bit_on_startup_advertise_as_overloaded = true + set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise = 10 + set_overload_bit_on_startup_wait_for_bgp = false + set_overload_bit_advertise_external = true + set_overload_bit_advertise_interlevel = true set_overload_bit_levels = [ { level_id = 1 @@ -80,6 +85,8 @@ resource "iosxr_router_isis" "example" { ### Required - `process_id` (String) Process ID +- `set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise` (Number) Time in seconds to advertise ourself as overloaded after reboot + - Range: `5`-`86400` ### Optional @@ -119,7 +126,11 @@ resource "iosxr_router_isis" "example" { - `nsf_lifetime` (Number) Maximum route lifetime following restart (seconds) - Range: `5`-`300` - `nsr` (Boolean) Enable NSR +- `set_overload_bit_advertise_external` (Boolean) If overload-bit set advertise IP prefixes learned from other protocols +- `set_overload_bit_advertise_interlevel` (Boolean) If overload-bit set advertise IP prefixes learned from another ISIS level - `set_overload_bit_levels` (Attributes List) Set overload-bit for one level only (see [below for nested schema](#nestedatt--set_overload_bit_levels)) +- `set_overload_bit_on_startup_advertise_as_overloaded` (Boolean) Time in seconds to advertise ourself as overloaded after reboot +- `set_overload_bit_on_startup_wait_for_bgp` (Boolean) Set overload bit on startup until BGP signals convergence, or timeout ### Read-Only diff --git a/examples/resources/iosxr_router_isis/resource.tf b/examples/resources/iosxr_router_isis/resource.tf index 893c4ad7..fc01893c 100644 --- a/examples/resources/iosxr_router_isis/resource.tf +++ b/examples/resources/iosxr_router_isis/resource.tf @@ -1,6 +1,11 @@ resource "iosxr_router_isis" "example" { - process_id = "P1" - is_type = "level-1" + process_id = "P1" + is_type = "level-1" + set_overload_bit_on_startup_advertise_as_overloaded = true + set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise = 10 + set_overload_bit_on_startup_wait_for_bgp = false + set_overload_bit_advertise_external = true + set_overload_bit_advertise_interlevel = true set_overload_bit_levels = [ { level_id = 1 diff --git a/gen/definitions/router_isis.yaml b/gen/definitions/router_isis.yaml index 76036f06..39eb4234 100644 --- a/gen/definitions/router_isis.yaml +++ b/gen/definitions/router_isis.yaml @@ -7,6 +7,17 @@ attributes: example: P1 - yang_name: is-type example: level-1 + - yang_name: set-overload-bit/on-startup/advertise-as-overloaded + example: true + - yang_name: set-overload-bit/on-startup/advertise-as-overloaded/time-to-advertise + delete_parent: true + example: 10 + - yang_name: set-overload-bit/on-startup/wait-for-bgp + example: false + - yang_name: set-overload-bit/advertise/external + example: true + - yang_name: set-overload-bit/advertise/interlevel + example: true - yang_name: set-overload-bit-levels/level tf_name: set_overload_bit_levels type: List diff --git a/internal/provider/data_source_iosxr_router_isis.go b/internal/provider/data_source_iosxr_router_isis.go index 68573f37..484c77f2 100644 --- a/internal/provider/data_source_iosxr_router_isis.go +++ b/internal/provider/data_source_iosxr_router_isis.go @@ -70,6 +70,26 @@ func (d *RouterISISDataSource) Schema(ctx context.Context, req datasource.Schema MarkdownDescription: "Area type (level)", Computed: true, }, + "set_overload_bit_on_startup_advertise_as_overloaded": schema.BoolAttribute{ + MarkdownDescription: "Time in seconds to advertise ourself as overloaded after reboot", + Computed: true, + }, + "set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise": schema.Int64Attribute{ + MarkdownDescription: "Time in seconds to advertise ourself as overloaded after reboot", + Computed: true, + }, + "set_overload_bit_on_startup_wait_for_bgp": schema.BoolAttribute{ + MarkdownDescription: "Set overload bit on startup until BGP signals convergence, or timeout", + Computed: true, + }, + "set_overload_bit_advertise_external": schema.BoolAttribute{ + MarkdownDescription: "If overload-bit set advertise IP prefixes learned from other protocols", + Computed: true, + }, + "set_overload_bit_advertise_interlevel": schema.BoolAttribute{ + MarkdownDescription: "If overload-bit set advertise IP prefixes learned from another ISIS level", + Computed: true, + }, "set_overload_bit_levels": schema.ListNestedAttribute{ MarkdownDescription: "Set overload-bit for one level only", Computed: true, diff --git a/internal/provider/data_source_iosxr_router_isis_test.go b/internal/provider/data_source_iosxr_router_isis_test.go index a68537cc..b7681ce1 100644 --- a/internal/provider/data_source_iosxr_router_isis_test.go +++ b/internal/provider/data_source_iosxr_router_isis_test.go @@ -28,6 +28,11 @@ import ( func TestAccDataSourceIosxrRouterISIS(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "is_type", "level-1")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_on_startup_advertise_as_overloaded", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise", "10")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_on_startup_wait_for_bgp", "false")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_advertise_external", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_advertise_interlevel", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_levels.0.level_id", "1")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_levels.0.on_startup_advertise_as_overloaded", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_router_isis.test", "set_overload_bit_levels.0.on_startup_advertise_as_overloaded_time_to_advertise", "10")) @@ -80,6 +85,11 @@ func testAccDataSourceIosxrRouterISISConfig() string { config += ` delete_mode = "attributes"` + "\n" config += ` process_id = "P1"` + "\n" config += ` is_type = "level-1"` + "\n" + config += ` set_overload_bit_on_startup_advertise_as_overloaded = true` + "\n" + config += ` set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise = 10` + "\n" + config += ` set_overload_bit_on_startup_wait_for_bgp = false` + "\n" + config += ` set_overload_bit_advertise_external = true` + "\n" + config += ` set_overload_bit_advertise_interlevel = true` + "\n" config += ` set_overload_bit_levels = [{` + "\n" config += ` level_id = 1` + "\n" config += ` on_startup_advertise_as_overloaded = true` + "\n" diff --git a/internal/provider/model_iosxr_router_isis.go b/internal/provider/model_iosxr_router_isis.go index e6837497..e530ef95 100644 --- a/internal/provider/model_iosxr_router_isis.go +++ b/internal/provider/model_iosxr_router_isis.go @@ -31,60 +31,70 @@ import ( ) type RouterISIS struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - DeleteMode types.String `tfsdk:"delete_mode"` - ProcessId types.String `tfsdk:"process_id"` - IsType types.String `tfsdk:"is_type"` - SetOverloadBitLevels []RouterISISSetOverloadBitLevels `tfsdk:"set_overload_bit_levels"` - Nsr types.Bool `tfsdk:"nsr"` - NsfCisco types.Bool `tfsdk:"nsf_cisco"` - NsfIetf types.Bool `tfsdk:"nsf_ietf"` - NsfLifetime types.Int64 `tfsdk:"nsf_lifetime"` - NsfInterfaceTimer types.Int64 `tfsdk:"nsf_interface_timer"` - NsfInterfaceExpires types.Int64 `tfsdk:"nsf_interface_expires"` - LogAdjacencyChanges types.Bool `tfsdk:"log_adjacency_changes"` - LspGenIntervalMaximumWait types.Int64 `tfsdk:"lsp_gen_interval_maximum_wait"` - LspGenIntervalInitialWait types.Int64 `tfsdk:"lsp_gen_interval_initial_wait"` - LspGenIntervalSecondaryWait types.Int64 `tfsdk:"lsp_gen_interval_secondary_wait"` - LspRefreshInterval types.Int64 `tfsdk:"lsp_refresh_interval"` - MaxLspLifetime types.Int64 `tfsdk:"max_lsp_lifetime"` - LspPasswordKeychain types.String `tfsdk:"lsp_password_keychain"` - DistributeLinkStateInstanceId types.Int64 `tfsdk:"distribute_link_state_instance_id"` - DistributeLinkStateThrottle types.Int64 `tfsdk:"distribute_link_state_throttle"` - DistributeLinkStateLevel types.Int64 `tfsdk:"distribute_link_state_level"` - AffinityMaps []RouterISISAffinityMaps `tfsdk:"affinity_maps"` - FlexAlgos []RouterISISFlexAlgos `tfsdk:"flex_algos"` - Nets []RouterISISNets `tfsdk:"nets"` - Interfaces []RouterISISInterfaces `tfsdk:"interfaces"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + DeleteMode types.String `tfsdk:"delete_mode"` + ProcessId types.String `tfsdk:"process_id"` + IsType types.String `tfsdk:"is_type"` + SetOverloadBitOnStartupAdvertiseAsOverloaded types.Bool `tfsdk:"set_overload_bit_on_startup_advertise_as_overloaded"` + SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise types.Int64 `tfsdk:"set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise"` + SetOverloadBitOnStartupWaitForBgp types.Bool `tfsdk:"set_overload_bit_on_startup_wait_for_bgp"` + SetOverloadBitAdvertiseExternal types.Bool `tfsdk:"set_overload_bit_advertise_external"` + SetOverloadBitAdvertiseInterlevel types.Bool `tfsdk:"set_overload_bit_advertise_interlevel"` + SetOverloadBitLevels []RouterISISSetOverloadBitLevels `tfsdk:"set_overload_bit_levels"` + Nsr types.Bool `tfsdk:"nsr"` + NsfCisco types.Bool `tfsdk:"nsf_cisco"` + NsfIetf types.Bool `tfsdk:"nsf_ietf"` + NsfLifetime types.Int64 `tfsdk:"nsf_lifetime"` + NsfInterfaceTimer types.Int64 `tfsdk:"nsf_interface_timer"` + NsfInterfaceExpires types.Int64 `tfsdk:"nsf_interface_expires"` + LogAdjacencyChanges types.Bool `tfsdk:"log_adjacency_changes"` + LspGenIntervalMaximumWait types.Int64 `tfsdk:"lsp_gen_interval_maximum_wait"` + LspGenIntervalInitialWait types.Int64 `tfsdk:"lsp_gen_interval_initial_wait"` + LspGenIntervalSecondaryWait types.Int64 `tfsdk:"lsp_gen_interval_secondary_wait"` + LspRefreshInterval types.Int64 `tfsdk:"lsp_refresh_interval"` + MaxLspLifetime types.Int64 `tfsdk:"max_lsp_lifetime"` + LspPasswordKeychain types.String `tfsdk:"lsp_password_keychain"` + DistributeLinkStateInstanceId types.Int64 `tfsdk:"distribute_link_state_instance_id"` + DistributeLinkStateThrottle types.Int64 `tfsdk:"distribute_link_state_throttle"` + DistributeLinkStateLevel types.Int64 `tfsdk:"distribute_link_state_level"` + AffinityMaps []RouterISISAffinityMaps `tfsdk:"affinity_maps"` + FlexAlgos []RouterISISFlexAlgos `tfsdk:"flex_algos"` + Nets []RouterISISNets `tfsdk:"nets"` + Interfaces []RouterISISInterfaces `tfsdk:"interfaces"` } type RouterISISData struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - ProcessId types.String `tfsdk:"process_id"` - IsType types.String `tfsdk:"is_type"` - SetOverloadBitLevels []RouterISISSetOverloadBitLevels `tfsdk:"set_overload_bit_levels"` - Nsr types.Bool `tfsdk:"nsr"` - NsfCisco types.Bool `tfsdk:"nsf_cisco"` - NsfIetf types.Bool `tfsdk:"nsf_ietf"` - NsfLifetime types.Int64 `tfsdk:"nsf_lifetime"` - NsfInterfaceTimer types.Int64 `tfsdk:"nsf_interface_timer"` - NsfInterfaceExpires types.Int64 `tfsdk:"nsf_interface_expires"` - LogAdjacencyChanges types.Bool `tfsdk:"log_adjacency_changes"` - LspGenIntervalMaximumWait types.Int64 `tfsdk:"lsp_gen_interval_maximum_wait"` - LspGenIntervalInitialWait types.Int64 `tfsdk:"lsp_gen_interval_initial_wait"` - LspGenIntervalSecondaryWait types.Int64 `tfsdk:"lsp_gen_interval_secondary_wait"` - LspRefreshInterval types.Int64 `tfsdk:"lsp_refresh_interval"` - MaxLspLifetime types.Int64 `tfsdk:"max_lsp_lifetime"` - LspPasswordKeychain types.String `tfsdk:"lsp_password_keychain"` - DistributeLinkStateInstanceId types.Int64 `tfsdk:"distribute_link_state_instance_id"` - DistributeLinkStateThrottle types.Int64 `tfsdk:"distribute_link_state_throttle"` - DistributeLinkStateLevel types.Int64 `tfsdk:"distribute_link_state_level"` - AffinityMaps []RouterISISAffinityMaps `tfsdk:"affinity_maps"` - FlexAlgos []RouterISISFlexAlgos `tfsdk:"flex_algos"` - Nets []RouterISISNets `tfsdk:"nets"` - Interfaces []RouterISISInterfaces `tfsdk:"interfaces"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + ProcessId types.String `tfsdk:"process_id"` + IsType types.String `tfsdk:"is_type"` + SetOverloadBitOnStartupAdvertiseAsOverloaded types.Bool `tfsdk:"set_overload_bit_on_startup_advertise_as_overloaded"` + SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise types.Int64 `tfsdk:"set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise"` + SetOverloadBitOnStartupWaitForBgp types.Bool `tfsdk:"set_overload_bit_on_startup_wait_for_bgp"` + SetOverloadBitAdvertiseExternal types.Bool `tfsdk:"set_overload_bit_advertise_external"` + SetOverloadBitAdvertiseInterlevel types.Bool `tfsdk:"set_overload_bit_advertise_interlevel"` + SetOverloadBitLevels []RouterISISSetOverloadBitLevels `tfsdk:"set_overload_bit_levels"` + Nsr types.Bool `tfsdk:"nsr"` + NsfCisco types.Bool `tfsdk:"nsf_cisco"` + NsfIetf types.Bool `tfsdk:"nsf_ietf"` + NsfLifetime types.Int64 `tfsdk:"nsf_lifetime"` + NsfInterfaceTimer types.Int64 `tfsdk:"nsf_interface_timer"` + NsfInterfaceExpires types.Int64 `tfsdk:"nsf_interface_expires"` + LogAdjacencyChanges types.Bool `tfsdk:"log_adjacency_changes"` + LspGenIntervalMaximumWait types.Int64 `tfsdk:"lsp_gen_interval_maximum_wait"` + LspGenIntervalInitialWait types.Int64 `tfsdk:"lsp_gen_interval_initial_wait"` + LspGenIntervalSecondaryWait types.Int64 `tfsdk:"lsp_gen_interval_secondary_wait"` + LspRefreshInterval types.Int64 `tfsdk:"lsp_refresh_interval"` + MaxLspLifetime types.Int64 `tfsdk:"max_lsp_lifetime"` + LspPasswordKeychain types.String `tfsdk:"lsp_password_keychain"` + DistributeLinkStateInstanceId types.Int64 `tfsdk:"distribute_link_state_instance_id"` + DistributeLinkStateThrottle types.Int64 `tfsdk:"distribute_link_state_throttle"` + DistributeLinkStateLevel types.Int64 `tfsdk:"distribute_link_state_level"` + AffinityMaps []RouterISISAffinityMaps `tfsdk:"affinity_maps"` + FlexAlgos []RouterISISFlexAlgos `tfsdk:"flex_algos"` + Nets []RouterISISNets `tfsdk:"nets"` + Interfaces []RouterISISInterfaces `tfsdk:"interfaces"` } type RouterISISSetOverloadBitLevels struct { LevelId types.Int64 `tfsdk:"level_id"` @@ -134,6 +144,29 @@ func (data RouterISIS) toBody(ctx context.Context) string { if !data.IsType.IsNull() && !data.IsType.IsUnknown() { body, _ = sjson.Set(body, "is-type", data.IsType.ValueString()) } + if !data.SetOverloadBitOnStartupAdvertiseAsOverloaded.IsNull() && !data.SetOverloadBitOnStartupAdvertiseAsOverloaded.IsUnknown() { + if data.SetOverloadBitOnStartupAdvertiseAsOverloaded.ValueBool() { + body, _ = sjson.Set(body, "set-overload-bit.on-startup.advertise-as-overloaded", map[string]string{}) + } + } + if !data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise.IsNull() && !data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise.IsUnknown() { + body, _ = sjson.Set(body, "set-overload-bit.on-startup.advertise-as-overloaded.time-to-advertise", strconv.FormatInt(data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise.ValueInt64(), 10)) + } + if !data.SetOverloadBitOnStartupWaitForBgp.IsNull() && !data.SetOverloadBitOnStartupWaitForBgp.IsUnknown() { + if data.SetOverloadBitOnStartupWaitForBgp.ValueBool() { + body, _ = sjson.Set(body, "set-overload-bit.on-startup.wait-for-bgp", map[string]string{}) + } + } + if !data.SetOverloadBitAdvertiseExternal.IsNull() && !data.SetOverloadBitAdvertiseExternal.IsUnknown() { + if data.SetOverloadBitAdvertiseExternal.ValueBool() { + body, _ = sjson.Set(body, "set-overload-bit.advertise.external", map[string]string{}) + } + } + if !data.SetOverloadBitAdvertiseInterlevel.IsNull() && !data.SetOverloadBitAdvertiseInterlevel.IsUnknown() { + if data.SetOverloadBitAdvertiseInterlevel.ValueBool() { + body, _ = sjson.Set(body, "set-overload-bit.advertise.interlevel", map[string]string{}) + } + } if !data.Nsr.IsNull() && !data.Nsr.IsUnknown() { if data.Nsr.ValueBool() { body, _ = sjson.Set(body, "nsr", map[string]string{}) @@ -311,6 +344,47 @@ func (data *RouterISIS) updateFromBody(ctx context.Context, res []byte) { } else { data.IsType = types.StringNull() } + if value := gjson.GetBytes(res, "set-overload-bit.on-startup.advertise-as-overloaded"); !data.SetOverloadBitOnStartupAdvertiseAsOverloaded.IsNull() { + if value.Exists() { + data.SetOverloadBitOnStartupAdvertiseAsOverloaded = types.BoolValue(true) + } else { + data.SetOverloadBitOnStartupAdvertiseAsOverloaded = types.BoolValue(false) + } + } else { + data.SetOverloadBitOnStartupAdvertiseAsOverloaded = types.BoolNull() + } + if value := gjson.GetBytes(res, "set-overload-bit.on-startup.advertise-as-overloaded.time-to-advertise"); value.Exists() && !data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise.IsNull() { + data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise = types.Int64Value(value.Int()) + } else { + data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise = types.Int64Null() + } + if value := gjson.GetBytes(res, "set-overload-bit.on-startup.wait-for-bgp"); !data.SetOverloadBitOnStartupWaitForBgp.IsNull() { + if value.Exists() { + data.SetOverloadBitOnStartupWaitForBgp = types.BoolValue(true) + } else { + data.SetOverloadBitOnStartupWaitForBgp = types.BoolValue(false) + } + } else { + data.SetOverloadBitOnStartupWaitForBgp = types.BoolNull() + } + if value := gjson.GetBytes(res, "set-overload-bit.advertise.external"); !data.SetOverloadBitAdvertiseExternal.IsNull() { + if value.Exists() { + data.SetOverloadBitAdvertiseExternal = types.BoolValue(true) + } else { + data.SetOverloadBitAdvertiseExternal = types.BoolValue(false) + } + } else { + data.SetOverloadBitAdvertiseExternal = types.BoolNull() + } + if value := gjson.GetBytes(res, "set-overload-bit.advertise.interlevel"); !data.SetOverloadBitAdvertiseInterlevel.IsNull() { + if value.Exists() { + data.SetOverloadBitAdvertiseInterlevel = types.BoolValue(true) + } else { + data.SetOverloadBitAdvertiseInterlevel = types.BoolValue(false) + } + } else { + data.SetOverloadBitAdvertiseInterlevel = types.BoolNull() + } for i := range data.SetOverloadBitLevels { keys := [...]string{"level-id"} keyValues := [...]string{strconv.FormatInt(data.SetOverloadBitLevels[i].LevelId.ValueInt64(), 10)} @@ -686,6 +760,29 @@ func (data *RouterISISData) fromBody(ctx context.Context, res []byte) { if value := gjson.GetBytes(res, "is-type"); value.Exists() { data.IsType = types.StringValue(value.String()) } + if value := gjson.GetBytes(res, "set-overload-bit.on-startup.advertise-as-overloaded"); value.Exists() { + data.SetOverloadBitOnStartupAdvertiseAsOverloaded = types.BoolValue(true) + } else { + data.SetOverloadBitOnStartupAdvertiseAsOverloaded = types.BoolValue(false) + } + if value := gjson.GetBytes(res, "set-overload-bit.on-startup.advertise-as-overloaded.time-to-advertise"); value.Exists() { + data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise = types.Int64Value(value.Int()) + } + if value := gjson.GetBytes(res, "set-overload-bit.on-startup.wait-for-bgp"); value.Exists() { + data.SetOverloadBitOnStartupWaitForBgp = types.BoolValue(true) + } else { + data.SetOverloadBitOnStartupWaitForBgp = types.BoolValue(false) + } + if value := gjson.GetBytes(res, "set-overload-bit.advertise.external"); value.Exists() { + data.SetOverloadBitAdvertiseExternal = types.BoolValue(true) + } else { + data.SetOverloadBitAdvertiseExternal = types.BoolValue(false) + } + if value := gjson.GetBytes(res, "set-overload-bit.advertise.interlevel"); value.Exists() { + data.SetOverloadBitAdvertiseInterlevel = types.BoolValue(true) + } else { + data.SetOverloadBitAdvertiseInterlevel = types.BoolValue(false) + } if value := gjson.GetBytes(res, "set-overload-bit-levels.level"); value.Exists() { data.SetOverloadBitLevels = make([]RouterISISSetOverloadBitLevels, 0) value.ForEach(func(k, v gjson.Result) bool { @@ -1028,6 +1125,18 @@ func (data *RouterISIS) getDeletedListItems(ctx context.Context, state RouterISI func (data *RouterISIS) getEmptyLeafsDelete(ctx context.Context) []string { emptyLeafsDelete := make([]string, 0) + if !data.SetOverloadBitOnStartupAdvertiseAsOverloaded.IsNull() && !data.SetOverloadBitOnStartupAdvertiseAsOverloaded.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/set-overload-bit/on-startup/advertise-as-overloaded", data.getPath())) + } + if !data.SetOverloadBitOnStartupWaitForBgp.IsNull() && !data.SetOverloadBitOnStartupWaitForBgp.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/set-overload-bit/on-startup/wait-for-bgp", data.getPath())) + } + if !data.SetOverloadBitAdvertiseExternal.IsNull() && !data.SetOverloadBitAdvertiseExternal.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/set-overload-bit/advertise/external", data.getPath())) + } + if !data.SetOverloadBitAdvertiseInterlevel.IsNull() && !data.SetOverloadBitAdvertiseInterlevel.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/set-overload-bit/advertise/interlevel", data.getPath())) + } for i := range data.SetOverloadBitLevels { keys := [...]string{"level-id"} keyValues := [...]string{strconv.FormatInt(data.SetOverloadBitLevels[i].LevelId.ValueInt64(), 10)} @@ -1124,6 +1233,21 @@ func (data *RouterISIS) getDeletePaths(ctx context.Context) []string { if !data.IsType.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/is-type", data.getPath())) } + if !data.SetOverloadBitOnStartupAdvertiseAsOverloaded.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/set-overload-bit/on-startup/advertise-as-overloaded", data.getPath())) + } + if !data.SetOverloadBitOnStartupAdvertiseAsOverloadedTimeToAdvertise.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/set-overload-bit/on-startup/advertise-as-overloaded", data.getPath())) + } + if !data.SetOverloadBitOnStartupWaitForBgp.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/set-overload-bit/on-startup/wait-for-bgp", data.getPath())) + } + if !data.SetOverloadBitAdvertiseExternal.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/set-overload-bit/advertise/external", data.getPath())) + } + if !data.SetOverloadBitAdvertiseInterlevel.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/set-overload-bit/advertise/interlevel", data.getPath())) + } for i := range data.SetOverloadBitLevels { keys := [...]string{"level-id"} keyValues := [...]string{strconv.FormatInt(data.SetOverloadBitLevels[i].LevelId.ValueInt64(), 10)} diff --git a/internal/provider/resource_iosxr_router_isis.go b/internal/provider/resource_iosxr_router_isis.go index 704fd6fe..1cc3758e 100644 --- a/internal/provider/resource_iosxr_router_isis.go +++ b/internal/provider/resource_iosxr_router_isis.go @@ -91,6 +91,29 @@ func (r *RouterISISResource) Schema(ctx context.Context, req resource.SchemaRequ stringvalidator.OneOf("level-1", "level-1-2", "level-2-only"), }, }, + "set_overload_bit_on_startup_advertise_as_overloaded": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Time in seconds to advertise ourself as overloaded after reboot").String, + Optional: true, + }, + "set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Time in seconds to advertise ourself as overloaded after reboot").AddIntegerRangeDescription(5, 86400).String, + Required: true, + Validators: []validator.Int64{ + int64validator.Between(5, 86400), + }, + }, + "set_overload_bit_on_startup_wait_for_bgp": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Set overload bit on startup until BGP signals convergence, or timeout").String, + Optional: true, + }, + "set_overload_bit_advertise_external": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("If overload-bit set advertise IP prefixes learned from other protocols").String, + Optional: true, + }, + "set_overload_bit_advertise_interlevel": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("If overload-bit set advertise IP prefixes learned from another ISIS level").String, + Optional: true, + }, "set_overload_bit_levels": schema.ListNestedAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Set overload-bit for one level only").String, Optional: true, diff --git a/internal/provider/resource_iosxr_router_isis_test.go b/internal/provider/resource_iosxr_router_isis_test.go index 9b1c4492..01a49aa8 100644 --- a/internal/provider/resource_iosxr_router_isis_test.go +++ b/internal/provider/resource_iosxr_router_isis_test.go @@ -30,6 +30,11 @@ func TestAccIosxrRouterISIS(t *testing.T) { var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "process_id", "P1")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "is_type", "level-1")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_on_startup_advertise_as_overloaded", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise", "10")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_on_startup_wait_for_bgp", "false")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_advertise_external", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_advertise_interlevel", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_levels.0.level_id", "1")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_levels.0.on_startup_advertise_as_overloaded", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_router_isis.test", "set_overload_bit_levels.0.on_startup_advertise_as_overloaded_time_to_advertise", "10")) @@ -90,6 +95,7 @@ func TestAccIosxrRouterISIS(t *testing.T) { func testAccIosxrRouterISISConfig_minimum() string { config := `resource "iosxr_router_isis" "test" {` + "\n" config += ` process_id = "P1"` + "\n" + config += ` set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise = 10` + "\n" config += `}` + "\n" return config } @@ -98,6 +104,11 @@ func testAccIosxrRouterISISConfig_all() string { config := `resource "iosxr_router_isis" "test" {` + "\n" config += ` process_id = "P1"` + "\n" config += ` is_type = "level-1"` + "\n" + config += ` set_overload_bit_on_startup_advertise_as_overloaded = true` + "\n" + config += ` set_overload_bit_on_startup_advertise_as_overloaded_time_to_advertise = 10` + "\n" + config += ` set_overload_bit_on_startup_wait_for_bgp = false` + "\n" + config += ` set_overload_bit_advertise_external = true` + "\n" + config += ` set_overload_bit_advertise_interlevel = true` + "\n" config += ` set_overload_bit_levels = [{` + "\n" config += ` level_id = 1` + "\n" config += ` on_startup_advertise_as_overloaded = true` + "\n" diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 70db9202..5d375a76 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -10,6 +10,7 @@ description: |- ## 0.2.4 (unreleased) - Add `record_ipv4`, `record_ipv6`, `record_mpls` and `sflow_options` attributes to `iosxr_flow_monitor_map` resource and data source +- Add `set_overload_bit` attributes to `iosxr_router_isis` resource and data source ## 0.2.3