Skip to content

Commit

Permalink
r/interface_physical: add storm_control argument
Browse files Browse the repository at this point in the history
Partial fix #574
  • Loading branch information
jeremmfr committed Nov 21, 2023
1 parent 27e555f commit 8275a4e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .changes/issue-574.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
FEATURES:

* add **junos_forwardingoptions_storm_control_profile** resource (Partial fix [#574](https://github.com/jeremmfr/terraform-provider-junos/issues/574))

ENHANCEMENTS:

* **resource/junos_interface_physical**: add `storm_control` argument (Partial fix [#574](https://github.com/jeremmfr/terraform-provider-junos/issues/574))
2 changes: 2 additions & 0 deletions docs/resources/interface_physical.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ The following arguments are supported:
- **speed** (Optional, String)
Link speed.
Must be a valid speed (10m | 100m | 1g ...)
- **storm_control** (Optional, String)
Storm control profile name to bind.
- **trunk** (Optional, Boolean)
Interface mode is trunk.
- **trunk_non_els** (Optional, Boolean)
Expand Down
16 changes: 16 additions & 0 deletions internal/providerfwk/resource_interface_physical.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ func (rsc *interfacePhysical) Schema(
"must be a valid speed (10m | 100m | 1g ...)"),
},
},
"storm_control": schema.StringAttribute{
Optional: true,
Description: "Storm control profile name to bind.",
Validators: []validator.String{
stringvalidator.LengthBetween(1, 127),
tfvalidator.StringDoubleQuoteExclusion(),
},
},
"trunk": schema.BoolAttribute{
Optional: true,
Description: "Interface mode is trunk.",
Expand Down Expand Up @@ -641,6 +649,7 @@ type interfacePhysicalData struct {
LinkMode types.String `tfsdk:"link_mode"`
Mtu types.Int64 `tfsdk:"mtu"`
Speed types.String `tfsdk:"speed"`
StormControl types.String `tfsdk:"storm_control"`
VlanMembers []types.String `tfsdk:"vlan_members"`
VlanNative types.Int64 `tfsdk:"vlan_native"`
VlanNativeNonELS types.String `tfsdk:"vlan_native_non_els"`
Expand Down Expand Up @@ -669,6 +678,7 @@ type interfacePhysicalConfig struct {
LinkMode types.String `tfsdk:"link_mode"`
Mtu types.Int64 `tfsdk:"mtu"`
Speed types.String `tfsdk:"speed"`
StormControl types.String `tfsdk:"storm_control"`
VlanMembers types.List `tfsdk:"vlan_members"`
VlanNative types.Int64 `tfsdk:"vlan_native"`
VlanNativeNonELS types.String `tfsdk:"vlan_native_non_els"`
Expand Down Expand Up @@ -1737,6 +1747,9 @@ func (rscData *interfacePhysicalData) set(
if v := rscData.Speed.ValueString(); v != "" {
configSet = append(configSet, setPrefix+"speed "+v)
}
if v := rscData.StormControl.ValueString(); v != "" {
configSet = append(configSet, setPrefix+"unit 0 family ethernet-switching storm-control \""+v+"\"")
}
if rscData.Trunk.ValueBool() {
configSet = append(configSet, setPrefix+"unit 0 family ethernet-switching interface-mode trunk")
}
Expand Down Expand Up @@ -2028,6 +2041,8 @@ func (rscData *interfacePhysicalData) read(
rscData.NoGratuitousArpRequest = types.BoolValue(true)
case balt.CutPrefixInString(&itemTrim, "speed "):
rscData.Speed = types.StringValue(itemTrim)
case balt.CutPrefixInString(&itemTrim, "unit 0 family ethernet-switching storm-control "):
rscData.StormControl = types.StringValue(strings.Trim(itemTrim, "\""))
case itemTrim == "unit 0 family ethernet-switching interface-mode trunk":
rscData.Trunk = types.BoolValue(true)
case itemTrim == "unit 0 family ethernet-switching port-mode trunk":
Expand Down Expand Up @@ -2228,6 +2243,7 @@ func (rscData *interfacePhysicalData) delOpts(
delPrefix + "unit 0 family ethernet-switching interface-mode",
delPrefix + "unit 0 family ethernet-switching native-vlan-id",
delPrefix + "unit 0 family ethernet-switching port-mode",
delPrefix + "unit 0 family ethernet-switching storm-control",
delPrefix + "unit 0 family ethernet-switching vlan members",
delPrefix + "vlan-tagging",
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
resource "junos_interface_physical" "testacc_interface" {
name = var.interface
description = "testacc_interface"
trunk = true
vlan_native = 100
vlan_members = ["100-110"]
name = var.interface
description = "testacc_interface"
storm_control = junos_forwardingoptions_storm_control_profile.testacc_interface.name
trunk = true
vlan_native = 100
vlan_members = ["100-110"]
}

resource "junos_forwardingoptions_storm_control_profile" "testacc_interface" {
name = "testacc interface"
all {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ resource "junos_interface_physical" "testacc_interface" {
description = "testacc_interfaceU"
vlan_members = ["100"]
}

resource "junos_forwardingoptions_storm_control_profile" "testacc_interface" {
name = "testacc interface"
all {}
}

0 comments on commit 8275a4e

Please sign in to comment.