diff --git a/docs/data-sources/flow_exporter.md b/docs/data-sources/flow_exporter.md index fd0191109..c91154dd2 100644 --- a/docs/data-sources/flow_exporter.md +++ b/docs/data-sources/flow_exporter.md @@ -40,6 +40,15 @@ data "iosxe_flow_exporter" "example" { - `option_interface_table_timeout` (Number) Option resend time - `option_sampler_table` (Boolean) Export Sampler Option - `option_vrf_table_timeout` (Number) Option resend time +- `source_five_gigabit_ethernet` (String) Five GigabitEthernet +- `source_forty_gigabit_ethernet` (String) Forty GigabitEthernet +- `source_gigabit_ethernet` (String) GigabitEthernet IEEE 802.3z +- `source_hundred_gigabit_ethernet` (String) Hundred GigabitEthernet - `source_loopback` (Number) Loopback interface +- `source_port_channel` (Number) Ethernet Channel of interfaces +- `source_ten_gigabit_ethernet` (String) Ten Gigabit Ethernet +- `source_twenty_five_gigabit_ethernet` (String) Twenty Five GigabitEthernet +- `source_two_gigabit_ethernet` (String) Two GigabitEthernet +- `source_vlan` (Number) Iosxr Vlans - `template_data_timeout` (Number) Resend data based on a timeout - `transport_udp` (Number) UDP transport protocol diff --git a/docs/data-sources/flow_record.md b/docs/data-sources/flow_record.md index 2e215d7fb..607c01b45 100644 --- a/docs/data-sources/flow_record.md +++ b/docs/data-sources/flow_record.md @@ -51,6 +51,11 @@ data "iosxe_flow_record" "example" { - `match_connection_server_ipv4_address` (Boolean) IPv4 address of the flow responder - `match_connection_server_ipv6_address` (Boolean) IPv6 address of the flow responder - `match_connection_server_transport_port` (Boolean) Transport port of the flow responder +- `match_datalink_destination_vlan_id` (Boolean) Match destination VLAN ID, available on router platforms (C8K, CSR1K) +- `match_datalink_mac_destination_address_input` (Boolean) Destination MAC address from packet at input +- `match_datalink_mac_source_address_input` (Boolean) Source MAC address from packet at input +- `match_datalink_source_vlan_id` (Boolean) Match source VLAN ID, available on router platforms (C8K, CSR1K) +- `match_datalink_vlan` (String) Match VLAN input/output, available on switch platforms (C9K) - `match_flow_direction` (Boolean) Direction the flow was monitored in - `match_flow_observation_point` (Boolean) Observation point ID - `match_interface_input` (Boolean) The input interface @@ -58,6 +63,7 @@ data "iosxe_flow_record" "example" { - `match_ipv4_protocol` (Boolean) IPv4 protocol - `match_ipv4_source_address` (Boolean) IPv4 source address - `match_ipv4_tos` (Boolean) IPv4 type of service +- `match_ipv4_ttl` (Boolean) IPv4 TTL - `match_ipv4_version` (Boolean) IP version from IPv4 header - `match_ipv6_destination_address` (Boolean) IPv6 destination address - `match_ipv6_protocol` (Boolean) IPv6 payload protocol diff --git a/docs/resources/flow_exporter.md b/docs/resources/flow_exporter.md index 71fc5eace..bc17e33b6 100644 --- a/docs/resources/flow_exporter.md +++ b/docs/resources/flow_exporter.md @@ -48,8 +48,19 @@ resource "iosxe_flow_exporter" "example" { - `option_sampler_table` (Boolean) Export Sampler Option - `option_vrf_table_timeout` (Number) Option resend time - Range: `1`-`86400` +- `source_five_gigabit_ethernet` (String) Five GigabitEthernet +- `source_forty_gigabit_ethernet` (String) Forty GigabitEthernet +- `source_gigabit_ethernet` (String) GigabitEthernet IEEE 802.3z +- `source_hundred_gigabit_ethernet` (String) Hundred GigabitEthernet - `source_loopback` (Number) Loopback interface - Range: `0`-`2147483647` +- `source_port_channel` (Number) Ethernet Channel of interfaces + - Range: `0`-`4294967295` +- `source_ten_gigabit_ethernet` (String) Ten Gigabit Ethernet +- `source_twenty_five_gigabit_ethernet` (String) Twenty Five GigabitEthernet +- `source_two_gigabit_ethernet` (String) Two GigabitEthernet +- `source_vlan` (Number) Iosxr Vlans + - Range: `0`-`65535` - `template_data_timeout` (Number) Resend data based on a timeout - Range: `1`-`86400` - `transport_udp` (Number) UDP transport protocol diff --git a/docs/resources/flow_record.md b/docs/resources/flow_record.md index 65cb43d73..41cc235cd 100644 --- a/docs/resources/flow_record.md +++ b/docs/resources/flow_record.md @@ -14,22 +14,25 @@ This resource can manage the Flow Record configuration. ```terraform resource "iosxe_flow_record" "example" { - name = "FNF1" - description = "My flow record" - match_ipv4_source_address = true - match_ipv4_destination_address = true - match_ipv4_protocol = true - match_ipv4_tos = true - match_transport_source_port = true - match_transport_destination_port = true - match_interface_input = true - match_flow_direction = true - collect_interface_output = true - collect_counter_bytes_long = true - collect_counter_packets_long = true - collect_transport_tcp_flags = true - collect_timestamp_absolute_first = true - collect_timestamp_absolute_last = true + name = "FNF1" + description = "My flow record" + match_ipv4_source_address = true + match_ipv4_destination_address = true + match_ipv4_protocol = true + match_ipv4_tos = true + match_transport_source_port = true + match_transport_destination_port = true + match_interface_input = true + match_flow_direction = true + collect_interface_output = true + collect_counter_bytes_long = true + collect_counter_packets_long = true + collect_transport_tcp_flags = true + collect_timestamp_absolute_first = true + collect_timestamp_absolute_last = true + match_datalink_mac_source_address_input = true + match_datalink_mac_destination_address_input = true + match_ipv4_ttl = true } ``` @@ -64,6 +67,12 @@ resource "iosxe_flow_record" "example" { - `match_connection_server_ipv4_address` (Boolean) IPv4 address of the flow responder - `match_connection_server_ipv6_address` (Boolean) IPv6 address of the flow responder - `match_connection_server_transport_port` (Boolean) Transport port of the flow responder +- `match_datalink_destination_vlan_id` (Boolean) Match destination VLAN ID, available on router platforms (C8K, CSR1K) +- `match_datalink_mac_destination_address_input` (Boolean) Destination MAC address from packet at input +- `match_datalink_mac_source_address_input` (Boolean) Source MAC address from packet at input +- `match_datalink_source_vlan_id` (Boolean) Match source VLAN ID, available on router platforms (C8K, CSR1K) +- `match_datalink_vlan` (String) Match VLAN input/output, available on switch platforms (C9K) + - Choices: `input`, `output` - `match_flow_direction` (Boolean) Direction the flow was monitored in - `match_flow_observation_point` (Boolean) Observation point ID - `match_interface_input` (Boolean) The input interface @@ -71,6 +80,7 @@ resource "iosxe_flow_record" "example" { - `match_ipv4_protocol` (Boolean) IPv4 protocol - `match_ipv4_source_address` (Boolean) IPv4 source address - `match_ipv4_tos` (Boolean) IPv4 type of service +- `match_ipv4_ttl` (Boolean) IPv4 TTL - `match_ipv4_version` (Boolean) IP version from IPv4 header - `match_ipv6_destination_address` (Boolean) IPv6 destination address - `match_ipv6_protocol` (Boolean) IPv6 payload protocol diff --git a/examples/resources/iosxe_flow_record/resource.tf b/examples/resources/iosxe_flow_record/resource.tf index 68e5ea318..a8d083190 100644 --- a/examples/resources/iosxe_flow_record/resource.tf +++ b/examples/resources/iosxe_flow_record/resource.tf @@ -1,18 +1,21 @@ resource "iosxe_flow_record" "example" { - name = "FNF1" - description = "My flow record" - match_ipv4_source_address = true - match_ipv4_destination_address = true - match_ipv4_protocol = true - match_ipv4_tos = true - match_transport_source_port = true - match_transport_destination_port = true - match_interface_input = true - match_flow_direction = true - collect_interface_output = true - collect_counter_bytes_long = true - collect_counter_packets_long = true - collect_transport_tcp_flags = true - collect_timestamp_absolute_first = true - collect_timestamp_absolute_last = true + name = "FNF1" + description = "My flow record" + match_ipv4_source_address = true + match_ipv4_destination_address = true + match_ipv4_protocol = true + match_ipv4_tos = true + match_transport_source_port = true + match_transport_destination_port = true + match_interface_input = true + match_flow_direction = true + collect_interface_output = true + collect_counter_bytes_long = true + collect_counter_packets_long = true + collect_transport_tcp_flags = true + collect_timestamp_absolute_first = true + collect_timestamp_absolute_last = true + match_datalink_mac_source_address_input = true + match_datalink_mac_destination_address_input = true + match_ipv4_ttl = true } diff --git a/gen/definitions/flow_exporter.yaml b/gen/definitions/flow_exporter.yaml index 9aff790e0..99bc45a6c 100644 --- a/gen/definitions/flow_exporter.yaml +++ b/gen/definitions/flow_exporter.yaml @@ -15,6 +15,51 @@ attributes: xpath: source/Loopback tf_name: source_loopback example: 123 + - yang_name: source/interface-choice/GigabitEthernet/GigabitEthernet + xpath: source/GigabitEthernet + tf_name: source_gigabit_ethernet + exclude_test: true + example: 0/0/1 + - yang_name: source/interface-choice/TwoGigabitEthernet/TwoGigabitEthernet + xpath: source/TwoGigabitEthernet + tf_name: source_two_gigabit_ethernet + exclude_test: true + example: 0/0/1 + - yang_name: source/interface-choice/FiveGigabitEthernet/FiveGigabitEthernet + xpath: source/FiveGigabitEthernet + tf_name: source_five_gigabit_ethernet + exclude_test: true + example: 0/0/1 + - yang_name: source/interface-choice/TenGigabitEthernet/TenGigabitEthernet + xpath: source/TenGigabitEthernet + tf_name: source_ten_gigabit_ethernet + exclude_test: true + example: 0/0/1 + - yang_name: source/interface-choice/TwentyFiveGigE/TwentyFiveGigE + xpath: source/TwentyFiveGigE + tf_name: source_twenty_five_gigabit_ethernet + exclude_test: true + example: 0/0/1 + - yang_name: source/interface-choice/FortyGigabitEthernet/FortyGigabitEthernet + xpath: source/FortyGigabitEthernet + tf_name: source_forty_gigabit_ethernet + exclude_test: true + example: 0/0/1 + - yang_name: source/interface-choice/HundredGigE/HundredGigE + xpath: source/HundredGigE + tf_name: source_hundred_gigabit_ethernet + exclude_test: true + example: 0/0/1 + - yang_name: source/interface-choice/Vlan/Vlan + xpath: source/Vlan + tf_name: source_vlan + exclude_test: true + example: 100 + - yang_name: source/interface-choice/Port-channel/Port-channel + xpath: source/Port-channel + tf_name: source_port_channel + exclude_test: true + example: 1 - yang_name: transport/udp example: 655 - yang_name: template/data/timeout diff --git a/gen/definitions/flow_record.yaml b/gen/definitions/flow_record.yaml index 8a6f581b2..38c7ad393 100644 --- a/gen/definitions/flow_record.yaml +++ b/gen/definitions/flow_record.yaml @@ -85,6 +85,25 @@ attributes: - yang_name: collect/connection/server/counter/packets/long example: true exclude_test: true + - yang_name: match/datalink/mac/source/address/input + example: true + - yang_name: match/datalink/mac/destination/address/input + example: true + - yang_name: match/datalink/vlan + description: Match VLAN input/output, available on switch platforms (C9K) + example: input + test_tags: [C9000V] + - yang_name: match/datalink/source-vlan-id + description: Match source VLAN ID, available on router platforms (C8K, CSR1K) + example: true + test_tags: [C8000V] + - yang_name: match/datalink/destination-vlan-id + description: Match destination VLAN ID, available on router platforms (C8K, CSR1K) + example: true + test_tags: [C8000V] + exclude_test: true + - yang_name: match/ipv4/ttl + example: true - yang_name: collect/datalink/mac/source/address/input example: true exclude_test: true diff --git a/internal/provider/data_source_iosxe_flow_exporter.go b/internal/provider/data_source_iosxe_flow_exporter.go index 71a8ca327..fcce41fd5 100644 --- a/internal/provider/data_source_iosxe_flow_exporter.go +++ b/internal/provider/data_source_iosxe_flow_exporter.go @@ -83,6 +83,42 @@ func (d *FlowExporterDataSource) Schema(ctx context.Context, req datasource.Sche MarkdownDescription: "Loopback interface", Computed: true, }, + "source_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: "GigabitEthernet IEEE 802.3z", + Computed: true, + }, + "source_two_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: "Two GigabitEthernet ", + Computed: true, + }, + "source_five_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: "Five GigabitEthernet ", + Computed: true, + }, + "source_ten_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: "Ten Gigabit Ethernet", + Computed: true, + }, + "source_twenty_five_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: "Twenty Five GigabitEthernet ", + Computed: true, + }, + "source_forty_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: "Forty GigabitEthernet ", + Computed: true, + }, + "source_hundred_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: "Hundred GigabitEthernet", + Computed: true, + }, + "source_vlan": schema.Int64Attribute{ + MarkdownDescription: "Iosxr Vlans", + Computed: true, + }, + "source_port_channel": schema.Int64Attribute{ + MarkdownDescription: "Ethernet Channel of interfaces", + Computed: true, + }, "transport_udp": schema.Int64Attribute{ MarkdownDescription: "UDP transport protocol", Computed: true, diff --git a/internal/provider/data_source_iosxe_flow_record.go b/internal/provider/data_source_iosxe_flow_record.go index bd9f7dd8a..45e5e8fa3 100644 --- a/internal/provider/data_source_iosxe_flow_record.go +++ b/internal/provider/data_source_iosxe_flow_record.go @@ -195,6 +195,30 @@ func (d *FlowRecordDataSource) Schema(ctx context.Context, req datasource.Schema MarkdownDescription: "64 bits counter", Computed: true, }, + "match_datalink_mac_source_address_input": schema.BoolAttribute{ + MarkdownDescription: "Source MAC address from packet at input", + Computed: true, + }, + "match_datalink_mac_destination_address_input": schema.BoolAttribute{ + MarkdownDescription: "Destination MAC address from packet at input", + Computed: true, + }, + "match_datalink_vlan": schema.StringAttribute{ + MarkdownDescription: "Match VLAN input/output, available on switch platforms (C9K)", + Computed: true, + }, + "match_datalink_source_vlan_id": schema.BoolAttribute{ + MarkdownDescription: "Match source VLAN ID, available on router platforms (C8K, CSR1K)", + Computed: true, + }, + "match_datalink_destination_vlan_id": schema.BoolAttribute{ + MarkdownDescription: "Match destination VLAN ID, available on router platforms (C8K, CSR1K)", + Computed: true, + }, + "match_ipv4_ttl": schema.BoolAttribute{ + MarkdownDescription: "IPv4 TTL", + Computed: true, + }, "collect_datalink_mac_source_address_input": schema.BoolAttribute{ MarkdownDescription: "Source MAC address from packet at input", Computed: true, diff --git a/internal/provider/data_source_iosxe_flow_record_test.go b/internal/provider/data_source_iosxe_flow_record_test.go index f835fca6b..f904f5208 100644 --- a/internal/provider/data_source_iosxe_flow_record_test.go +++ b/internal/provider/data_source_iosxe_flow_record_test.go @@ -21,6 +21,7 @@ package provider // Section below is generated&owned by "gen/generator.go". //template:begin imports import ( + "os" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -47,6 +48,15 @@ func TestAccDataSourceIosxeFlowRecord(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "collect_transport_tcp_flags", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "collect_timestamp_absolute_first", "true")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "collect_timestamp_absolute_last", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "match_datalink_mac_source_address_input", "true")) + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "match_datalink_mac_destination_address_input", "true")) + if os.Getenv("C9000V") != "" { + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "match_datalink_vlan", "input")) + } + if os.Getenv("C8000V") != "" { + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "match_datalink_source_vlan_id", "true")) + } + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_flow_record.test", "match_ipv4_ttl", "true")) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, @@ -85,6 +95,15 @@ func testAccDataSourceIosxeFlowRecordConfig() string { config += ` collect_transport_tcp_flags = true` + "\n" config += ` collect_timestamp_absolute_first = true` + "\n" config += ` collect_timestamp_absolute_last = true` + "\n" + config += ` match_datalink_mac_source_address_input = true` + "\n" + config += ` match_datalink_mac_destination_address_input = true` + "\n" + if os.Getenv("C9000V") != "" { + config += ` match_datalink_vlan = "input"` + "\n" + } + if os.Getenv("C8000V") != "" { + config += ` match_datalink_source_vlan_id = true` + "\n" + } + config += ` match_ipv4_ttl = true` + "\n" config += `}` + "\n" config += ` diff --git a/internal/provider/model_iosxe_flow_exporter.go b/internal/provider/model_iosxe_flow_exporter.go index 0d458f702..981fe311c 100644 --- a/internal/provider/model_iosxe_flow_exporter.go +++ b/internal/provider/model_iosxe_flow_exporter.go @@ -44,6 +44,15 @@ type FlowExporter struct { Description types.String `tfsdk:"description"` DestinationIp types.String `tfsdk:"destination_ip"` SourceLoopback types.Int64 `tfsdk:"source_loopback"` + SourceGigabitEthernet types.String `tfsdk:"source_gigabit_ethernet"` + SourceTwoGigabitEthernet types.String `tfsdk:"source_two_gigabit_ethernet"` + SourceFiveGigabitEthernet types.String `tfsdk:"source_five_gigabit_ethernet"` + SourceTenGigabitEthernet types.String `tfsdk:"source_ten_gigabit_ethernet"` + SourceTwentyFiveGigabitEthernet types.String `tfsdk:"source_twenty_five_gigabit_ethernet"` + SourceFortyGigabitEthernet types.String `tfsdk:"source_forty_gigabit_ethernet"` + SourceHundredGigabitEthernet types.String `tfsdk:"source_hundred_gigabit_ethernet"` + SourceVlan types.Int64 `tfsdk:"source_vlan"` + SourcePortChannel types.Int64 `tfsdk:"source_port_channel"` TransportUdp types.Int64 `tfsdk:"transport_udp"` TemplateDataTimeout types.Int64 `tfsdk:"template_data_timeout"` ExportProtocol types.String `tfsdk:"export_protocol"` @@ -61,6 +70,15 @@ type FlowExporterData struct { Description types.String `tfsdk:"description"` DestinationIp types.String `tfsdk:"destination_ip"` SourceLoopback types.Int64 `tfsdk:"source_loopback"` + SourceGigabitEthernet types.String `tfsdk:"source_gigabit_ethernet"` + SourceTwoGigabitEthernet types.String `tfsdk:"source_two_gigabit_ethernet"` + SourceFiveGigabitEthernet types.String `tfsdk:"source_five_gigabit_ethernet"` + SourceTenGigabitEthernet types.String `tfsdk:"source_ten_gigabit_ethernet"` + SourceTwentyFiveGigabitEthernet types.String `tfsdk:"source_twenty_five_gigabit_ethernet"` + SourceFortyGigabitEthernet types.String `tfsdk:"source_forty_gigabit_ethernet"` + SourceHundredGigabitEthernet types.String `tfsdk:"source_hundred_gigabit_ethernet"` + SourceVlan types.Int64 `tfsdk:"source_vlan"` + SourcePortChannel types.Int64 `tfsdk:"source_port_channel"` TransportUdp types.Int64 `tfsdk:"transport_udp"` TemplateDataTimeout types.Int64 `tfsdk:"template_data_timeout"` ExportProtocol types.String `tfsdk:"export_protocol"` @@ -112,6 +130,33 @@ func (data FlowExporter) toBody(ctx context.Context) string { if !data.SourceLoopback.IsNull() && !data.SourceLoopback.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.Loopback", strconv.FormatInt(data.SourceLoopback.ValueInt64(), 10)) } + if !data.SourceGigabitEthernet.IsNull() && !data.SourceGigabitEthernet.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.GigabitEthernet", data.SourceGigabitEthernet.ValueString()) + } + if !data.SourceTwoGigabitEthernet.IsNull() && !data.SourceTwoGigabitEthernet.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.TwoGigabitEthernet", data.SourceTwoGigabitEthernet.ValueString()) + } + if !data.SourceFiveGigabitEthernet.IsNull() && !data.SourceFiveGigabitEthernet.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.FiveGigabitEthernet", data.SourceFiveGigabitEthernet.ValueString()) + } + if !data.SourceTenGigabitEthernet.IsNull() && !data.SourceTenGigabitEthernet.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.TenGigabitEthernet", data.SourceTenGigabitEthernet.ValueString()) + } + if !data.SourceTwentyFiveGigabitEthernet.IsNull() && !data.SourceTwentyFiveGigabitEthernet.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.TwentyFiveGigE", data.SourceTwentyFiveGigabitEthernet.ValueString()) + } + if !data.SourceFortyGigabitEthernet.IsNull() && !data.SourceFortyGigabitEthernet.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.FortyGigabitEthernet", data.SourceFortyGigabitEthernet.ValueString()) + } + if !data.SourceHundredGigabitEthernet.IsNull() && !data.SourceHundredGigabitEthernet.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.HundredGigE", data.SourceHundredGigabitEthernet.ValueString()) + } + if !data.SourceVlan.IsNull() && !data.SourceVlan.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.Vlan", strconv.FormatInt(data.SourceVlan.ValueInt64(), 10)) + } + if !data.SourcePortChannel.IsNull() && !data.SourcePortChannel.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"source.Port-channel", strconv.FormatInt(data.SourcePortChannel.ValueInt64(), 10)) + } if !data.TransportUdp.IsNull() && !data.TransportUdp.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"transport.udp", strconv.FormatInt(data.TransportUdp.ValueInt64(), 10)) } @@ -170,6 +215,51 @@ func (data *FlowExporter) updateFromBody(ctx context.Context, res gjson.Result) } else { data.SourceLoopback = types.Int64Null() } + if value := res.Get(prefix + "source.GigabitEthernet"); value.Exists() && !data.SourceGigabitEthernet.IsNull() { + data.SourceGigabitEthernet = types.StringValue(value.String()) + } else { + data.SourceGigabitEthernet = types.StringNull() + } + if value := res.Get(prefix + "source.TwoGigabitEthernet"); value.Exists() && !data.SourceTwoGigabitEthernet.IsNull() { + data.SourceTwoGigabitEthernet = types.StringValue(value.String()) + } else { + data.SourceTwoGigabitEthernet = types.StringNull() + } + if value := res.Get(prefix + "source.FiveGigabitEthernet"); value.Exists() && !data.SourceFiveGigabitEthernet.IsNull() { + data.SourceFiveGigabitEthernet = types.StringValue(value.String()) + } else { + data.SourceFiveGigabitEthernet = types.StringNull() + } + if value := res.Get(prefix + "source.TenGigabitEthernet"); value.Exists() && !data.SourceTenGigabitEthernet.IsNull() { + data.SourceTenGigabitEthernet = types.StringValue(value.String()) + } else { + data.SourceTenGigabitEthernet = types.StringNull() + } + if value := res.Get(prefix + "source.TwentyFiveGigE"); value.Exists() && !data.SourceTwentyFiveGigabitEthernet.IsNull() { + data.SourceTwentyFiveGigabitEthernet = types.StringValue(value.String()) + } else { + data.SourceTwentyFiveGigabitEthernet = types.StringNull() + } + if value := res.Get(prefix + "source.FortyGigabitEthernet"); value.Exists() && !data.SourceFortyGigabitEthernet.IsNull() { + data.SourceFortyGigabitEthernet = types.StringValue(value.String()) + } else { + data.SourceFortyGigabitEthernet = types.StringNull() + } + if value := res.Get(prefix + "source.HundredGigE"); value.Exists() && !data.SourceHundredGigabitEthernet.IsNull() { + data.SourceHundredGigabitEthernet = types.StringValue(value.String()) + } else { + data.SourceHundredGigabitEthernet = types.StringNull() + } + if value := res.Get(prefix + "source.Vlan"); value.Exists() && !data.SourceVlan.IsNull() { + data.SourceVlan = types.Int64Value(value.Int()) + } else { + data.SourceVlan = types.Int64Null() + } + if value := res.Get(prefix + "source.Port-channel"); value.Exists() && !data.SourcePortChannel.IsNull() { + data.SourcePortChannel = types.Int64Value(value.Int()) + } else { + data.SourcePortChannel = types.Int64Null() + } if value := res.Get(prefix + "transport.udp"); value.Exists() && !data.TransportUdp.IsNull() { data.TransportUdp = types.Int64Value(value.Int()) } else { @@ -234,6 +324,33 @@ func (data *FlowExporter) fromBody(ctx context.Context, res gjson.Result) { if value := res.Get(prefix + "source.Loopback"); value.Exists() { data.SourceLoopback = types.Int64Value(value.Int()) } + if value := res.Get(prefix + "source.GigabitEthernet"); value.Exists() { + data.SourceGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.TwoGigabitEthernet"); value.Exists() { + data.SourceTwoGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.FiveGigabitEthernet"); value.Exists() { + data.SourceFiveGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.TenGigabitEthernet"); value.Exists() { + data.SourceTenGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.TwentyFiveGigE"); value.Exists() { + data.SourceTwentyFiveGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.FortyGigabitEthernet"); value.Exists() { + data.SourceFortyGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.HundredGigE"); value.Exists() { + data.SourceHundredGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.Vlan"); value.Exists() { + data.SourceVlan = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "source.Port-channel"); value.Exists() { + data.SourcePortChannel = types.Int64Value(value.Int()) + } if value := res.Get(prefix + "transport.udp"); value.Exists() { data.TransportUdp = types.Int64Value(value.Int()) } @@ -280,6 +397,33 @@ func (data *FlowExporterData) fromBody(ctx context.Context, res gjson.Result) { if value := res.Get(prefix + "source.Loopback"); value.Exists() { data.SourceLoopback = types.Int64Value(value.Int()) } + if value := res.Get(prefix + "source.GigabitEthernet"); value.Exists() { + data.SourceGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.TwoGigabitEthernet"); value.Exists() { + data.SourceTwoGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.FiveGigabitEthernet"); value.Exists() { + data.SourceFiveGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.TenGigabitEthernet"); value.Exists() { + data.SourceTenGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.TwentyFiveGigE"); value.Exists() { + data.SourceTwentyFiveGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.FortyGigabitEthernet"); value.Exists() { + data.SourceFortyGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.HundredGigE"); value.Exists() { + data.SourceHundredGigabitEthernet = types.StringValue(value.String()) + } + if value := res.Get(prefix + "source.Vlan"); value.Exists() { + data.SourceVlan = types.Int64Value(value.Int()) + } + if value := res.Get(prefix + "source.Port-channel"); value.Exists() { + data.SourcePortChannel = types.Int64Value(value.Int()) + } if value := res.Get(prefix + "transport.udp"); value.Exists() { data.TransportUdp = types.Int64Value(value.Int()) } @@ -338,6 +482,33 @@ func (data *FlowExporter) getDeletedItems(ctx context.Context, state FlowExporte if !state.TransportUdp.IsNull() && data.TransportUdp.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/transport/udp", state.getPath())) } + if !state.SourcePortChannel.IsNull() && data.SourcePortChannel.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/Port-channel", state.getPath())) + } + if !state.SourceVlan.IsNull() && data.SourceVlan.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/Vlan", state.getPath())) + } + if !state.SourceHundredGigabitEthernet.IsNull() && data.SourceHundredGigabitEthernet.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/HundredGigE", state.getPath())) + } + if !state.SourceFortyGigabitEthernet.IsNull() && data.SourceFortyGigabitEthernet.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/FortyGigabitEthernet", state.getPath())) + } + if !state.SourceTwentyFiveGigabitEthernet.IsNull() && data.SourceTwentyFiveGigabitEthernet.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/TwentyFiveGigE", state.getPath())) + } + if !state.SourceTenGigabitEthernet.IsNull() && data.SourceTenGigabitEthernet.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/TenGigabitEthernet", state.getPath())) + } + if !state.SourceFiveGigabitEthernet.IsNull() && data.SourceFiveGigabitEthernet.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/FiveGigabitEthernet", state.getPath())) + } + if !state.SourceTwoGigabitEthernet.IsNull() && data.SourceTwoGigabitEthernet.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/TwoGigabitEthernet", state.getPath())) + } + if !state.SourceGigabitEthernet.IsNull() && data.SourceGigabitEthernet.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/source/GigabitEthernet", state.getPath())) + } if !state.SourceLoopback.IsNull() && data.SourceLoopback.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/source/Loopback", state.getPath())) } @@ -394,6 +565,33 @@ func (data *FlowExporter) getDeletePaths(ctx context.Context) []string { if !data.TransportUdp.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/transport/udp", data.getPath())) } + if !data.SourcePortChannel.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/Port-channel", data.getPath())) + } + if !data.SourceVlan.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/Vlan", data.getPath())) + } + if !data.SourceHundredGigabitEthernet.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/HundredGigE", data.getPath())) + } + if !data.SourceFortyGigabitEthernet.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/FortyGigabitEthernet", data.getPath())) + } + if !data.SourceTwentyFiveGigabitEthernet.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/TwentyFiveGigE", data.getPath())) + } + if !data.SourceTenGigabitEthernet.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/TenGigabitEthernet", data.getPath())) + } + if !data.SourceFiveGigabitEthernet.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/FiveGigabitEthernet", data.getPath())) + } + if !data.SourceTwoGigabitEthernet.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/TwoGigabitEthernet", data.getPath())) + } + if !data.SourceGigabitEthernet.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/source/GigabitEthernet", data.getPath())) + } if !data.SourceLoopback.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/source/Loopback", data.getPath())) } diff --git a/internal/provider/model_iosxe_flow_record.go b/internal/provider/model_iosxe_flow_record.go index 1cf9fee74..7da362a8e 100644 --- a/internal/provider/model_iosxe_flow_record.go +++ b/internal/provider/model_iosxe_flow_record.go @@ -71,6 +71,12 @@ type FlowRecord struct { CollectConnectionNewConnections types.Bool `tfsdk:"collect_connection_new_connections"` CollectConnectionServerCounterBytesNetworkLong types.Bool `tfsdk:"collect_connection_server_counter_bytes_network_long"` CollectConnectionServerCounterPacketsLong types.Bool `tfsdk:"collect_connection_server_counter_packets_long"` + MatchDatalinkMacSourceAddressInput types.Bool `tfsdk:"match_datalink_mac_source_address_input"` + MatchDatalinkMacDestinationAddressInput types.Bool `tfsdk:"match_datalink_mac_destination_address_input"` + MatchDatalinkVlan types.String `tfsdk:"match_datalink_vlan"` + MatchDatalinkSourceVlanId types.Bool `tfsdk:"match_datalink_source_vlan_id"` + MatchDatalinkDestinationVlanId types.Bool `tfsdk:"match_datalink_destination_vlan_id"` + MatchIpv4Ttl types.Bool `tfsdk:"match_ipv4_ttl"` CollectDatalinkMacSourceAddressInput types.Bool `tfsdk:"collect_datalink_mac_source_address_input"` CollectFlowDirection types.Bool `tfsdk:"collect_flow_direction"` } @@ -110,6 +116,12 @@ type FlowRecordData struct { CollectConnectionNewConnections types.Bool `tfsdk:"collect_connection_new_connections"` CollectConnectionServerCounterBytesNetworkLong types.Bool `tfsdk:"collect_connection_server_counter_bytes_network_long"` CollectConnectionServerCounterPacketsLong types.Bool `tfsdk:"collect_connection_server_counter_packets_long"` + MatchDatalinkMacSourceAddressInput types.Bool `tfsdk:"match_datalink_mac_source_address_input"` + MatchDatalinkMacDestinationAddressInput types.Bool `tfsdk:"match_datalink_mac_destination_address_input"` + MatchDatalinkVlan types.String `tfsdk:"match_datalink_vlan"` + MatchDatalinkSourceVlanId types.Bool `tfsdk:"match_datalink_source_vlan_id"` + MatchDatalinkDestinationVlanId types.Bool `tfsdk:"match_datalink_destination_vlan_id"` + MatchIpv4Ttl types.Bool `tfsdk:"match_ipv4_ttl"` CollectDatalinkMacSourceAddressInput types.Bool `tfsdk:"collect_datalink_mac_source_address_input"` CollectFlowDirection types.Bool `tfsdk:"collect_flow_direction"` } @@ -299,6 +311,34 @@ func (data FlowRecord) toBody(ctx context.Context) string { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"collect.connection.server.counter.packets.long", map[string]string{}) } } + if !data.MatchDatalinkMacSourceAddressInput.IsNull() && !data.MatchDatalinkMacSourceAddressInput.IsUnknown() { + if data.MatchDatalinkMacSourceAddressInput.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.datalink.mac.source.address.input", map[string]string{}) + } + } + if !data.MatchDatalinkMacDestinationAddressInput.IsNull() && !data.MatchDatalinkMacDestinationAddressInput.IsUnknown() { + if data.MatchDatalinkMacDestinationAddressInput.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.datalink.mac.destination.address.input", map[string]string{}) + } + } + if !data.MatchDatalinkVlan.IsNull() && !data.MatchDatalinkVlan.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.datalink.vlan", data.MatchDatalinkVlan.ValueString()) + } + if !data.MatchDatalinkSourceVlanId.IsNull() && !data.MatchDatalinkSourceVlanId.IsUnknown() { + if data.MatchDatalinkSourceVlanId.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.datalink.source-vlan-id", map[string]string{}) + } + } + if !data.MatchDatalinkDestinationVlanId.IsNull() && !data.MatchDatalinkDestinationVlanId.IsUnknown() { + if data.MatchDatalinkDestinationVlanId.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.datalink.destination-vlan-id", map[string]string{}) + } + } + if !data.MatchIpv4Ttl.IsNull() && !data.MatchIpv4Ttl.IsUnknown() { + if data.MatchIpv4Ttl.ValueBool() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"match.ipv4.ttl", map[string]string{}) + } + } if !data.CollectDatalinkMacSourceAddressInput.IsNull() && !data.CollectDatalinkMacSourceAddressInput.IsUnknown() { if data.CollectDatalinkMacSourceAddressInput.ValueBool() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"collect.datalink.mac.source.address.input", map[string]string{}) @@ -601,6 +641,56 @@ func (data *FlowRecord) updateFromBody(ctx context.Context, res gjson.Result) { } else { data.CollectConnectionServerCounterPacketsLong = types.BoolNull() } + if value := res.Get(prefix + "match.datalink.mac.source.address.input"); !data.MatchDatalinkMacSourceAddressInput.IsNull() { + if value.Exists() { + data.MatchDatalinkMacSourceAddressInput = types.BoolValue(true) + } else { + data.MatchDatalinkMacSourceAddressInput = types.BoolValue(false) + } + } else { + data.MatchDatalinkMacSourceAddressInput = types.BoolNull() + } + if value := res.Get(prefix + "match.datalink.mac.destination.address.input"); !data.MatchDatalinkMacDestinationAddressInput.IsNull() { + if value.Exists() { + data.MatchDatalinkMacDestinationAddressInput = types.BoolValue(true) + } else { + data.MatchDatalinkMacDestinationAddressInput = types.BoolValue(false) + } + } else { + data.MatchDatalinkMacDestinationAddressInput = types.BoolNull() + } + if value := res.Get(prefix + "match.datalink.vlan"); value.Exists() && !data.MatchDatalinkVlan.IsNull() { + data.MatchDatalinkVlan = types.StringValue(value.String()) + } else { + data.MatchDatalinkVlan = types.StringNull() + } + if value := res.Get(prefix + "match.datalink.source-vlan-id"); !data.MatchDatalinkSourceVlanId.IsNull() { + if value.Exists() { + data.MatchDatalinkSourceVlanId = types.BoolValue(true) + } else { + data.MatchDatalinkSourceVlanId = types.BoolValue(false) + } + } else { + data.MatchDatalinkSourceVlanId = types.BoolNull() + } + if value := res.Get(prefix + "match.datalink.destination-vlan-id"); !data.MatchDatalinkDestinationVlanId.IsNull() { + if value.Exists() { + data.MatchDatalinkDestinationVlanId = types.BoolValue(true) + } else { + data.MatchDatalinkDestinationVlanId = types.BoolValue(false) + } + } else { + data.MatchDatalinkDestinationVlanId = types.BoolNull() + } + if value := res.Get(prefix + "match.ipv4.ttl"); !data.MatchIpv4Ttl.IsNull() { + if value.Exists() { + data.MatchIpv4Ttl = types.BoolValue(true) + } else { + data.MatchIpv4Ttl = types.BoolValue(false) + } + } else { + data.MatchIpv4Ttl = types.BoolNull() + } if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); !data.CollectDatalinkMacSourceAddressInput.IsNull() { if value.Exists() { data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true) @@ -783,6 +873,34 @@ func (data *FlowRecord) fromBody(ctx context.Context, res gjson.Result) { } else { data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false) } + if value := res.Get(prefix + "match.datalink.mac.source.address.input"); value.Exists() { + data.MatchDatalinkMacSourceAddressInput = types.BoolValue(true) + } else { + data.MatchDatalinkMacSourceAddressInput = types.BoolValue(false) + } + if value := res.Get(prefix + "match.datalink.mac.destination.address.input"); value.Exists() { + data.MatchDatalinkMacDestinationAddressInput = types.BoolValue(true) + } else { + data.MatchDatalinkMacDestinationAddressInput = types.BoolValue(false) + } + if value := res.Get(prefix + "match.datalink.vlan"); value.Exists() { + data.MatchDatalinkVlan = types.StringValue(value.String()) + } + if value := res.Get(prefix + "match.datalink.source-vlan-id"); value.Exists() { + data.MatchDatalinkSourceVlanId = types.BoolValue(true) + } else { + data.MatchDatalinkSourceVlanId = types.BoolValue(false) + } + if value := res.Get(prefix + "match.datalink.destination-vlan-id"); value.Exists() { + data.MatchDatalinkDestinationVlanId = types.BoolValue(true) + } else { + data.MatchDatalinkDestinationVlanId = types.BoolValue(false) + } + if value := res.Get(prefix + "match.ipv4.ttl"); value.Exists() { + data.MatchIpv4Ttl = types.BoolValue(true) + } else { + data.MatchIpv4Ttl = types.BoolValue(false) + } if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); value.Exists() { data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true) } else { @@ -957,6 +1075,34 @@ func (data *FlowRecordData) fromBody(ctx context.Context, res gjson.Result) { } else { data.CollectConnectionServerCounterPacketsLong = types.BoolValue(false) } + if value := res.Get(prefix + "match.datalink.mac.source.address.input"); value.Exists() { + data.MatchDatalinkMacSourceAddressInput = types.BoolValue(true) + } else { + data.MatchDatalinkMacSourceAddressInput = types.BoolValue(false) + } + if value := res.Get(prefix + "match.datalink.mac.destination.address.input"); value.Exists() { + data.MatchDatalinkMacDestinationAddressInput = types.BoolValue(true) + } else { + data.MatchDatalinkMacDestinationAddressInput = types.BoolValue(false) + } + if value := res.Get(prefix + "match.datalink.vlan"); value.Exists() { + data.MatchDatalinkVlan = types.StringValue(value.String()) + } + if value := res.Get(prefix + "match.datalink.source-vlan-id"); value.Exists() { + data.MatchDatalinkSourceVlanId = types.BoolValue(true) + } else { + data.MatchDatalinkSourceVlanId = types.BoolValue(false) + } + if value := res.Get(prefix + "match.datalink.destination-vlan-id"); value.Exists() { + data.MatchDatalinkDestinationVlanId = types.BoolValue(true) + } else { + data.MatchDatalinkDestinationVlanId = types.BoolValue(false) + } + if value := res.Get(prefix + "match.ipv4.ttl"); value.Exists() { + data.MatchIpv4Ttl = types.BoolValue(true) + } else { + data.MatchIpv4Ttl = types.BoolValue(false) + } if value := res.Get(prefix + "collect.datalink.mac.source.address.input"); value.Exists() { data.CollectDatalinkMacSourceAddressInput = types.BoolValue(true) } else { @@ -981,6 +1127,24 @@ func (data *FlowRecord) getDeletedItems(ctx context.Context, state FlowRecord) [ if !state.CollectDatalinkMacSourceAddressInput.IsNull() && data.CollectDatalinkMacSourceAddressInput.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/collect/datalink/mac/source/address/input", state.getPath())) } + if !state.MatchIpv4Ttl.IsNull() && data.MatchIpv4Ttl.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/ipv4/ttl", state.getPath())) + } + if !state.MatchDatalinkDestinationVlanId.IsNull() && data.MatchDatalinkDestinationVlanId.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/datalink/destination-vlan-id", state.getPath())) + } + if !state.MatchDatalinkSourceVlanId.IsNull() && data.MatchDatalinkSourceVlanId.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/datalink/source-vlan-id", state.getPath())) + } + if !state.MatchDatalinkVlan.IsNull() && data.MatchDatalinkVlan.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/datalink/vlan", state.getPath())) + } + if !state.MatchDatalinkMacDestinationAddressInput.IsNull() && data.MatchDatalinkMacDestinationAddressInput.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/datalink/mac/destination/address/input", state.getPath())) + } + if !state.MatchDatalinkMacSourceAddressInput.IsNull() && data.MatchDatalinkMacSourceAddressInput.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/match/datalink/mac/source/address/input", state.getPath())) + } if !state.CollectConnectionServerCounterPacketsLong.IsNull() && data.CollectConnectionServerCounterPacketsLong.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/collect/connection/server/counter/packets/long", state.getPath())) } @@ -1090,6 +1254,21 @@ func (data *FlowRecord) getEmptyLeafsDelete(ctx context.Context) []string { if !data.CollectDatalinkMacSourceAddressInput.IsNull() && !data.CollectDatalinkMacSourceAddressInput.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/collect/datalink/mac/source/address/input", data.getPath())) } + if !data.MatchIpv4Ttl.IsNull() && !data.MatchIpv4Ttl.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/match/ipv4/ttl", data.getPath())) + } + if !data.MatchDatalinkDestinationVlanId.IsNull() && !data.MatchDatalinkDestinationVlanId.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/match/datalink/destination-vlan-id", data.getPath())) + } + if !data.MatchDatalinkSourceVlanId.IsNull() && !data.MatchDatalinkSourceVlanId.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/match/datalink/source-vlan-id", data.getPath())) + } + if !data.MatchDatalinkMacDestinationAddressInput.IsNull() && !data.MatchDatalinkMacDestinationAddressInput.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/match/datalink/mac/destination/address/input", data.getPath())) + } + if !data.MatchDatalinkMacSourceAddressInput.IsNull() && !data.MatchDatalinkMacSourceAddressInput.ValueBool() { + emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/match/datalink/mac/source/address/input", data.getPath())) + } if !data.CollectConnectionServerCounterPacketsLong.IsNull() && !data.CollectConnectionServerCounterPacketsLong.ValueBool() { emptyLeafsDelete = append(emptyLeafsDelete, fmt.Sprintf("%v/collect/connection/server/counter/packets/long", data.getPath())) } @@ -1196,6 +1375,24 @@ func (data *FlowRecord) getDeletePaths(ctx context.Context) []string { if !data.CollectDatalinkMacSourceAddressInput.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/collect/datalink/mac/source/address/input", data.getPath())) } + if !data.MatchIpv4Ttl.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/match/ipv4/ttl", data.getPath())) + } + if !data.MatchDatalinkDestinationVlanId.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/match/datalink/destination-vlan-id", data.getPath())) + } + if !data.MatchDatalinkSourceVlanId.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/match/datalink/source-vlan-id", data.getPath())) + } + if !data.MatchDatalinkVlan.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/match/datalink/vlan", data.getPath())) + } + if !data.MatchDatalinkMacDestinationAddressInput.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/match/datalink/mac/destination/address/input", data.getPath())) + } + if !data.MatchDatalinkMacSourceAddressInput.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/match/datalink/mac/source/address/input", data.getPath())) + } if !data.CollectConnectionServerCounterPacketsLong.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/collect/connection/server/counter/packets/long", data.getPath())) } diff --git a/internal/provider/resource_iosxe_flow_exporter.go b/internal/provider/resource_iosxe_flow_exporter.go index 2542bb3e6..4696c7c92 100644 --- a/internal/provider/resource_iosxe_flow_exporter.go +++ b/internal/provider/resource_iosxe_flow_exporter.go @@ -111,6 +111,48 @@ func (r *FlowExporterResource) Schema(ctx context.Context, req resource.SchemaRe int64validator.Between(0, 2147483647), }, }, + "source_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("GigabitEthernet IEEE 802.3z").String, + Optional: true, + }, + "source_two_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Two GigabitEthernet ").String, + Optional: true, + }, + "source_five_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Five GigabitEthernet ").String, + Optional: true, + }, + "source_ten_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Ten Gigabit Ethernet").String, + Optional: true, + }, + "source_twenty_five_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Twenty Five GigabitEthernet ").String, + Optional: true, + }, + "source_forty_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Forty GigabitEthernet ").String, + Optional: true, + }, + "source_hundred_gigabit_ethernet": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Hundred GigabitEthernet").String, + Optional: true, + }, + "source_vlan": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Iosxr Vlans").AddIntegerRangeDescription(0, 65535).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(0, 65535), + }, + }, + "source_port_channel": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("Ethernet Channel of interfaces").AddIntegerRangeDescription(0, 4294967295).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(0, 4294967295), + }, + }, "transport_udp": schema.Int64Attribute{ MarkdownDescription: helpers.NewAttributeDescription("UDP transport protocol").AddIntegerRangeDescription(0, 65535).String, Optional: true, diff --git a/internal/provider/resource_iosxe_flow_record.go b/internal/provider/resource_iosxe_flow_record.go index d7d52b7e2..55126b34e 100644 --- a/internal/provider/resource_iosxe_flow_record.go +++ b/internal/provider/resource_iosxe_flow_record.go @@ -219,6 +219,33 @@ func (r *FlowRecordResource) Schema(ctx context.Context, req resource.SchemaRequ MarkdownDescription: helpers.NewAttributeDescription("64 bits counter").String, Optional: true, }, + "match_datalink_mac_source_address_input": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Source MAC address from packet at input").String, + Optional: true, + }, + "match_datalink_mac_destination_address_input": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Destination MAC address from packet at input").String, + Optional: true, + }, + "match_datalink_vlan": schema.StringAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Match VLAN input/output, available on switch platforms (C9K)").AddStringEnumDescription("input", "output").String, + Optional: true, + Validators: []validator.String{ + stringvalidator.OneOf("input", "output"), + }, + }, + "match_datalink_source_vlan_id": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Match source VLAN ID, available on router platforms (C8K, CSR1K)").String, + Optional: true, + }, + "match_datalink_destination_vlan_id": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("Match destination VLAN ID, available on router platforms (C8K, CSR1K)").String, + Optional: true, + }, + "match_ipv4_ttl": schema.BoolAttribute{ + MarkdownDescription: helpers.NewAttributeDescription("IPv4 TTL").String, + Optional: true, + }, "collect_datalink_mac_source_address_input": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("Source MAC address from packet at input").String, Optional: true, diff --git a/internal/provider/resource_iosxe_flow_record_test.go b/internal/provider/resource_iosxe_flow_record_test.go index a543cde52..bb0fc509e 100644 --- a/internal/provider/resource_iosxe_flow_record_test.go +++ b/internal/provider/resource_iosxe_flow_record_test.go @@ -22,6 +22,7 @@ package provider // Section below is generated&owned by "gen/generator.go". //template:begin imports import ( "fmt" + "os" "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -50,6 +51,15 @@ func TestAccIosxeFlowRecord(t *testing.T) { checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "collect_transport_tcp_flags", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "collect_timestamp_absolute_first", "true")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "collect_timestamp_absolute_last", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "match_datalink_mac_source_address_input", "true")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "match_datalink_mac_destination_address_input", "true")) + if os.Getenv("C9000V") != "" { + checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "match_datalink_vlan", "input")) + } + if os.Getenv("C8000V") != "" { + checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "match_datalink_source_vlan_id", "true")) + } + checks = append(checks, resource.TestCheckResourceAttr("iosxe_flow_record.test", "match_ipv4_ttl", "true")) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, @@ -66,7 +76,7 @@ func TestAccIosxeFlowRecord(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateIdFunc: iosxeFlowRecordImportStateIdFunc("iosxe_flow_record.test"), - ImportStateVerifyIgnore: []string{"match_ipv6_source_address", "match_ipv6_destination_address", "match_application_name", "match_flow_observation_point", "match_ipv4_version", "match_ipv6_version", "match_ipv6_protocol", "match_connection_client_ipv4_address", "match_connection_server_ipv4_address", "match_connection_client_ipv6_address", "match_connection_server_ipv6_address", "match_connection_server_transport_port", "collect_connection_initiator", "collect_connection_new_connections", "collect_connection_server_counter_bytes_network_long", "collect_connection_server_counter_packets_long", "collect_datalink_mac_source_address_input", "collect_flow_direction"}, + ImportStateVerifyIgnore: []string{"match_ipv6_source_address", "match_ipv6_destination_address", "match_application_name", "match_flow_observation_point", "match_ipv4_version", "match_ipv6_version", "match_ipv6_protocol", "match_connection_client_ipv4_address", "match_connection_server_ipv4_address", "match_connection_client_ipv6_address", "match_connection_server_ipv6_address", "match_connection_server_transport_port", "collect_connection_initiator", "collect_connection_new_connections", "collect_connection_server_counter_bytes_network_long", "collect_connection_server_counter_packets_long", "match_datalink_source_vlan_id", "match_datalink_destination_vlan_id", "collect_datalink_mac_source_address_input", "collect_flow_direction"}, Check: resource.ComposeTestCheckFunc(checks...), }, }, @@ -122,6 +132,15 @@ func testAccIosxeFlowRecordConfig_all() string { config += ` collect_transport_tcp_flags = true` + "\n" config += ` collect_timestamp_absolute_first = true` + "\n" config += ` collect_timestamp_absolute_last = true` + "\n" + config += ` match_datalink_mac_source_address_input = true` + "\n" + config += ` match_datalink_mac_destination_address_input = true` + "\n" + if os.Getenv("C9000V") != "" { + config += ` match_datalink_vlan = "input"` + "\n" + } + if os.Getenv("C8000V") != "" { + config += ` match_datalink_source_vlan_id = true` + "\n" + } + config += ` match_ipv4_ttl = true` + "\n" config += `}` + "\n" return config }