Skip to content

Commit

Permalink
Added mtu attribute to vlan resource
Browse files Browse the repository at this point in the history
  • Loading branch information
urohit011 committed Dec 29, 2023
1 parent 609099d commit 1a4dd60
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bigip/resource_bigip_net_vlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func resourceBigipNetVlan() *schema.Resource {
Optional: true,
Description: "Vlan name",
},

"tagged": {
Type: schema.TypeBool,
Optional: true,
Expand All @@ -62,6 +61,13 @@ func resourceBigipNetVlan() *schema.Resource {
},
},
},
"mtu": {
Type: schema.TypeInt,
Optional: true,
Description: "Maximum Transmission Unit (MTU) for the VLAN",
Default: 1500,
ValidateFunc: validation.IntBetween(576, 9198),
},
"cmp_hash": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -79,6 +85,7 @@ func resourceBigipNetVlanCreate(ctx context.Context, d *schema.ResourceData, met

name := d.Get("name").(string)
tag := d.Get("tag").(int)
mtu := d.Get("mtu").(int)

log.Printf("[INFO] Creating VLAN %s", name)

Expand All @@ -87,6 +94,7 @@ func resourceBigipNetVlanCreate(ctx context.Context, d *schema.ResourceData, met
r := &bigip.Vlan{
Name: name,
Tag: tag,
MTU: mtu,
CMPHash: d.Get("cmp_hash").(string),
}

Expand Down Expand Up @@ -135,6 +143,7 @@ func resourceBigipNetVlanRead(ctx context.Context, d *schema.ResourceData, meta
_ = d.Set("name", vlan.FullPath)
_ = d.Set("tag", vlan.Tag)
_ = d.Set("cmp_hash", vlan.CMPHash)
_ = d.Set("mtu", vlan.MTU)

log.Printf("[DEBUG] Reading VLAN %s Interfaces", name)

Expand Down Expand Up @@ -178,6 +187,7 @@ func resourceBigipNetVlanUpdate(ctx context.Context, d *schema.ResourceData, met
r := &bigip.Vlan{
Name: name,
Tag: d.Get("tag").(int),
MTU: d.Get("mtu").(int),
CMPHash: d.Get("cmp_hash").(string),
}

Expand Down
2 changes: 2 additions & 0 deletions bigip/resource_bigip_net_vlan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ resource "bigip_net_vlan" "test-vlan" {
vlanport = 1.1
tagged = true
}
mtu = 900
}
`

Expand All @@ -45,6 +46,7 @@ func TestAccBigipNetvlan_create(t *testing.T) {
resource.TestCheckResourceAttr("bigip_net_vlan.test-vlan", "tag", "101"),
resource.TestCheckResourceAttr("bigip_net_vlan.test-vlan", "interfaces.0.vlanport", "1.1"),
resource.TestCheckResourceAttr("bigip_net_vlan.test-vlan", "interfaces.0.tagged", "true"),
resource.TestCheckResourceAttr("bigip_net_vlan.test-vlan", "mtu", "900"),
),
},
},
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/bigip_net_vlan.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ resource "bigip_net_vlan" "vlan1" {
* `cmp_hash` - (Optional,type `string`) Specifies how the traffic on the VLAN will be disaggregated. The value selected determines the traffic disaggregation method. possible options: [`default`, `src-ip`, `dst-ip`]

* `tagged` - Specifies a list of tagged interfaces or trunks associated with this VLAN. Note that you can associate tagged interfaces or trunks with any number of VLANs.

* `mtu` - Specifies the maximum transmission unit (MTU) for traffic on this VLAN. The default value is `1500`.

0 comments on commit 1a4dd60

Please sign in to comment.