From c78afccafd43f4f997fbe8fdb25549c2905e230e Mon Sep 17 00:00:00 2001 From: Blake Becton <238314145+tech-of-all-trades@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:42:31 -0400 Subject: [PATCH 1/2] feat: Add persistent logging parameters and rate-limit configuration options in logging.yaml --- gen/definitions/logging.yaml | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/gen/definitions/logging.yaml b/gen/definitions/logging.yaml index b357fd83f..b84a3cedb 100644 --- a/gen/definitions/logging.yaml +++ b/gen/definitions/logging.yaml @@ -234,6 +234,59 @@ attributes: - yang_name: profile example: PROF1 exclude_test: true + - yang_name: count + tf_name: logging_count + example: true + - yang_name: persistent/url + example: flash:/local_logging + - yang_name: persistent/size + example: 1000000 + - yang_name: persistent/filesize + example: 500000 + - yang_name: persistent/batch + example: 4096 + exclude_test: true + - yang_name: persistent/threshold + example: 50 + exclude_test: true + - yang_name: persistent/immediate + example: true + exclude_test: true + - yang_name: persistent/notify + example: true + exclude_test: true + - yang_name: persistent/protected + example: true + exclude_test: true + - yang_name: rate-limit-config/config-options/common-case/common-config/rate-limit/all/common-options/range + xpath: rate-limit-config/common-config/rate-limit/all/common-options/range + tf_name: rate_limit_all + example: 200 + - yang_name: rate-limit-config/config-options/common-case/common-config/rate-limit/all/common-options/except/range + xpath: rate-limit-config/common-config/rate-limit/all/common-options/except/range + tf_name: rate_limit_all_except_severity + example: warnings + exclude_test: true + - yang_name: rate-limit-config/config-options/common-case/common-config/rate-limit/console/common-options/range + xpath: rate-limit-config/common-config/rate-limit/console/common-options/range + tf_name: rate_limit_console + example: 100 + exclude_test: true + - yang_name: rate-limit-config/config-options/common-case/common-config/rate-limit/console/common-options/except/range + xpath: rate-limit-config/common-config/rate-limit/console/common-options/except/range + tf_name: rate_limit_console_except_severity + example: errors + exclude_test: true + - yang_name: rate-limit-config/config-options/common-case/common-config/rate-limit/console/all/common-options/range + xpath: rate-limit-config/common-config/rate-limit/console/all/common-options/range + tf_name: rate_limit_console_all + example: 150 + exclude_test: true + - yang_name: rate-limit-config/config-options/common-case/common-config/rate-limit/console/all/common-options/except/range + xpath: rate-limit-config/common-config/rate-limit/console/all/common-options/except/range + tf_name: rate_limit_console_all_except_severity + example: critical + exclude_test: true test_prerequisites: - path: Cisco-IOS-XE-native:native/vrf/definition=VRF1 From c61e2e862bf180ee295278ab56df29bf52d48b37 Mon Sep 17 00:00:00 2001 From: Blake Becton <238314145+tech-of-all-trades@users.noreply.github.com> Date: Fri, 31 Oct 2025 17:39:58 -0400 Subject: [PATCH 2/2] feat: Add logging count, persistent storage, and rate-limit support to logging resource MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhanced the iosxe_logging resource with comprehensive logging configuration capabilities including message counting, persistent storage, and rate limiting functionality. New Attributes (15 total): - logging_count: Enable message counting with timestamps - persistent_url: Configure persistent log storage location - persistent_size: Set disk space for log messages (16384-2147483647 bytes) - persistent_filesize: Set individual log file size (8192-2147483647 bytes) - persistent_batch: Configure batch size for storage writes (4096-2147483647 bytes) - persistent_threshold: Set threshold capacity percentage (1-99%) - persistent_immediate: Enable immediate write without buffering - persistent_notify: Enable notifications for persistent logging - persistent_protected: Protect logging files from manipulation - rate_limit_all: Set global message rate limit (1-10000 msgs/sec) - rate_limit_all_except_severity: Configure exception severity for global rate limit - rate_limit_console: Set console-only message rate limit (1-10000 msgs/sec) - rate_limit_console_except_severity: Configure exception severity for console rate limit - rate_limit_console_all: Set console rate limit including debug messages (1-10000 msgs/sec) - rate_limit_console_all_except_severity: Configure exception severity for console all rate limit CLI Commands Supported: - logging count - logging persistent url flash:/ size filesize - logging rate-limit all Benefits: - Enables message counting and timestamping for operational awareness - Supports persistent logging to flash storage for long-term log retention - Provides granular rate limiting controls to prevent log flooding - Enhances troubleshooting and compliance capabilities Implementation Details: - Updated gen/definitions/logging.yaml with YANG mappings - YANG path: Cisco-IOS-XE-native:native/logging - Resolved Terraform reserved word conflict (count → logging_count) - Generated provider code with validation rules and acceptance tests - All acceptance tests passing (136.41s) Files Modified: - gen/definitions/logging.yaml - docs/data-sources/logging.md - docs/resources/logging.md - examples/resources/iosxe_logging/resource.tf - internal/provider/data_source_iosxe_logging.go - internal/provider/data_source_iosxe_logging_test.go - internal/provider/model_iosxe_logging.go - internal/provider/resource_iosxe_logging.go - internal/provider/resource_iosxe_logging_test.go --- docs/data-sources/logging.md | 15 + docs/resources/logging.md | 30 ++ examples/resources/iosxe_logging/resource.tf | 5 + .../provider/data_source_iosxe_logging.go | 60 +++ .../data_source_iosxe_logging_test.go | 10 + internal/provider/model_iosxe_logging.go | 494 ++++++++++++++++-- internal/provider/resource_iosxe_logging.go | 95 ++++ .../provider/resource_iosxe_logging_test.go | 12 +- 8 files changed, 664 insertions(+), 57 deletions(-) diff --git a/docs/data-sources/logging.md b/docs/data-sources/logging.md index 84b6cfd10..2af05fb62 100644 --- a/docs/data-sources/logging.md +++ b/docs/data-sources/logging.md @@ -46,9 +46,24 @@ data "iosxe_logging" "example" { - `ipv6_hosts_transport` (Attributes List) (see [below for nested schema](#nestedatt--ipv6_hosts_transport)) - `ipv6_vrf_hosts` (Attributes List) (see [below for nested schema](#nestedatt--ipv6_vrf_hosts)) - `ipv6_vrf_hosts_transport` (Attributes List) (see [below for nested schema](#nestedatt--ipv6_vrf_hosts_transport)) +- `logging_count` (Boolean) Count every log message and timestamp last occurrence - `monitor_severity` (String) - `origin_id_name` (String) Define a unique text string as ID - `origin_id_type` (String) Use origin hostname/ip/ipv6 as ID +- `persistent_batch` (Number) Batch size for writing to persistent storage +- `persistent_filesize` (Number) Set size of individual log files +- `persistent_immediate` (Boolean) Write log entry to storage immediately (no buffering). +- `persistent_notify` (Boolean) Notify when show logging [persistent] is activated. +- `persistent_protected` (Boolean) Eliminates manipulation on logging-persistent files +- `persistent_size` (Number) Set disk space for writing log messages +- `persistent_threshold` (Number) Setting threshold capacity. When setting circular logging is disabled +- `persistent_url` (String) URL to store logging messages +- `rate_limit_all` (Number) Messages per second +- `rate_limit_all_except_severity` (String) Logging severity level +- `rate_limit_console` (Number) Messages per second +- `rate_limit_console_all` (Number) Messages per second +- `rate_limit_console_all_except_severity` (String) Logging severity level +- `rate_limit_console_except_severity` (String) Logging severity level - `source_interface` (String) - `source_interfaces_vrf` (Attributes List) Specify interface and vrf for source address in logging transactions (see [below for nested schema](#nestedatt--source_interfaces_vrf)) - `trap` (Boolean) Set trap server logging level diff --git a/docs/resources/logging.md b/docs/resources/logging.md index 4feb099a9..100ca062f 100644 --- a/docs/resources/logging.md +++ b/docs/resources/logging.md @@ -135,6 +135,11 @@ resource "iosxe_logging" "example" { ] } ] + logging_count = true + persistent_url = "flash:/local_logging" + persistent_size = 1000000 + persistent_filesize = 500000 + rate_limit_all = 200 } ``` @@ -166,10 +171,35 @@ resource "iosxe_logging" "example" { - `ipv6_hosts_transport` (Attributes List) (see [below for nested schema](#nestedatt--ipv6_hosts_transport)) - `ipv6_vrf_hosts` (Attributes List) (see [below for nested schema](#nestedatt--ipv6_vrf_hosts)) - `ipv6_vrf_hosts_transport` (Attributes List) (see [below for nested schema](#nestedatt--ipv6_vrf_hosts_transport)) +- `logging_count` (Boolean) Count every log message and timestamp last occurrence - `monitor_severity` (String) - `origin_id_name` (String) Define a unique text string as ID - `origin_id_type` (String) Use origin hostname/ip/ipv6 as ID - Choices: `hostname`, `ip`, `ipv6` +- `persistent_batch` (Number) Batch size for writing to persistent storage + - Range: `4096`-`2147483647` +- `persistent_filesize` (Number) Set size of individual log files + - Range: `8192`-`2147483647` +- `persistent_immediate` (Boolean) Write log entry to storage immediately (no buffering). +- `persistent_notify` (Boolean) Notify when show logging [persistent] is activated. +- `persistent_protected` (Boolean) Eliminates manipulation on logging-persistent files +- `persistent_size` (Number) Set disk space for writing log messages + - Range: `16384`-`2147483647` +- `persistent_threshold` (Number) Setting threshold capacity. When setting circular logging is disabled + - Range: `1`-`99` +- `persistent_url` (String) URL to store logging messages +- `rate_limit_all` (Number) Messages per second + - Range: `1`-`10000` +- `rate_limit_all_except_severity` (String) Logging severity level + - Choices: `alerts`, `critical`, `debugging`, `emergencies`, `errors`, `informational`, `notifications`, `warnings` +- `rate_limit_console` (Number) Messages per second + - Range: `1`-`10000` +- `rate_limit_console_all` (Number) Messages per second + - Range: `1`-`10000` +- `rate_limit_console_all_except_severity` (String) Logging severity level + - Choices: `alerts`, `critical`, `debugging`, `emergencies`, `errors`, `informational`, `notifications`, `warnings` +- `rate_limit_console_except_severity` (String) Logging severity level + - Choices: `alerts`, `critical`, `debugging`, `emergencies`, `errors`, `informational`, `notifications`, `warnings` - `source_interface` (String) - `source_interfaces_vrf` (Attributes List) Specify interface and vrf for source address in logging transactions (see [below for nested schema](#nestedatt--source_interfaces_vrf)) - `trap` (Boolean) Set trap server logging level diff --git a/examples/resources/iosxe_logging/resource.tf b/examples/resources/iosxe_logging/resource.tf index fee078993..400768034 100644 --- a/examples/resources/iosxe_logging/resource.tf +++ b/examples/resources/iosxe_logging/resource.tf @@ -120,4 +120,9 @@ resource "iosxe_logging" "example" { ] } ] + logging_count = true + persistent_url = "flash:/local_logging" + persistent_size = 1000000 + persistent_filesize = 500000 + rate_limit_all = 200 } diff --git a/internal/provider/data_source_iosxe_logging.go b/internal/provider/data_source_iosxe_logging.go index d978e2260..3a20f930f 100644 --- a/internal/provider/data_source_iosxe_logging.go +++ b/internal/provider/data_source_iosxe_logging.go @@ -423,6 +423,66 @@ func (d *LoggingDataSource) Schema(ctx context.Context, req datasource.SchemaReq }, }, }, + "logging_count": schema.BoolAttribute{ + MarkdownDescription: "Count every log message and timestamp last occurrence", + Computed: true, + }, + "persistent_url": schema.StringAttribute{ + MarkdownDescription: "URL to store logging messages", + Computed: true, + }, + "persistent_size": schema.Int64Attribute{ + MarkdownDescription: "Set disk space for writing log messages", + Computed: true, + }, + "persistent_filesize": schema.Int64Attribute{ + MarkdownDescription: "Set size of individual log files", + Computed: true, + }, + "persistent_batch": schema.Int64Attribute{ + MarkdownDescription: "Batch size for writing to persistent storage", + Computed: true, + }, + "persistent_threshold": schema.Int64Attribute{ + MarkdownDescription: "Setting threshold capacity. When setting circular logging is disabled", + Computed: true, + }, + "persistent_immediate": schema.BoolAttribute{ + MarkdownDescription: "Write log entry to storage immediately (no buffering).", + Computed: true, + }, + "persistent_notify": schema.BoolAttribute{ + MarkdownDescription: "Notify when show logging [persistent] is activated.", + Computed: true, + }, + "persistent_protected": schema.BoolAttribute{ + MarkdownDescription: "Eliminates manipulation on logging-persistent files", + Computed: true, + }, + "rate_limit_all": schema.Int64Attribute{ + MarkdownDescription: "Messages per second", + Computed: true, + }, + "rate_limit_all_except_severity": schema.StringAttribute{ + MarkdownDescription: "Logging severity level", + Computed: true, + }, + "rate_limit_console": schema.Int64Attribute{ + MarkdownDescription: "Messages per second", + Computed: true, + }, + "rate_limit_console_except_severity": schema.StringAttribute{ + MarkdownDescription: "Logging severity level", + Computed: true, + }, + "rate_limit_console_all": schema.Int64Attribute{ + MarkdownDescription: "Messages per second", + Computed: true, + }, + "rate_limit_console_all_except_severity": schema.StringAttribute{ + MarkdownDescription: "Logging severity level", + Computed: true, + }, }, } } diff --git a/internal/provider/data_source_iosxe_logging_test.go b/internal/provider/data_source_iosxe_logging_test.go index 5c7be155e..7206f546d 100644 --- a/internal/provider/data_source_iosxe_logging_test.go +++ b/internal/provider/data_source_iosxe_logging_test.go @@ -69,6 +69,11 @@ func TestAccDataSourceIosxeLogging(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "ipv6_vrf_hosts_transport.0.transport_udp_ports.0.port_number", "10000")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "ipv6_vrf_hosts_transport.0.transport_tcp_ports.0.port_number", "10001")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "ipv6_vrf_hosts_transport.0.transport_tls_ports.0.port_number", "10002")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "logging_count", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "persistent_url", "flash:/local_logging")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "persistent_size", "1000000")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "persistent_filesize", "500000")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_logging.test", "rate_limit_all", "200")) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, @@ -191,6 +196,11 @@ func testAccDataSourceIosxeLoggingConfig() string { config += ` port_number = 10002` + "\n" config += ` }]` + "\n" config += ` }]` + "\n" + config += ` logging_count = true` + "\n" + config += ` persistent_url = "flash:/local_logging"` + "\n" + config += ` persistent_size = 1000000` + "\n" + config += ` persistent_filesize = 500000` + "\n" + config += ` rate_limit_all = 200` + "\n" config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n" config += `}` + "\n" diff --git a/internal/provider/model_iosxe_logging.go b/internal/provider/model_iosxe_logging.go index 73afc2096..bffc4cc4a 100644 --- a/internal/provider/model_iosxe_logging.go +++ b/internal/provider/model_iosxe_logging.go @@ -38,65 +38,95 @@ import ( // Section below is generated&owned by "gen/generator.go". //template:begin types type Logging struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - MonitorSeverity types.String `tfsdk:"monitor_severity"` - BufferedSize types.Int64 `tfsdk:"buffered_size"` - BufferedSeverity types.String `tfsdk:"buffered_severity"` - ConsoleSeverity types.String `tfsdk:"console_severity"` - Facility types.String `tfsdk:"facility"` - HistorySize types.Int64 `tfsdk:"history_size"` - HistorySeverity types.String `tfsdk:"history_severity"` - Trap types.Bool `tfsdk:"trap"` - TrapSeverity types.String `tfsdk:"trap_severity"` - OriginIdType types.String `tfsdk:"origin_id_type"` - OriginIdName types.String `tfsdk:"origin_id_name"` - FileName types.String `tfsdk:"file_name"` - FileMaxSize types.Int64 `tfsdk:"file_max_size"` - FileMinSize types.Int64 `tfsdk:"file_min_size"` - FileSeverity types.String `tfsdk:"file_severity"` - SourceInterface types.String `tfsdk:"source_interface"` - Console types.Bool `tfsdk:"console"` - SourceInterfacesVrf []LoggingSourceInterfacesVrf `tfsdk:"source_interfaces_vrf"` - Ipv4Hosts []LoggingIpv4Hosts `tfsdk:"ipv4_hosts"` - Ipv4HostsTransport []LoggingIpv4HostsTransport `tfsdk:"ipv4_hosts_transport"` - Ipv4VrfHosts []LoggingIpv4VrfHosts `tfsdk:"ipv4_vrf_hosts"` - Ipv4VrfHostsTransport []LoggingIpv4VrfHostsTransport `tfsdk:"ipv4_vrf_hosts_transport"` - Ipv6Hosts []LoggingIpv6Hosts `tfsdk:"ipv6_hosts"` - Ipv6HostsTransport []LoggingIpv6HostsTransport `tfsdk:"ipv6_hosts_transport"` - Ipv6VrfHosts []LoggingIpv6VrfHosts `tfsdk:"ipv6_vrf_hosts"` - Ipv6VrfHostsTransport []LoggingIpv6VrfHostsTransport `tfsdk:"ipv6_vrf_hosts_transport"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + MonitorSeverity types.String `tfsdk:"monitor_severity"` + BufferedSize types.Int64 `tfsdk:"buffered_size"` + BufferedSeverity types.String `tfsdk:"buffered_severity"` + ConsoleSeverity types.String `tfsdk:"console_severity"` + Facility types.String `tfsdk:"facility"` + HistorySize types.Int64 `tfsdk:"history_size"` + HistorySeverity types.String `tfsdk:"history_severity"` + Trap types.Bool `tfsdk:"trap"` + TrapSeverity types.String `tfsdk:"trap_severity"` + OriginIdType types.String `tfsdk:"origin_id_type"` + OriginIdName types.String `tfsdk:"origin_id_name"` + FileName types.String `tfsdk:"file_name"` + FileMaxSize types.Int64 `tfsdk:"file_max_size"` + FileMinSize types.Int64 `tfsdk:"file_min_size"` + FileSeverity types.String `tfsdk:"file_severity"` + SourceInterface types.String `tfsdk:"source_interface"` + Console types.Bool `tfsdk:"console"` + SourceInterfacesVrf []LoggingSourceInterfacesVrf `tfsdk:"source_interfaces_vrf"` + Ipv4Hosts []LoggingIpv4Hosts `tfsdk:"ipv4_hosts"` + Ipv4HostsTransport []LoggingIpv4HostsTransport `tfsdk:"ipv4_hosts_transport"` + Ipv4VrfHosts []LoggingIpv4VrfHosts `tfsdk:"ipv4_vrf_hosts"` + Ipv4VrfHostsTransport []LoggingIpv4VrfHostsTransport `tfsdk:"ipv4_vrf_hosts_transport"` + Ipv6Hosts []LoggingIpv6Hosts `tfsdk:"ipv6_hosts"` + Ipv6HostsTransport []LoggingIpv6HostsTransport `tfsdk:"ipv6_hosts_transport"` + Ipv6VrfHosts []LoggingIpv6VrfHosts `tfsdk:"ipv6_vrf_hosts"` + Ipv6VrfHostsTransport []LoggingIpv6VrfHostsTransport `tfsdk:"ipv6_vrf_hosts_transport"` + LoggingCount types.Bool `tfsdk:"logging_count"` + PersistentUrl types.String `tfsdk:"persistent_url"` + PersistentSize types.Int64 `tfsdk:"persistent_size"` + PersistentFilesize types.Int64 `tfsdk:"persistent_filesize"` + PersistentBatch types.Int64 `tfsdk:"persistent_batch"` + PersistentThreshold types.Int64 `tfsdk:"persistent_threshold"` + PersistentImmediate types.Bool `tfsdk:"persistent_immediate"` + PersistentNotify types.Bool `tfsdk:"persistent_notify"` + PersistentProtected types.Bool `tfsdk:"persistent_protected"` + RateLimitAll types.Int64 `tfsdk:"rate_limit_all"` + RateLimitAllExceptSeverity types.String `tfsdk:"rate_limit_all_except_severity"` + RateLimitConsole types.Int64 `tfsdk:"rate_limit_console"` + RateLimitConsoleExceptSeverity types.String `tfsdk:"rate_limit_console_except_severity"` + RateLimitConsoleAll types.Int64 `tfsdk:"rate_limit_console_all"` + RateLimitConsoleAllExceptSeverity types.String `tfsdk:"rate_limit_console_all_except_severity"` } type LoggingData struct { - Device types.String `tfsdk:"device"` - Id types.String `tfsdk:"id"` - MonitorSeverity types.String `tfsdk:"monitor_severity"` - BufferedSize types.Int64 `tfsdk:"buffered_size"` - BufferedSeverity types.String `tfsdk:"buffered_severity"` - ConsoleSeverity types.String `tfsdk:"console_severity"` - Facility types.String `tfsdk:"facility"` - HistorySize types.Int64 `tfsdk:"history_size"` - HistorySeverity types.String `tfsdk:"history_severity"` - Trap types.Bool `tfsdk:"trap"` - TrapSeverity types.String `tfsdk:"trap_severity"` - OriginIdType types.String `tfsdk:"origin_id_type"` - OriginIdName types.String `tfsdk:"origin_id_name"` - FileName types.String `tfsdk:"file_name"` - FileMaxSize types.Int64 `tfsdk:"file_max_size"` - FileMinSize types.Int64 `tfsdk:"file_min_size"` - FileSeverity types.String `tfsdk:"file_severity"` - SourceInterface types.String `tfsdk:"source_interface"` - Console types.Bool `tfsdk:"console"` - SourceInterfacesVrf []LoggingSourceInterfacesVrf `tfsdk:"source_interfaces_vrf"` - Ipv4Hosts []LoggingIpv4Hosts `tfsdk:"ipv4_hosts"` - Ipv4HostsTransport []LoggingIpv4HostsTransport `tfsdk:"ipv4_hosts_transport"` - Ipv4VrfHosts []LoggingIpv4VrfHosts `tfsdk:"ipv4_vrf_hosts"` - Ipv4VrfHostsTransport []LoggingIpv4VrfHostsTransport `tfsdk:"ipv4_vrf_hosts_transport"` - Ipv6Hosts []LoggingIpv6Hosts `tfsdk:"ipv6_hosts"` - Ipv6HostsTransport []LoggingIpv6HostsTransport `tfsdk:"ipv6_hosts_transport"` - Ipv6VrfHosts []LoggingIpv6VrfHosts `tfsdk:"ipv6_vrf_hosts"` - Ipv6VrfHostsTransport []LoggingIpv6VrfHostsTransport `tfsdk:"ipv6_vrf_hosts_transport"` + Device types.String `tfsdk:"device"` + Id types.String `tfsdk:"id"` + MonitorSeverity types.String `tfsdk:"monitor_severity"` + BufferedSize types.Int64 `tfsdk:"buffered_size"` + BufferedSeverity types.String `tfsdk:"buffered_severity"` + ConsoleSeverity types.String `tfsdk:"console_severity"` + Facility types.String `tfsdk:"facility"` + HistorySize types.Int64 `tfsdk:"history_size"` + HistorySeverity types.String `tfsdk:"history_severity"` + Trap types.Bool `tfsdk:"trap"` + TrapSeverity types.String `tfsdk:"trap_severity"` + OriginIdType types.String `tfsdk:"origin_id_type"` + OriginIdName types.String `tfsdk:"origin_id_name"` + FileName types.String `tfsdk:"file_name"` + FileMaxSize types.Int64 `tfsdk:"file_max_size"` + FileMinSize types.Int64 `tfsdk:"file_min_size"` + FileSeverity types.String `tfsdk:"file_severity"` + SourceInterface types.String `tfsdk:"source_interface"` + Console types.Bool `tfsdk:"console"` + SourceInterfacesVrf []LoggingSourceInterfacesVrf `tfsdk:"source_interfaces_vrf"` + Ipv4Hosts []LoggingIpv4Hosts `tfsdk:"ipv4_hosts"` + Ipv4HostsTransport []LoggingIpv4HostsTransport `tfsdk:"ipv4_hosts_transport"` + Ipv4VrfHosts []LoggingIpv4VrfHosts `tfsdk:"ipv4_vrf_hosts"` + Ipv4VrfHostsTransport []LoggingIpv4VrfHostsTransport `tfsdk:"ipv4_vrf_hosts_transport"` + Ipv6Hosts []LoggingIpv6Hosts `tfsdk:"ipv6_hosts"` + Ipv6HostsTransport []LoggingIpv6HostsTransport `tfsdk:"ipv6_hosts_transport"` + Ipv6VrfHosts []LoggingIpv6VrfHosts `tfsdk:"ipv6_vrf_hosts"` + Ipv6VrfHostsTransport []LoggingIpv6VrfHostsTransport `tfsdk:"ipv6_vrf_hosts_transport"` + LoggingCount types.Bool `tfsdk:"logging_count"` + PersistentUrl types.String `tfsdk:"persistent_url"` + PersistentSize types.Int64 `tfsdk:"persistent_size"` + PersistentFilesize types.Int64 `tfsdk:"persistent_filesize"` + PersistentBatch types.Int64 `tfsdk:"persistent_batch"` + PersistentThreshold types.Int64 `tfsdk:"persistent_threshold"` + PersistentImmediate types.Bool `tfsdk:"persistent_immediate"` + PersistentNotify types.Bool `tfsdk:"persistent_notify"` + PersistentProtected types.Bool `tfsdk:"persistent_protected"` + RateLimitAll types.Int64 `tfsdk:"rate_limit_all"` + RateLimitAllExceptSeverity types.String `tfsdk:"rate_limit_all_except_severity"` + RateLimitConsole types.Int64 `tfsdk:"rate_limit_console"` + RateLimitConsoleExceptSeverity types.String `tfsdk:"rate_limit_console_except_severity"` + RateLimitConsoleAll types.Int64 `tfsdk:"rate_limit_console_all"` + RateLimitConsoleAllExceptSeverity types.String `tfsdk:"rate_limit_console_all_except_severity"` } type LoggingSourceInterfacesVrf struct { Vrf types.String `tfsdk:"vrf"` @@ -265,6 +295,59 @@ func (data Logging) toBody(ctx context.Context) string { if !data.Console.IsNull() && !data.Console.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"console-config.console", data.Console.ValueBool()) } + if !data.LoggingCount.IsNull() && !data.LoggingCount.IsUnknown() { + if data.LoggingCount.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"count", map[string]string{}) + } + } + if !data.PersistentUrl.IsNull() && !data.PersistentUrl.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.url", data.PersistentUrl.ValueString()) + } + if !data.PersistentSize.IsNull() && !data.PersistentSize.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.size", strconv.FormatInt(data.PersistentSize.ValueInt64(), 10)) + } + if !data.PersistentFilesize.IsNull() && !data.PersistentFilesize.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.filesize", strconv.FormatInt(data.PersistentFilesize.ValueInt64(), 10)) + } + if !data.PersistentBatch.IsNull() && !data.PersistentBatch.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.batch", strconv.FormatInt(data.PersistentBatch.ValueInt64(), 10)) + } + if !data.PersistentThreshold.IsNull() && !data.PersistentThreshold.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.threshold", strconv.FormatInt(data.PersistentThreshold.ValueInt64(), 10)) + } + if !data.PersistentImmediate.IsNull() && !data.PersistentImmediate.IsUnknown() { + if data.PersistentImmediate.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.immediate", map[string]string{}) + } + } + if !data.PersistentNotify.IsNull() && !data.PersistentNotify.IsUnknown() { + if data.PersistentNotify.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.notify", map[string]string{}) + } + } + if !data.PersistentProtected.IsNull() && !data.PersistentProtected.IsUnknown() { + if data.PersistentProtected.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"persistent.protected", map[string]string{}) + } + } + if !data.RateLimitAll.IsNull() && !data.RateLimitAll.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"rate-limit-config.common-config.rate-limit.all.common-options.range", strconv.FormatInt(data.RateLimitAll.ValueInt64(), 10)) + } + if !data.RateLimitAllExceptSeverity.IsNull() && !data.RateLimitAllExceptSeverity.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"rate-limit-config.common-config.rate-limit.all.common-options.except.range", data.RateLimitAllExceptSeverity.ValueString()) + } + if !data.RateLimitConsole.IsNull() && !data.RateLimitConsole.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"rate-limit-config.common-config.rate-limit.console.common-options.range", strconv.FormatInt(data.RateLimitConsole.ValueInt64(), 10)) + } + if !data.RateLimitConsoleExceptSeverity.IsNull() && !data.RateLimitConsoleExceptSeverity.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"rate-limit-config.common-config.rate-limit.console.common-options.except.range", data.RateLimitConsoleExceptSeverity.ValueString()) + } + if !data.RateLimitConsoleAll.IsNull() && !data.RateLimitConsoleAll.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"rate-limit-config.common-config.rate-limit.console.all.common-options.range", strconv.FormatInt(data.RateLimitConsoleAll.ValueInt64(), 10)) + } + if !data.RateLimitConsoleAllExceptSeverity.IsNull() && !data.RateLimitConsoleAllExceptSeverity.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"rate-limit-config.common-config.rate-limit.console.all.common-options.except.range", data.RateLimitConsoleAllExceptSeverity.ValueString()) + } if len(data.SourceInterfacesVrf) > 0 { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source-interface-conf.source-interface-vrf", []interface{}{}) for index, item := range data.SourceInterfacesVrf { @@ -1217,6 +1300,97 @@ func (data *Logging) updateFromBody(ctx context.Context, res gjson.Result) { } } } + if value := res.Get(prefix + "count"); !data.LoggingCount.IsNull() { + if value.Exists() { + data.LoggingCount = types.BoolValue(true) + } else { + data.LoggingCount = types.BoolValue(false) + } + } else { + data.LoggingCount = types.BoolNull() + } + if value := res.Get(prefix + "persistent.url"); value.Exists() && !data.PersistentUrl.IsNull() { + data.PersistentUrl = types.StringValue(value.String()) + } else { + data.PersistentUrl = types.StringNull() + } + if value := res.Get(prefix + "persistent.size"); value.Exists() && !data.PersistentSize.IsNull() { + data.PersistentSize = types.Int64Value(value.Int()) + } else { + data.PersistentSize = types.Int64Null() + } + if value := res.Get(prefix + "persistent.filesize"); value.Exists() && !data.PersistentFilesize.IsNull() { + data.PersistentFilesize = types.Int64Value(value.Int()) + } else { + data.PersistentFilesize = types.Int64Null() + } + if value := res.Get(prefix + "persistent.batch"); value.Exists() && !data.PersistentBatch.IsNull() { + data.PersistentBatch = types.Int64Value(value.Int()) + } else { + data.PersistentBatch = types.Int64Null() + } + if value := res.Get(prefix + "persistent.threshold"); value.Exists() && !data.PersistentThreshold.IsNull() { + data.PersistentThreshold = types.Int64Value(value.Int()) + } else { + data.PersistentThreshold = types.Int64Null() + } + if value := res.Get(prefix + "persistent.immediate"); !data.PersistentImmediate.IsNull() { + if value.Exists() { + data.PersistentImmediate = types.BoolValue(true) + } else { + data.PersistentImmediate = types.BoolValue(false) + } + } else { + data.PersistentImmediate = types.BoolNull() + } + if value := res.Get(prefix + "persistent.notify"); !data.PersistentNotify.IsNull() { + if value.Exists() { + data.PersistentNotify = types.BoolValue(true) + } else { + data.PersistentNotify = types.BoolValue(false) + } + } else { + data.PersistentNotify = types.BoolNull() + } + if value := res.Get(prefix + "persistent.protected"); !data.PersistentProtected.IsNull() { + if value.Exists() { + data.PersistentProtected = types.BoolValue(true) + } else { + data.PersistentProtected = types.BoolValue(false) + } + } else { + data.PersistentProtected = types.BoolNull() + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.all.common-options.range"); value.Exists() && !data.RateLimitAll.IsNull() { + data.RateLimitAll = types.Int64Value(value.Int()) + } else { + data.RateLimitAll = types.Int64Null() + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.all.common-options.except.range"); value.Exists() && !data.RateLimitAllExceptSeverity.IsNull() { + data.RateLimitAllExceptSeverity = types.StringValue(value.String()) + } else { + data.RateLimitAllExceptSeverity = types.StringNull() + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.common-options.range"); value.Exists() && !data.RateLimitConsole.IsNull() { + data.RateLimitConsole = types.Int64Value(value.Int()) + } else { + data.RateLimitConsole = types.Int64Null() + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.common-options.except.range"); value.Exists() && !data.RateLimitConsoleExceptSeverity.IsNull() { + data.RateLimitConsoleExceptSeverity = types.StringValue(value.String()) + } else { + data.RateLimitConsoleExceptSeverity = types.StringNull() + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.all.common-options.range"); value.Exists() && !data.RateLimitConsoleAll.IsNull() { + data.RateLimitConsoleAll = types.Int64Value(value.Int()) + } else { + data.RateLimitConsoleAll = types.Int64Null() + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.all.common-options.except.range"); value.Exists() && !data.RateLimitConsoleAllExceptSeverity.IsNull() { + data.RateLimitConsoleAllExceptSeverity = types.StringValue(value.String()) + } else { + data.RateLimitConsoleAllExceptSeverity = types.StringNull() + } } // End of section. //template:end updateFromBody @@ -1541,6 +1715,59 @@ func (data *Logging) fromBody(ctx context.Context, res gjson.Result) { return true }) } + if value := res.Get(prefix + "count"); value.Exists() { + data.LoggingCount = types.BoolValue(true) + } else { + data.LoggingCount = types.BoolValue(false) + } + if value := res.Get(prefix + "persistent.url"); value.Exists() { + data.PersistentUrl = types.StringValue(value.String()) + } + if value := res.Get(prefix + "persistent.size"); value.Exists() { + data.PersistentSize = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.filesize"); value.Exists() { + data.PersistentFilesize = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.batch"); value.Exists() { + data.PersistentBatch = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.threshold"); value.Exists() { + data.PersistentThreshold = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.immediate"); value.Exists() { + data.PersistentImmediate = types.BoolValue(true) + } else { + data.PersistentImmediate = types.BoolValue(false) + } + if value := res.Get(prefix + "persistent.notify"); value.Exists() { + data.PersistentNotify = types.BoolValue(true) + } else { + data.PersistentNotify = types.BoolValue(false) + } + if value := res.Get(prefix + "persistent.protected"); value.Exists() { + data.PersistentProtected = types.BoolValue(true) + } else { + data.PersistentProtected = types.BoolValue(false) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.all.common-options.range"); value.Exists() { + data.RateLimitAll = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.all.common-options.except.range"); value.Exists() { + data.RateLimitAllExceptSeverity = types.StringValue(value.String()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.common-options.range"); value.Exists() { + data.RateLimitConsole = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.common-options.except.range"); value.Exists() { + data.RateLimitConsoleExceptSeverity = types.StringValue(value.String()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.all.common-options.range"); value.Exists() { + data.RateLimitConsoleAll = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.all.common-options.except.range"); value.Exists() { + data.RateLimitConsoleAllExceptSeverity = types.StringValue(value.String()) + } } // End of section. //template:end fromBody @@ -1865,6 +2092,59 @@ func (data *LoggingData) fromBody(ctx context.Context, res gjson.Result) { return true }) } + if value := res.Get(prefix + "count"); value.Exists() { + data.LoggingCount = types.BoolValue(true) + } else { + data.LoggingCount = types.BoolValue(false) + } + if value := res.Get(prefix + "persistent.url"); value.Exists() { + data.PersistentUrl = types.StringValue(value.String()) + } + if value := res.Get(prefix + "persistent.size"); value.Exists() { + data.PersistentSize = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.filesize"); value.Exists() { + data.PersistentFilesize = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.batch"); value.Exists() { + data.PersistentBatch = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.threshold"); value.Exists() { + data.PersistentThreshold = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "persistent.immediate"); value.Exists() { + data.PersistentImmediate = types.BoolValue(true) + } else { + data.PersistentImmediate = types.BoolValue(false) + } + if value := res.Get(prefix + "persistent.notify"); value.Exists() { + data.PersistentNotify = types.BoolValue(true) + } else { + data.PersistentNotify = types.BoolValue(false) + } + if value := res.Get(prefix + "persistent.protected"); value.Exists() { + data.PersistentProtected = types.BoolValue(true) + } else { + data.PersistentProtected = types.BoolValue(false) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.all.common-options.range"); value.Exists() { + data.RateLimitAll = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.all.common-options.except.range"); value.Exists() { + data.RateLimitAllExceptSeverity = types.StringValue(value.String()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.common-options.range"); value.Exists() { + data.RateLimitConsole = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.common-options.except.range"); value.Exists() { + data.RateLimitConsoleExceptSeverity = types.StringValue(value.String()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.all.common-options.range"); value.Exists() { + data.RateLimitConsoleAll = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "rate-limit-config.common-config.rate-limit.console.all.common-options.except.range"); value.Exists() { + data.RateLimitConsoleAllExceptSeverity = types.StringValue(value.String()) + } } // End of section. //template:end fromBodyData @@ -1873,6 +2153,51 @@ func (data *LoggingData) fromBody(ctx context.Context, res gjson.Result) { func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []string { deletedItems := make([]string, 0) + if !state.RateLimitConsoleAllExceptSeverity.IsNull() && data.RateLimitConsoleAllExceptSeverity.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/all/common-options/except/range", state.getPath())) + } + if !state.RateLimitConsoleAll.IsNull() && data.RateLimitConsoleAll.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/all/common-options/range", state.getPath())) + } + if !state.RateLimitConsoleExceptSeverity.IsNull() && data.RateLimitConsoleExceptSeverity.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/common-options/except/range", state.getPath())) + } + if !state.RateLimitConsole.IsNull() && data.RateLimitConsole.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/common-options/range", state.getPath())) + } + if !state.RateLimitAllExceptSeverity.IsNull() && data.RateLimitAllExceptSeverity.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/all/common-options/except/range", state.getPath())) + } + if !state.RateLimitAll.IsNull() && data.RateLimitAll.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/all/common-options/range", state.getPath())) + } + if !state.PersistentProtected.IsNull() && data.PersistentProtected.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/protected", state.getPath())) + } + if !state.PersistentNotify.IsNull() && data.PersistentNotify.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/notify", state.getPath())) + } + if !state.PersistentImmediate.IsNull() && data.PersistentImmediate.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/immediate", state.getPath())) + } + if !state.PersistentThreshold.IsNull() && data.PersistentThreshold.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/threshold", state.getPath())) + } + if !state.PersistentBatch.IsNull() && data.PersistentBatch.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/batch", state.getPath())) + } + if !state.PersistentFilesize.IsNull() && data.PersistentFilesize.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/filesize", state.getPath())) + } + if !state.PersistentSize.IsNull() && data.PersistentSize.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/size", state.getPath())) + } + if !state.PersistentUrl.IsNull() && data.PersistentUrl.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/persistent/url", state.getPath())) + } + if !state.LoggingCount.IsNull() && data.LoggingCount.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/count", state.getPath())) + } for i := range state.Ipv6VrfHostsTransport { stateKeyValues := [...]string{state.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString(), state.Ipv6VrfHostsTransport[i].Vrf.ValueString()} @@ -2498,6 +2823,18 @@ func (data *Logging) getDeletedItems(ctx context.Context, state Logging) []strin func (data *Logging) getEmptyLeafsDelete(ctx context.Context) []string { emptyLeafsDelete := make([]string, 0) + if !data.PersistentProtected.IsNull() && !data.PersistentProtected.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/persistent/protected", data.getPath())) + } + if !data.PersistentNotify.IsNull() && !data.PersistentNotify.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/persistent/notify", data.getPath())) + } + if !data.PersistentImmediate.IsNull() && !data.PersistentImmediate.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/persistent/immediate", data.getPath())) + } + if !data.LoggingCount.IsNull() && !data.LoggingCount.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/count", data.getPath())) + } if !data.Trap.IsNull() && !data.Trap.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/trap", data.getPath())) @@ -2512,6 +2849,51 @@ func (data *Logging) getEmptyLeafsDelete(ctx context.Context) []string { func (data *Logging) getDeletePaths(ctx context.Context) []string { var deletePaths []string + if !data.RateLimitConsoleAllExceptSeverity.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/all/common-options/except/range", data.getPath())) + } + if !data.RateLimitConsoleAll.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/all/common-options/range", data.getPath())) + } + if !data.RateLimitConsoleExceptSeverity.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/common-options/except/range", data.getPath())) + } + if !data.RateLimitConsole.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/console/common-options/range", data.getPath())) + } + if !data.RateLimitAllExceptSeverity.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/all/common-options/except/range", data.getPath())) + } + if !data.RateLimitAll.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/rate-limit-config/common-config/rate-limit/all/common-options/range", data.getPath())) + } + if !data.PersistentProtected.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/protected", data.getPath())) + } + if !data.PersistentNotify.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/notify", data.getPath())) + } + if !data.PersistentImmediate.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/immediate", data.getPath())) + } + if !data.PersistentThreshold.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/threshold", data.getPath())) + } + if !data.PersistentBatch.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/batch", data.getPath())) + } + if !data.PersistentFilesize.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/filesize", data.getPath())) + } + if !data.PersistentSize.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/size", data.getPath())) + } + if !data.PersistentUrl.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/persistent/url", data.getPath())) + } + if !data.LoggingCount.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/count", data.getPath())) + } for i := range data.Ipv6VrfHostsTransport { keyValues := [...]string{data.Ipv6VrfHostsTransport[i].Ipv6Host.ValueString(), data.Ipv6VrfHostsTransport[i].Vrf.ValueString()} diff --git a/internal/provider/resource_iosxe_logging.go b/internal/provider/resource_iosxe_logging.go index 4ebeeda22..c08ffdef9 100644 --- a/internal/provider/resource_iosxe_logging.go +++ b/internal/provider/resource_iosxe_logging.go @@ -23,6 +23,7 @@ package provider import ( "context" "fmt" + "regexp" "strings" "github.com/CiscoDevNet/terraform-provider-iosxe/internal/provider/helpers" @@ -488,6 +489,100 @@ func (r *LoggingResource) Schema(ctx context.Context, req resource.SchemaRequest }, }, }, + "logging_count": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Count every log message and timestamp last occurrence").String, + Optional: true, + }, + "persistent_url": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("URL to store logging messages").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.RegexMatches(regexp.MustCompile(`(((bootflash:/)|(cns:/)|(flash:/)|(ftp:/)|(http:/)|(https:/)|(null:/)|(crashinfo:/) +(nvram:/)|(pram:/)|(rcp:/)|(scp:/)|(sftp:/)|(system:/)|(tar:/)|(tftp:/)|(tmpsys:/)|(webui:/)).*)`), ""), + }, + }, + "persistent_size": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Set disk space for writing log messages").AddIntegerRangeDescription(16384, 2147483647).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(16384, 2147483647), + }, + }, + "persistent_filesize": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Set size of individual log files").AddIntegerRangeDescription(8192, 2147483647).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(8192, 2147483647), + }, + }, + "persistent_batch": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Batch size for writing to persistent storage").AddIntegerRangeDescription(4096, 2147483647).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(4096, 2147483647), + }, + }, + "persistent_threshold": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Setting threshold capacity. When setting circular logging is disabled").AddIntegerRangeDescription(1, 99).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 99), + }, + }, + "persistent_immediate": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Write log entry to storage immediately (no buffering).").String, + Optional: true, + }, + "persistent_notify": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Notify when show logging [persistent] is activated.").String, + Optional: true, + }, + "persistent_protected": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Eliminates manipulation on logging-persistent files").String, + Optional: true, + }, + "rate_limit_all": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Messages per second").AddIntegerRangeDescription(1, 10000).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 10000), + }, + }, + "rate_limit_all_except_severity": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Logging severity level").AddStringEnumDescription("alerts", "critical", "debugging", "emergencies", "errors", "informational", "notifications", "warnings").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("alerts", "critical", "debugging", "emergencies", "errors", "informational", "notifications", "warnings"), + }, + }, + "rate_limit_console": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Messages per second").AddIntegerRangeDescription(1, 10000).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 10000), + }, + }, + "rate_limit_console_except_severity": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Logging severity level").AddStringEnumDescription("alerts", "critical", "debugging", "emergencies", "errors", "informational", "notifications", "warnings").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("alerts", "critical", "debugging", "emergencies", "errors", "informational", "notifications", "warnings"), + }, + }, + "rate_limit_console_all": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Messages per second").AddIntegerRangeDescription(1, 10000).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 10000), + }, + }, + "rate_limit_console_all_except_severity": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Logging severity level").AddStringEnumDescription("alerts", "critical", "debugging", "emergencies", "errors", "informational", "notifications", "warnings").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("alerts", "critical", "debugging", "emergencies", "errors", "informational", "notifications", "warnings"), + }, + }, }, } } diff --git a/internal/provider/resource_iosxe_logging_test.go b/internal/provider/resource_iosxe_logging_test.go index e2418352a..fd91edc4b 100644 --- a/internal/provider/resource_iosxe_logging_test.go +++ b/internal/provider/resource_iosxe_logging_test.go @@ -71,6 +71,11 @@ func TestAccIosxeLogging(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "ipv6_vrf_hosts_transport.0.transport_udp_ports.0.port_number", "10000")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "ipv6_vrf_hosts_transport.0.transport_tcp_ports.0.port_number", "10001")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "ipv6_vrf_hosts_transport.0.transport_tls_ports.0.port_number", "10002")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "logging_count", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "persistent_url", "flash:/local_logging")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "persistent_size", "1000000")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "persistent_filesize", "500000")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_logging.test", "rate_limit_all", "200")) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, @@ -87,7 +92,7 @@ func TestAccIosxeLogging(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateIdFunc: iosxeLoggingImportStateIdFunc("iosxe_logging.test"), - ImportStateVerifyIgnore: []string{}, + ImportStateVerifyIgnore: []string{"persistent_immediate", "persistent_notify", "persistent_protected"}, Check: resource.ComposeTestCheckFunc(checks...), }, }, @@ -226,6 +231,11 @@ func testAccIosxeLoggingConfig_all() string { config += ` port_number = 10002` + "\n" config += ` }]` + "\n" config += ` }]` + "\n" + config += ` logging_count = true` + "\n" + config += ` persistent_url = "flash:/local_logging"` + "\n" + config += ` persistent_size = 1000000` + "\n" + config += ` persistent_filesize = 500000` + "\n" + config += ` rate_limit_all = 200` + "\n" config += ` depends_on = [iosxe_restconf.PreReq0, iosxe_restconf.PreReq1, ]` + "\n" config += `}` + "\n" return config