diff --git a/CHANGELOG.md b/CHANGELOG.md index 88f672fb..5d7d6d26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +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 + ## 0.2.3 - Add `timers_bgp_minimum_acceptable_holdtime` attribute to `iosxr_router_bgp` resource and data source diff --git a/docs/data-sources/flow_monitor_map.md b/docs/data-sources/flow_monitor_map.md index f6f7ab0f..cd8ce163 100644 --- a/docs/data-sources/flow_monitor_map.md +++ b/docs/data-sources/flow_monitor_map.md @@ -48,6 +48,7 @@ data "iosxr_flow_monitor_map" "example" { - `record_datalink_record` (Boolean) Layer2 traffic based flow - `record_default_mdi` (Boolean) Default MDI record format - `record_default_rtp` (Boolean) Default RTP record format +- `record_ipv4` (Boolean) IPv4 raw record format - `record_ipv4_as` (Boolean) Autonomous System based aggregation - `record_ipv4_as_tos` (Boolean) AS-TOS based aggregation - `record_ipv4_bgp_nexthop_tos` (Boolean) BGP, nexthop and tos based aggregation @@ -64,15 +65,18 @@ data "iosxr_flow_monitor_map" "example" { - `record_ipv4_protocol_port_tos` (Boolean) Protocol, port and tos based aggregation - `record_ipv4_source_prefix` (Boolean) source prefix based aggregation - `record_ipv4_source_prefix_tos` (Boolean) Source, Prefix and TOS based aggregation +- `record_ipv6` (Boolean) IPv6 raw record format - `record_ipv6_destination` (Boolean) IPv6 Destination Based NetFlow Accounting - `record_ipv6_gtp` (Boolean) IPV6 gtp record format - `record_ipv6_peer_as` (Boolean) Record peer AS - `record_map_t` (Boolean) map-t translation based Netflow +- `record_mpls` (Boolean) MPLS record format - `record_mpls_ipv4_fields` (Boolean) MPLS with IPv4 fields format - `record_mpls_ipv4_ipv6_fields` (Boolean) MPLS with IPv4 and IPv6 fields format - `record_mpls_ipv6_fields` (Boolean) MPLS with IPv6 fields format - `record_mpls_labels` (Number) Labels to be used for Hashing - `record_sflow` (Boolean) sFlow based flow +- `sflow_options` (Boolean) submode to configure sFlow related options - `sflow_options_extended_gateway` (Boolean) Enable extended-gateway flow data type - `sflow_options_extended_ipv4_tunnel_egress` (Boolean) Enable extended-ipv4-tunnel-egress flow data type - `sflow_options_extended_ipv6_tunnel_egress` (Boolean) Enable extended-ipv6-tunnel-egress flow data type diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index ea63c084..70db9202 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -7,6 +7,10 @@ description: |- # Changelog +## 0.2.4 (unreleased) + +- Add `record_ipv4`, `record_ipv6`, `record_mpls` and `sflow_options` attributes to `iosxr_flow_monitor_map` resource and data source + ## 0.2.3 - Add `timers_bgp_minimum_acceptable_holdtime` attribute to `iosxr_router_bgp` resource and data source diff --git a/docs/resources/flow_monitor_map.md b/docs/resources/flow_monitor_map.md index 40cb342f..b1d4801e 100644 --- a/docs/resources/flow_monitor_map.md +++ b/docs/resources/flow_monitor_map.md @@ -24,6 +24,7 @@ resource "iosxr_flow_monitor_map" "example" { option_filtered = true option_bgpattr = true option_outbundlemember = true + record_ipv4 = true record_ipv4_destination = true record_ipv4_destination_tos = true record_ipv4_as = true @@ -40,9 +41,11 @@ resource "iosxr_flow_monitor_map" "example" { record_ipv4_bgp_nexthop_tos = true record_ipv4_peer_as = true record_ipv4_gtp = true + record_ipv6 = true record_ipv6_destination = true record_ipv6_peer_as = true record_ipv6_gtp = true + record_mpls = true record_mpls_ipv4_fields = true record_mpls_ipv6_fields = true record_mpls_ipv4_ipv6_fields = true @@ -60,6 +63,7 @@ resource "iosxr_flow_monitor_map" "example" { cache_permanent = true cache_immediate = true hw_cache_timeout_inactive = 50 + sflow_options = true sflow_options_extended_router = true sflow_options_extended_gateway = true sflow_options_extended_ipv4_tunnel_egress = true @@ -103,6 +107,7 @@ resource "iosxr_flow_monitor_map" "example" { - `record_datalink_record` (Boolean) Layer2 traffic based flow - `record_default_mdi` (Boolean) Default MDI record format - `record_default_rtp` (Boolean) Default RTP record format +- `record_ipv4` (Boolean) IPv4 raw record format - `record_ipv4_as` (Boolean) Autonomous System based aggregation - `record_ipv4_as_tos` (Boolean) AS-TOS based aggregation - `record_ipv4_bgp_nexthop_tos` (Boolean) BGP, nexthop and tos based aggregation @@ -119,16 +124,19 @@ resource "iosxr_flow_monitor_map" "example" { - `record_ipv4_protocol_port_tos` (Boolean) Protocol, port and tos based aggregation - `record_ipv4_source_prefix` (Boolean) source prefix based aggregation - `record_ipv4_source_prefix_tos` (Boolean) Source, Prefix and TOS based aggregation +- `record_ipv6` (Boolean) IPv6 raw record format - `record_ipv6_destination` (Boolean) IPv6 Destination Based NetFlow Accounting - `record_ipv6_gtp` (Boolean) IPV6 gtp record format - `record_ipv6_peer_as` (Boolean) Record peer AS - `record_map_t` (Boolean) map-t translation based Netflow +- `record_mpls` (Boolean) MPLS record format - `record_mpls_ipv4_fields` (Boolean) MPLS with IPv4 fields format - `record_mpls_ipv4_ipv6_fields` (Boolean) MPLS with IPv4 and IPv6 fields format - `record_mpls_ipv6_fields` (Boolean) MPLS with IPv6 fields format - `record_mpls_labels` (Number) Labels to be used for Hashing - Range: `1`-`6` - `record_sflow` (Boolean) sFlow based flow +- `sflow_options` (Boolean) submode to configure sFlow related options - `sflow_options_extended_gateway` (Boolean) Enable extended-gateway flow data type - `sflow_options_extended_ipv4_tunnel_egress` (Boolean) Enable extended-ipv4-tunnel-egress flow data type - `sflow_options_extended_ipv6_tunnel_egress` (Boolean) Enable extended-ipv6-tunnel-egress flow data type diff --git a/examples/resources/iosxr_flow_monitor_map/resource.tf b/examples/resources/iosxr_flow_monitor_map/resource.tf index 3e6631ee..ccdaf1f0 100644 --- a/examples/resources/iosxr_flow_monitor_map/resource.tf +++ b/examples/resources/iosxr_flow_monitor_map/resource.tf @@ -9,6 +9,7 @@ resource "iosxr_flow_monitor_map" "example" { option_filtered = true option_bgpattr = true option_outbundlemember = true + record_ipv4 = true record_ipv4_destination = true record_ipv4_destination_tos = true record_ipv4_as = true @@ -25,9 +26,11 @@ resource "iosxr_flow_monitor_map" "example" { record_ipv4_bgp_nexthop_tos = true record_ipv4_peer_as = true record_ipv4_gtp = true + record_ipv6 = true record_ipv6_destination = true record_ipv6_peer_as = true record_ipv6_gtp = true + record_mpls = true record_mpls_ipv4_fields = true record_mpls_ipv6_fields = true record_mpls_ipv4_ipv6_fields = true @@ -45,6 +48,7 @@ resource "iosxr_flow_monitor_map" "example" { cache_permanent = true cache_immediate = true hw_cache_timeout_inactive = 50 + sflow_options = true sflow_options_extended_router = true sflow_options_extended_gateway = true sflow_options_extended_ipv4_tunnel_egress = true diff --git a/gen/definitions/flow_monitor_map.yaml b/gen/definitions/flow_monitor_map.yaml index 7d4d92ef..fe7ca2aa 100644 --- a/gen/definitions/flow_monitor_map.yaml +++ b/gen/definitions/flow_monitor_map.yaml @@ -23,6 +23,8 @@ attributes: example: true - yang_name: option/outbundlemember example: true + - yang_name: record/ipv4 + example: true - yang_name: record/ipv4/destination example: true - yang_name: record/ipv4/destination-tos @@ -55,12 +57,16 @@ attributes: example: true - yang_name: record/ipv4/gtp example: true + - yang_name: record/ipv6 + example: true - yang_name: record/ipv6/destination example: true - yang_name: record/ipv6/peer-as example: true - yang_name: record/ipv6/gtp example: true + - yang_name: record/mpls + example: true - yang_name: record/mpls/ipv4-fields example: true - yang_name: record/mpls/ipv6-fields @@ -95,6 +101,8 @@ attributes: example: true - yang_name: hw-cache/timeout/inactive example: 50 + - yang_name: sflow/options + example: true - yang_name: sflow/options/extended-router example: true - yang_name: sflow/options/extended-gateway diff --git a/internal/provider/data_source_iosxr_flow_monitor_map.go b/internal/provider/data_source_iosxr_flow_monitor_map.go index e04e5fc5..32d504c7 100644 --- a/internal/provider/data_source_iosxr_flow_monitor_map.go +++ b/internal/provider/data_source_iosxr_flow_monitor_map.go @@ -94,6 +94,10 @@ func (d *FlowMonitorMapDataSource) Schema(ctx context.Context, req datasource.Sc MarkdownDescription: "export output physical interfaces of bundle interface", Computed: true, }, + "record_ipv4": schema.BoolAttribute{ + MarkdownDescription: "IPv4 raw record format", + Computed: true, + }, "record_ipv4_destination": schema.BoolAttribute{ MarkdownDescription: "IPv4 Destination Based NetFlow Accounting", Computed: true, @@ -158,6 +162,10 @@ func (d *FlowMonitorMapDataSource) Schema(ctx context.Context, req datasource.Sc MarkdownDescription: "IPV4 gtp record format", Computed: true, }, + "record_ipv6": schema.BoolAttribute{ + MarkdownDescription: "IPv6 raw record format", + Computed: true, + }, "record_ipv6_destination": schema.BoolAttribute{ MarkdownDescription: "IPv6 Destination Based NetFlow Accounting", Computed: true, @@ -170,6 +178,10 @@ func (d *FlowMonitorMapDataSource) Schema(ctx context.Context, req datasource.Sc MarkdownDescription: "IPV6 gtp record format", Computed: true, }, + "record_mpls": schema.BoolAttribute{ + MarkdownDescription: "MPLS record format", + Computed: true, + }, "record_mpls_ipv4_fields": schema.BoolAttribute{ MarkdownDescription: "MPLS with IPv4 fields format", Computed: true, @@ -238,6 +250,10 @@ func (d *FlowMonitorMapDataSource) Schema(ctx context.Context, req datasource.Sc MarkdownDescription: "Specify the inactive timeout", Computed: true, }, + "sflow_options": schema.BoolAttribute{ + MarkdownDescription: "submode to configure sFlow related options", + Computed: true, + }, "sflow_options_extended_router": schema.BoolAttribute{ MarkdownDescription: "Enable extended-router flow data type", Computed: true, diff --git a/internal/provider/data_source_iosxr_flow_monitor_map_test.go b/internal/provider/data_source_iosxr_flow_monitor_map_test.go index 33f0ec9c..4d011c9b 100644 --- a/internal/provider/data_source_iosxr_flow_monitor_map_test.go +++ b/internal/provider/data_source_iosxr_flow_monitor_map_test.go @@ -36,6 +36,7 @@ func TestAccDataSourceIosxrFlowMonitorMap(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "option_filtered", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "option_bgpattr", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "option_outbundlemember", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv4", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv4_destination", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv4_destination_tos", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv4_as", "true")) @@ -52,9 +53,11 @@ func TestAccDataSourceIosxrFlowMonitorMap(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv4_bgp_nexthop_tos", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv4_peer_as", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv4_gtp", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv6", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv6_destination", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv6_peer_as", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_ipv6_gtp", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_mpls", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_mpls_ipv4_fields", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_mpls_ipv6_fields", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "record_mpls_ipv4_ipv6_fields", "true")) @@ -72,6 +75,7 @@ func TestAccDataSourceIosxrFlowMonitorMap(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "cache_permanent", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "cache_immediate", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "hw_cache_timeout_inactive", "50")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "sflow_options", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "sflow_options_extended_router", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "sflow_options_extended_gateway", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxr_flow_monitor_map.test", "sflow_options_extended_ipv4_tunnel_egress", "true")) @@ -102,6 +106,7 @@ func testAccDataSourceIosxrFlowMonitorMapConfig() string { config += ` option_filtered = true` + "\n" config += ` option_bgpattr = true` + "\n" config += ` option_outbundlemember = true` + "\n" + config += ` record_ipv4 = true` + "\n" config += ` record_ipv4_destination = true` + "\n" config += ` record_ipv4_destination_tos = true` + "\n" config += ` record_ipv4_as = true` + "\n" @@ -118,9 +123,11 @@ func testAccDataSourceIosxrFlowMonitorMapConfig() string { config += ` record_ipv4_bgp_nexthop_tos = true` + "\n" config += ` record_ipv4_peer_as = true` + "\n" config += ` record_ipv4_gtp = true` + "\n" + config += ` record_ipv6 = true` + "\n" config += ` record_ipv6_destination = true` + "\n" config += ` record_ipv6_peer_as = true` + "\n" config += ` record_ipv6_gtp = true` + "\n" + config += ` record_mpls = true` + "\n" config += ` record_mpls_ipv4_fields = true` + "\n" config += ` record_mpls_ipv6_fields = true` + "\n" config += ` record_mpls_ipv4_ipv6_fields = true` + "\n" @@ -138,6 +145,7 @@ func testAccDataSourceIosxrFlowMonitorMapConfig() string { config += ` cache_permanent = true` + "\n" config += ` cache_immediate = true` + "\n" config += ` hw_cache_timeout_inactive = 50` + "\n" + config += ` sflow_options = true` + "\n" config += ` sflow_options_extended_router = true` + "\n" config += ` sflow_options_extended_gateway = true` + "\n" config += ` sflow_options_extended_ipv4_tunnel_egress = true` + "\n" diff --git a/internal/provider/model_iosxr_flow_monitor_map.go b/internal/provider/model_iosxr_flow_monitor_map.go index 1c540f3c..3e2bd7b7 100644 --- a/internal/provider/model_iosxr_flow_monitor_map.go +++ b/internal/provider/model_iosxr_flow_monitor_map.go @@ -39,6 +39,7 @@ type FlowMonitorMap struct { OptionFiltered types.Bool `tfsdk:"option_filtered"` OptionBgpattr types.Bool `tfsdk:"option_bgpattr"` OptionOutbundlemember types.Bool `tfsdk:"option_outbundlemember"` + RecordIpv4 types.Bool `tfsdk:"record_ipv4"` RecordIpv4Destination types.Bool `tfsdk:"record_ipv4_destination"` RecordIpv4DestinationTos types.Bool `tfsdk:"record_ipv4_destination_tos"` RecordIpv4As types.Bool `tfsdk:"record_ipv4_as"` @@ -55,9 +56,11 @@ type FlowMonitorMap struct { RecordIpv4BgpNexthopTos types.Bool `tfsdk:"record_ipv4_bgp_nexthop_tos"` RecordIpv4PeerAs types.Bool `tfsdk:"record_ipv4_peer_as"` RecordIpv4Gtp types.Bool `tfsdk:"record_ipv4_gtp"` + RecordIpv6 types.Bool `tfsdk:"record_ipv6"` RecordIpv6Destination types.Bool `tfsdk:"record_ipv6_destination"` RecordIpv6PeerAs types.Bool `tfsdk:"record_ipv6_peer_as"` RecordIpv6Gtp types.Bool `tfsdk:"record_ipv6_gtp"` + RecordMpls types.Bool `tfsdk:"record_mpls"` RecordMplsIpv4Fields types.Bool `tfsdk:"record_mpls_ipv4_fields"` RecordMplsIpv6Fields types.Bool `tfsdk:"record_mpls_ipv6_fields"` RecordMplsIpv4Ipv6Fields types.Bool `tfsdk:"record_mpls_ipv4_ipv6_fields"` @@ -75,6 +78,7 @@ type FlowMonitorMap struct { CachePermanent types.Bool `tfsdk:"cache_permanent"` CacheImmediate types.Bool `tfsdk:"cache_immediate"` HwCacheTimeoutInactive types.Int64 `tfsdk:"hw_cache_timeout_inactive"` + SflowOptions types.Bool `tfsdk:"sflow_options"` SflowOptionsExtendedRouter types.Bool `tfsdk:"sflow_options_extended_router"` SflowOptionsExtendedGateway types.Bool `tfsdk:"sflow_options_extended_gateway"` SflowOptionsExtendedIpv4TunnelEgress types.Bool `tfsdk:"sflow_options_extended_ipv4_tunnel_egress"` @@ -94,6 +98,7 @@ type FlowMonitorMapData struct { OptionFiltered types.Bool `tfsdk:"option_filtered"` OptionBgpattr types.Bool `tfsdk:"option_bgpattr"` OptionOutbundlemember types.Bool `tfsdk:"option_outbundlemember"` + RecordIpv4 types.Bool `tfsdk:"record_ipv4"` RecordIpv4Destination types.Bool `tfsdk:"record_ipv4_destination"` RecordIpv4DestinationTos types.Bool `tfsdk:"record_ipv4_destination_tos"` RecordIpv4As types.Bool `tfsdk:"record_ipv4_as"` @@ -110,9 +115,11 @@ type FlowMonitorMapData struct { RecordIpv4BgpNexthopTos types.Bool `tfsdk:"record_ipv4_bgp_nexthop_tos"` RecordIpv4PeerAs types.Bool `tfsdk:"record_ipv4_peer_as"` RecordIpv4Gtp types.Bool `tfsdk:"record_ipv4_gtp"` + RecordIpv6 types.Bool `tfsdk:"record_ipv6"` RecordIpv6Destination types.Bool `tfsdk:"record_ipv6_destination"` RecordIpv6PeerAs types.Bool `tfsdk:"record_ipv6_peer_as"` RecordIpv6Gtp types.Bool `tfsdk:"record_ipv6_gtp"` + RecordMpls types.Bool `tfsdk:"record_mpls"` RecordMplsIpv4Fields types.Bool `tfsdk:"record_mpls_ipv4_fields"` RecordMplsIpv6Fields types.Bool `tfsdk:"record_mpls_ipv6_fields"` RecordMplsIpv4Ipv6Fields types.Bool `tfsdk:"record_mpls_ipv4_ipv6_fields"` @@ -130,6 +137,7 @@ type FlowMonitorMapData struct { CachePermanent types.Bool `tfsdk:"cache_permanent"` CacheImmediate types.Bool `tfsdk:"cache_immediate"` HwCacheTimeoutInactive types.Int64 `tfsdk:"hw_cache_timeout_inactive"` + SflowOptions types.Bool `tfsdk:"sflow_options"` SflowOptionsExtendedRouter types.Bool `tfsdk:"sflow_options_extended_router"` SflowOptionsExtendedGateway types.Bool `tfsdk:"sflow_options_extended_gateway"` SflowOptionsExtendedIpv4TunnelEgress types.Bool `tfsdk:"sflow_options_extended_ipv4_tunnel_egress"` @@ -176,6 +184,11 @@ func (data FlowMonitorMap) toBody(ctx context.Context) string { body, _ = sjson.Set(body, "option.outbundlemember", map[string]string{}) } } + if !data.RecordIpv4.IsNull() && !data.RecordIpv4.IsUnknown() { + if data.RecordIpv4.ValueBool() { + body, _ = sjson.Set(body, "record.ipv4", map[string]string{}) + } + } if !data.RecordIpv4Destination.IsNull() && !data.RecordIpv4Destination.IsUnknown() { if data.RecordIpv4Destination.ValueBool() { body, _ = sjson.Set(body, "record.ipv4.destination", map[string]string{}) @@ -256,6 +269,11 @@ func (data FlowMonitorMap) toBody(ctx context.Context) string { body, _ = sjson.Set(body, "record.ipv4.gtp", map[string]string{}) } } + if !data.RecordIpv6.IsNull() && !data.RecordIpv6.IsUnknown() { + if data.RecordIpv6.ValueBool() { + body, _ = sjson.Set(body, "record.ipv6", map[string]string{}) + } + } if !data.RecordIpv6Destination.IsNull() && !data.RecordIpv6Destination.IsUnknown() { if data.RecordIpv6Destination.ValueBool() { body, _ = sjson.Set(body, "record.ipv6.destination", map[string]string{}) @@ -271,6 +289,11 @@ func (data FlowMonitorMap) toBody(ctx context.Context) string { body, _ = sjson.Set(body, "record.ipv6.gtp", map[string]string{}) } } + if !data.RecordMpls.IsNull() && !data.RecordMpls.IsUnknown() { + if data.RecordMpls.ValueBool() { + body, _ = sjson.Set(body, "record.mpls", map[string]string{}) + } + } if !data.RecordMplsIpv4Fields.IsNull() && !data.RecordMplsIpv4Fields.IsUnknown() { if data.RecordMplsIpv4Fields.ValueBool() { body, _ = sjson.Set(body, "record.mpls.ipv4-fields", map[string]string{}) @@ -342,6 +365,11 @@ func (data FlowMonitorMap) toBody(ctx context.Context) string { if !data.HwCacheTimeoutInactive.IsNull() && !data.HwCacheTimeoutInactive.IsUnknown() { body, _ = sjson.Set(body, "hw-cache.timeout.inactive", strconv.FormatInt(data.HwCacheTimeoutInactive.ValueInt64(), 10)) } + if !data.SflowOptions.IsNull() && !data.SflowOptions.IsUnknown() { + if data.SflowOptions.ValueBool() { + body, _ = sjson.Set(body, "sflow.options", map[string]string{}) + } + } if !data.SflowOptionsExtendedRouter.IsNull() && !data.SflowOptionsExtendedRouter.IsUnknown() { if data.SflowOptionsExtendedRouter.ValueBool() { body, _ = sjson.Set(body, "sflow.options.extended-router", map[string]string{}) @@ -451,6 +479,15 @@ func (data *FlowMonitorMap) updateFromBody(ctx context.Context, res []byte) { } else { data.OptionOutbundlemember = types.BoolNull() } + if value := gjson.GetBytes(res, "record.ipv4"); !data.RecordIpv4.IsNull() { + if value.Exists() { + data.RecordIpv4 = types.BoolValue(true) + } else { + data.RecordIpv4 = types.BoolValue(false) + } + } else { + data.RecordIpv4 = types.BoolNull() + } if value := gjson.GetBytes(res, "record.ipv4.destination"); !data.RecordIpv4Destination.IsNull() { if value.Exists() { data.RecordIpv4Destination = types.BoolValue(true) @@ -595,6 +632,15 @@ func (data *FlowMonitorMap) updateFromBody(ctx context.Context, res []byte) { } else { data.RecordIpv4Gtp = types.BoolNull() } + if value := gjson.GetBytes(res, "record.ipv6"); !data.RecordIpv6.IsNull() { + if value.Exists() { + data.RecordIpv6 = types.BoolValue(true) + } else { + data.RecordIpv6 = types.BoolValue(false) + } + } else { + data.RecordIpv6 = types.BoolNull() + } if value := gjson.GetBytes(res, "record.ipv6.destination"); !data.RecordIpv6Destination.IsNull() { if value.Exists() { data.RecordIpv6Destination = types.BoolValue(true) @@ -622,6 +668,15 @@ func (data *FlowMonitorMap) updateFromBody(ctx context.Context, res []byte) { } else { data.RecordIpv6Gtp = types.BoolNull() } + if value := gjson.GetBytes(res, "record.mpls"); !data.RecordMpls.IsNull() { + if value.Exists() { + data.RecordMpls = types.BoolValue(true) + } else { + data.RecordMpls = types.BoolValue(false) + } + } else { + data.RecordMpls = types.BoolNull() + } if value := gjson.GetBytes(res, "record.mpls.ipv4-fields"); !data.RecordMplsIpv4Fields.IsNull() { if value.Exists() { data.RecordMplsIpv4Fields = types.BoolValue(true) @@ -747,6 +802,15 @@ func (data *FlowMonitorMap) updateFromBody(ctx context.Context, res []byte) { } else { data.HwCacheTimeoutInactive = types.Int64Null() } + if value := gjson.GetBytes(res, "sflow.options"); !data.SflowOptions.IsNull() { + if value.Exists() { + data.SflowOptions = types.BoolValue(true) + } else { + data.SflowOptions = types.BoolValue(false) + } + } else { + data.SflowOptions = types.BoolNull() + } if value := gjson.GetBytes(res, "sflow.options.extended-router"); !data.SflowOptionsExtendedRouter.IsNull() { if value.Exists() { data.SflowOptionsExtendedRouter = types.BoolValue(true) @@ -837,6 +901,11 @@ func (data *FlowMonitorMapData) fromBody(ctx context.Context, res []byte) { } else { data.OptionOutbundlemember = types.BoolValue(false) } + if value := gjson.GetBytes(res, "record.ipv4"); value.Exists() { + data.RecordIpv4 = types.BoolValue(true) + } else { + data.RecordIpv4 = types.BoolValue(false) + } if value := gjson.GetBytes(res, "record.ipv4.destination"); value.Exists() { data.RecordIpv4Destination = types.BoolValue(true) } else { @@ -917,6 +986,11 @@ func (data *FlowMonitorMapData) fromBody(ctx context.Context, res []byte) { } else { data.RecordIpv4Gtp = types.BoolValue(false) } + if value := gjson.GetBytes(res, "record.ipv6"); value.Exists() { + data.RecordIpv6 = types.BoolValue(true) + } else { + data.RecordIpv6 = types.BoolValue(false) + } if value := gjson.GetBytes(res, "record.ipv6.destination"); value.Exists() { data.RecordIpv6Destination = types.BoolValue(true) } else { @@ -932,6 +1006,11 @@ func (data *FlowMonitorMapData) fromBody(ctx context.Context, res []byte) { } else { data.RecordIpv6Gtp = types.BoolValue(false) } + if value := gjson.GetBytes(res, "record.mpls"); value.Exists() { + data.RecordMpls = types.BoolValue(true) + } else { + data.RecordMpls = types.BoolValue(false) + } if value := gjson.GetBytes(res, "record.mpls.ipv4-fields"); value.Exists() { data.RecordMplsIpv4Fields = types.BoolValue(true) } else { @@ -1003,6 +1082,11 @@ func (data *FlowMonitorMapData) fromBody(ctx context.Context, res []byte) { if value := gjson.GetBytes(res, "hw-cache.timeout.inactive"); value.Exists() { data.HwCacheTimeoutInactive = types.Int64Value(value.Int()) } + if value := gjson.GetBytes(res, "sflow.options"); value.Exists() { + data.SflowOptions = types.BoolValue(true) + } else { + data.SflowOptions = types.BoolValue(false) + } if value := gjson.GetBytes(res, "sflow.options.extended-router"); value.Exists() { data.SflowOptionsExtendedRouter = types.BoolValue(true) } else { @@ -1094,6 +1178,9 @@ func (data *FlowMonitorMap) getEmptyLeafsDelete(ctx context.Context) []string { if !data.OptionOutbundlemember.IsNull() && !data.OptionOutbundlemember.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/option/outbundlemember", data.getPath())) } + if !data.RecordIpv4.IsNull() && !data.RecordIpv4.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/ipv4", data.getPath())) + } if !data.RecordIpv4Destination.IsNull() && !data.RecordIpv4Destination.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/ipv4/destination", data.getPath())) } @@ -1142,6 +1229,9 @@ func (data *FlowMonitorMap) getEmptyLeafsDelete(ctx context.Context) []string { if !data.RecordIpv4Gtp.IsNull() && !data.RecordIpv4Gtp.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/ipv4/gtp", data.getPath())) } + if !data.RecordIpv6.IsNull() && !data.RecordIpv6.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/ipv6", data.getPath())) + } if !data.RecordIpv6Destination.IsNull() && !data.RecordIpv6Destination.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/ipv6/destination", data.getPath())) } @@ -1151,6 +1241,9 @@ func (data *FlowMonitorMap) getEmptyLeafsDelete(ctx context.Context) []string { if !data.RecordIpv6Gtp.IsNull() && !data.RecordIpv6Gtp.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/ipv6/gtp", data.getPath())) } + if !data.RecordMpls.IsNull() && !data.RecordMpls.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/mpls", data.getPath())) + } if !data.RecordMplsIpv4Fields.IsNull() && !data.RecordMplsIpv4Fields.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/record/mpls/ipv4-fields", data.getPath())) } @@ -1181,6 +1274,9 @@ func (data *FlowMonitorMap) getEmptyLeafsDelete(ctx context.Context) []string { if !data.CacheImmediate.IsNull() && !data.CacheImmediate.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/cache/immediate", data.getPath())) } + if !data.SflowOptions.IsNull() && !data.SflowOptions.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/sflow/options", data.getPath())) + } if !data.SflowOptionsExtendedRouter.IsNull() && !data.SflowOptionsExtendedRouter.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/sflow/options/extended-router", data.getPath())) } @@ -1220,6 +1316,9 @@ func (data *FlowMonitorMap) getDeletePaths(ctx context.Context) []string { if !data.OptionOutbundlemember.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/option/outbundlemember", data.getPath())) } + if !data.RecordIpv4.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/record/ipv4", data.getPath())) + } if !data.RecordIpv4Destination.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/record/ipv4/destination", data.getPath())) } @@ -1268,6 +1367,9 @@ func (data *FlowMonitorMap) getDeletePaths(ctx context.Context) []string { if !data.RecordIpv4Gtp.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/record/ipv4/gtp", data.getPath())) } + if !data.RecordIpv6.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/record/ipv6", data.getPath())) + } if !data.RecordIpv6Destination.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/record/ipv6/destination", data.getPath())) } @@ -1277,6 +1379,9 @@ func (data *FlowMonitorMap) getDeletePaths(ctx context.Context) []string { if !data.RecordIpv6Gtp.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/record/ipv6/gtp", data.getPath())) } + if !data.RecordMpls.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/record/mpls", data.getPath())) + } if !data.RecordMplsIpv4Fields.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/record/mpls/ipv4-fields", data.getPath())) } @@ -1328,6 +1433,9 @@ func (data *FlowMonitorMap) getDeletePaths(ctx context.Context) []string { if !data.HwCacheTimeoutInactive.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/hw-cache/timeout/inactive", data.getPath())) } + if !data.SflowOptions.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/sflow/options", data.getPath())) + } if !data.SflowOptionsExtendedRouter.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/sflow/options/extended-router", data.getPath())) } diff --git a/internal/provider/resource_iosxr_flow_monitor_map.go b/internal/provider/resource_iosxr_flow_monitor_map.go index 504a4d92..905b0dc5 100644 --- a/internal/provider/resource_iosxr_flow_monitor_map.go +++ b/internal/provider/resource_iosxr_flow_monitor_map.go @@ -110,6 +110,10 @@ func (r *FlowMonitorMapResource) Schema(ctx context.Context, req resource.Schema MarkdownDescription: helpers.NewAttributeDescription("export output physical interfaces of bundle interface").String, Optional: true, }, + "record_ipv4": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("IPv4 raw record format").String, + Optional: true, + }, "record_ipv4_destination": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("IPv4 Destination Based NetFlow Accounting").String, Optional: true, @@ -174,6 +178,10 @@ func (r *FlowMonitorMapResource) Schema(ctx context.Context, req resource.Schema MarkdownDescription: helpers.NewAttributeDescription("IPV4 gtp record format").String, Optional: true, }, + "record_ipv6": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("IPv6 raw record format").String, + Optional: true, + }, "record_ipv6_destination": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("IPv6 Destination Based NetFlow Accounting").String, Optional: true, @@ -186,6 +194,10 @@ func (r *FlowMonitorMapResource) Schema(ctx context.Context, req resource.Schema MarkdownDescription: helpers.NewAttributeDescription("IPV6 gtp record format").String, Optional: true, }, + "record_mpls": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("MPLS record format").String, + Optional: true, + }, "record_mpls_ipv4_fields": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("MPLS with IPv4 fields format").String, Optional: true, @@ -275,6 +287,10 @@ func (r *FlowMonitorMapResource) Schema(ctx context.Context, req resource.Schema int64validator.Between(50, 1800), }, }, + "sflow_options": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("submode to configure sFlow related options").String, + Optional: true, + }, "sflow_options_extended_router": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Enable extended-router flow data type").String, Optional: true, diff --git a/internal/provider/resource_iosxr_flow_monitor_map_test.go b/internal/provider/resource_iosxr_flow_monitor_map_test.go index 18f038e6..ec03d6ab 100644 --- a/internal/provider/resource_iosxr_flow_monitor_map_test.go +++ b/internal/provider/resource_iosxr_flow_monitor_map_test.go @@ -37,6 +37,7 @@ func TestAccIosxrFlowMonitorMap(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "option_filtered", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "option_bgpattr", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "option_outbundlemember", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv4", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv4_destination", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv4_destination_tos", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv4_as", "true")) @@ -53,9 +54,11 @@ func TestAccIosxrFlowMonitorMap(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv4_bgp_nexthop_tos", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv4_peer_as", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv4_gtp", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv6", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv6_destination", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv6_peer_as", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_ipv6_gtp", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_mpls", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_mpls_ipv4_fields", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_mpls_ipv6_fields", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "record_mpls_ipv4_ipv6_fields", "true")) @@ -73,6 +76,7 @@ func TestAccIosxrFlowMonitorMap(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "cache_permanent", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "cache_immediate", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "hw_cache_timeout_inactive", "50")) + checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "sflow_options", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "sflow_options_extended_router", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "sflow_options_extended_gateway", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxr_flow_monitor_map.test", "sflow_options_extended_ipv4_tunnel_egress", "true")) @@ -120,6 +124,7 @@ func testAccIosxrFlowMonitorMapConfig_all() string { config += ` option_filtered = true` + "\n" config += ` option_bgpattr = true` + "\n" config += ` option_outbundlemember = true` + "\n" + config += ` record_ipv4 = true` + "\n" config += ` record_ipv4_destination = true` + "\n" config += ` record_ipv4_destination_tos = true` + "\n" config += ` record_ipv4_as = true` + "\n" @@ -136,9 +141,11 @@ func testAccIosxrFlowMonitorMapConfig_all() string { config += ` record_ipv4_bgp_nexthop_tos = true` + "\n" config += ` record_ipv4_peer_as = true` + "\n" config += ` record_ipv4_gtp = true` + "\n" + config += ` record_ipv6 = true` + "\n" config += ` record_ipv6_destination = true` + "\n" config += ` record_ipv6_peer_as = true` + "\n" config += ` record_ipv6_gtp = true` + "\n" + config += ` record_mpls = true` + "\n" config += ` record_mpls_ipv4_fields = true` + "\n" config += ` record_mpls_ipv6_fields = true` + "\n" config += ` record_mpls_ipv4_ipv6_fields = true` + "\n" @@ -156,6 +163,7 @@ func testAccIosxrFlowMonitorMapConfig_all() string { config += ` cache_permanent = true` + "\n" config += ` cache_immediate = true` + "\n" config += ` hw_cache_timeout_inactive = 50` + "\n" + config += ` sflow_options = true` + "\n" config += ` sflow_options_extended_router = true` + "\n" config += ` sflow_options_extended_gateway = true` + "\n" config += ` sflow_options_extended_ipv4_tunnel_egress = true` + "\n" diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index ea63c084..70db9202 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -7,6 +7,10 @@ description: |- # Changelog +## 0.2.4 (unreleased) + +- Add `record_ipv4`, `record_ipv6`, `record_mpls` and `sflow_options` attributes to `iosxr_flow_monitor_map` resource and data source + ## 0.2.3 - Add `timers_bgp_minimum_acceptable_holdtime` attribute to `iosxr_router_bgp` resource and data source