diff --git a/CHANGELOG.md b/CHANGELOG.md index 63625037..f574972c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.5 (unreleased) + +- Add `bandwidth` attribute to `iosxe_interface_ethernet` resource and data source + ## 0.5.4 - Add `next_hop_self` and `next_hop_self_all` attributes to `iosxe_bgp_ipv4_unicast_vrf_neighbor` resource and data source diff --git a/docs/data-sources/interface_ethernet.md b/docs/data-sources/interface_ethernet.md index dd920e5a..8c6d464d 100644 --- a/docs/data-sources/interface_ethernet.md +++ b/docs/data-sources/interface_ethernet.md @@ -65,6 +65,7 @@ data "iosxe_interface_ethernet" "example" { - `auto_qos_voip_cisco_phone` (Boolean) Trust the QoS marking of Cisco IP Phone - `auto_qos_voip_cisco_softphone` (Boolean) Trust the QoS marking of Cisco IP SoftPhone - `auto_qos_voip_trust` (Boolean) Trust the DSCP/CoS marking +- `bandwidth` (Number) - `bfd_echo` (Boolean) Use echo adjunct as bfd detection mechanism - `bfd_enable` (Boolean) Enable BFD under the interface - `bfd_interval` (Number) diff --git a/docs/guides/changelog.md b/docs/guides/changelog.md index 48b2921f..7ecde398 100644 --- a/docs/guides/changelog.md +++ b/docs/guides/changelog.md @@ -7,6 +7,10 @@ description: |- # Changelog +## 0.5.5 (unreleased) + +- Add `bandwidth` attribute to `iosxe_interface_ethernet` resource and data source + ## 0.5.4 - Add `next_hop_self` and `next_hop_self_all` attributes to `iosxe_bgp_ipv4_unicast_vrf_neighbor` resource and data source diff --git a/docs/resources/interface_ethernet.md b/docs/resources/interface_ethernet.md index e116e636..c1328b28 100644 --- a/docs/resources/interface_ethernet.md +++ b/docs/resources/interface_ethernet.md @@ -16,6 +16,7 @@ This resource can manage the Interface Ethernet configuration. resource "iosxe_interface_ethernet" "example" { type = "GigabitEthernet" name = "3" + bandwidth = 1000000 description = "My Interface Description" shutdown = false ip_proxy_arp = false @@ -109,6 +110,7 @@ resource "iosxe_interface_ethernet" "example" { - `auto_qos_voip_cisco_phone` (Boolean) Trust the QoS marking of Cisco IP Phone - `auto_qos_voip_cisco_softphone` (Boolean) Trust the QoS marking of Cisco IP SoftPhone - `auto_qos_voip_trust` (Boolean) Trust the DSCP/CoS marking +- `bandwidth` (Number) - Range: `1`-`200000000` - `bfd_echo` (Boolean) Use echo adjunct as bfd detection mechanism - `bfd_enable` (Boolean) Enable BFD under the interface - `bfd_interval` (Number) - Range: `50`-`9999` diff --git a/examples/resources/iosxe_interface_ethernet/resource.tf b/examples/resources/iosxe_interface_ethernet/resource.tf index f3b18ae8..9f8fb34f 100644 --- a/examples/resources/iosxe_interface_ethernet/resource.tf +++ b/examples/resources/iosxe_interface_ethernet/resource.tf @@ -1,6 +1,7 @@ resource "iosxe_interface_ethernet" "example" { type = "GigabitEthernet" name = "3" + bandwidth = 1000000 description = "My Interface Description" shutdown = false ip_proxy_arp = false diff --git a/gen/definitions/interface_ethernet.yaml b/gen/definitions/interface_ethernet.yaml index a97dcc06..38ac72dd 100644 --- a/gen/definitions/interface_ethernet.yaml +++ b/gen/definitions/interface_ethernet.yaml @@ -27,6 +27,9 @@ attributes: - yang_name: media-type exclude_test: true example: sfp + - yang_name: bandwidth/kilobits + tf_name: bandwidth + example: 1000000 - yang_name: switchport-conf/switchport tf_name: switchport exclude_test: true diff --git a/internal/provider/data_source_iosxe_interface_ethernet.go b/internal/provider/data_source_iosxe_interface_ethernet.go index d2f9c04f..74d435b9 100644 --- a/internal/provider/data_source_iosxe_interface_ethernet.go +++ b/internal/provider/data_source_iosxe_interface_ethernet.go @@ -75,6 +75,10 @@ func (d *InterfaceEthernetDataSource) Schema(ctx context.Context, req datasource MarkdownDescription: "Media type", Computed: true, }, + "bandwidth": schema.Int64Attribute{ + MarkdownDescription: "", + Computed: true, + }, "switchport": schema.BoolAttribute{ MarkdownDescription: "", Computed: true, diff --git a/internal/provider/data_source_iosxe_interface_ethernet_test.go b/internal/provider/data_source_iosxe_interface_ethernet_test.go index 71dc51ec..12cc7c63 100644 --- a/internal/provider/data_source_iosxe_interface_ethernet_test.go +++ b/internal/provider/data_source_iosxe_interface_ethernet_test.go @@ -31,6 +31,7 @@ func TestAccDataSourceIosxeInterfaceEthernet(t *testing.T) { t.Skip("skipping test, set environment variable C8000V") } var checks []resource.TestCheckFunc + checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_interface_ethernet.test", "bandwidth", "1000000")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_interface_ethernet.test", "description", "My Interface Description")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_interface_ethernet.test", "shutdown", "false")) checks = append(checks, resource.TestCheckResourceAttr("data.iosxe_interface_ethernet.test", "ip_proxy_arp", "false")) @@ -104,6 +105,7 @@ func testAccDataSourceIosxeInterfaceEthernetConfig() string { config := `resource "iosxe_interface_ethernet" "test" {` + "\n" config += ` type = "GigabitEthernet"` + "\n" config += ` name = "3"` + "\n" + config += ` bandwidth = 1000000` + "\n" config += ` description = "My Interface Description"` + "\n" config += ` shutdown = false` + "\n" config += ` ip_proxy_arp = false` + "\n" diff --git a/internal/provider/model_iosxe_interface_ethernet.go b/internal/provider/model_iosxe_interface_ethernet.go index fdba0bb3..ffe04ed0 100644 --- a/internal/provider/model_iosxe_interface_ethernet.go +++ b/internal/provider/model_iosxe_interface_ethernet.go @@ -40,6 +40,7 @@ type InterfaceEthernet struct { Type types.String `tfsdk:"type"` Name types.String `tfsdk:"name"` MediaType types.String `tfsdk:"media_type"` + Bandwidth types.Int64 `tfsdk:"bandwidth"` Switchport types.Bool `tfsdk:"switchport"` Description types.String `tfsdk:"description"` Shutdown types.Bool `tfsdk:"shutdown"` @@ -142,6 +143,7 @@ type InterfaceEthernetData struct { Type types.String `tfsdk:"type"` Name types.String `tfsdk:"name"` MediaType types.String `tfsdk:"media_type"` + Bandwidth types.Int64 `tfsdk:"bandwidth"` Switchport types.Bool `tfsdk:"switchport"` Description types.String `tfsdk:"description"` Shutdown types.Bool `tfsdk:"shutdown"` @@ -282,6 +284,9 @@ func (data InterfaceEthernet) toBody(ctx context.Context) string { if !data.MediaType.IsNull() && !data.MediaType.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"media-type", data.MediaType.ValueString()) } + if !data.Bandwidth.IsNull() && !data.Bandwidth.IsUnknown() { + body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"bandwidth.kilobits", strconv.FormatInt(data.Bandwidth.ValueInt64(), 10)) + } if !data.Switchport.IsNull() && !data.Switchport.IsUnknown() { body, _ = sjson.Set(body, helpers.LastElement(data.getPath())+"."+"switchport-conf.switchport", data.Switchport.ValueBool()) } @@ -721,6 +726,11 @@ func (data *InterfaceEthernet) updateFromBody(ctx context.Context, res gjson.Res } else { data.MediaType = types.StringNull() } + if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() && !data.Bandwidth.IsNull() { + data.Bandwidth = types.Int64Value(value.Int()) + } else { + data.Bandwidth = types.Int64Null() + } if value := res.Get(prefix + "switchport-conf.switchport"); !data.Switchport.IsNull() { if value.Exists() { data.Switchport = types.BoolValue(value.Bool()) @@ -1542,6 +1552,9 @@ func (data *InterfaceEthernetData) fromBody(ctx context.Context, res gjson.Resul if value := res.Get(prefix + "media-type"); value.Exists() { data.MediaType = types.StringValue(value.String()) } + if value := res.Get(prefix + "bandwidth.kilobits"); value.Exists() { + data.Bandwidth = types.Int64Value(value.Int()) + } if value := res.Get(prefix + "switchport-conf.switchport"); value.Exists() { data.Switchport = types.BoolValue(value.Bool()) } else { @@ -1994,6 +2007,9 @@ func (data *InterfaceEthernet) getDeletedItems(ctx context.Context, state Interf if !state.MediaType.IsNull() && data.MediaType.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/media-type", state.getPath())) } + if !state.Bandwidth.IsNull() && data.Bandwidth.IsNull() { + deletedItems = append(deletedItems, fmt.Sprintf("%v/bandwidth/kilobits", state.getPath())) + } if !state.Switchport.IsNull() && data.Switchport.IsNull() { deletedItems = append(deletedItems, fmt.Sprintf("%v/switchport-conf/switchport", state.getPath())) } @@ -2564,6 +2580,9 @@ func (data *InterfaceEthernet) getDeletePaths(ctx context.Context) []string { if !data.MediaType.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/media-type", data.getPath())) } + if !data.Bandwidth.IsNull() { + deletePaths = append(deletePaths, fmt.Sprintf("%v/bandwidth/kilobits", data.getPath())) + } if !data.Switchport.IsNull() { deletePaths = append(deletePaths, fmt.Sprintf("%v/switchport-conf/switchport", data.getPath())) } diff --git a/internal/provider/resource_iosxe_interface_ethernet.go b/internal/provider/resource_iosxe_interface_ethernet.go index 5dd27450..bb6bf938 100644 --- a/internal/provider/resource_iosxe_interface_ethernet.go +++ b/internal/provider/resource_iosxe_interface_ethernet.go @@ -94,6 +94,13 @@ func (r *InterfaceEthernetResource) Schema(ctx context.Context, req resource.Sch stringvalidator.OneOf("auto-select", "rj45", "sfp"), }, }, + "bandwidth": schema.Int64Attribute{ + MarkdownDescription: helpers.NewAttributeDescription("").AddIntegerRangeDescription(1, 200000000).String, + Optional: true, + Validators: []validator.Int64{ + int64validator.Between(1, 200000000), + }, + }, "switchport": schema.BoolAttribute{ MarkdownDescription: helpers.NewAttributeDescription("").String, Optional: true, diff --git a/internal/provider/resource_iosxe_interface_ethernet_test.go b/internal/provider/resource_iosxe_interface_ethernet_test.go index 92575df6..1c50b9e2 100644 --- a/internal/provider/resource_iosxe_interface_ethernet_test.go +++ b/internal/provider/resource_iosxe_interface_ethernet_test.go @@ -32,6 +32,7 @@ func TestAccIosxeInterfaceEthernet(t *testing.T) { } var checks []resource.TestCheckFunc checks = append(checks, resource.TestCheckResourceAttr("iosxe_interface_ethernet.test", "name", "3")) + checks = append(checks, resource.TestCheckResourceAttr("iosxe_interface_ethernet.test", "bandwidth", "1000000")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_interface_ethernet.test", "description", "My Interface Description")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_interface_ethernet.test", "shutdown", "false")) checks = append(checks, resource.TestCheckResourceAttr("iosxe_interface_ethernet.test", "ip_proxy_arp", "false")) @@ -122,6 +123,7 @@ func testAccIosxeInterfaceEthernetConfig_all() string { config := `resource "iosxe_interface_ethernet" "test" {` + "\n" config += ` type = "GigabitEthernet"` + "\n" config += ` name = "3"` + "\n" + config += ` bandwidth = 1000000` + "\n" config += ` description = "My Interface Description"` + "\n" config += ` shutdown = false` + "\n" config += ` ip_proxy_arp = false` + "\n" diff --git a/templates/guides/changelog.md.tmpl b/templates/guides/changelog.md.tmpl index 48b2921f..7ecde398 100644 --- a/templates/guides/changelog.md.tmpl +++ b/templates/guides/changelog.md.tmpl @@ -7,6 +7,10 @@ description: |- # Changelog +## 0.5.5 (unreleased) + +- Add `bandwidth` attribute to `iosxe_interface_ethernet` resource and data source + ## 0.5.4 - Add `next_hop_self` and `next_hop_self_all` attributes to `iosxe_bgp_ipv4_unicast_vrf_neighbor` resource and data source