feat: support excluded_network_ids on port profile resource

This commit is contained in:
Mateusz Filipowicz
2025-02-07 11:02:48 +01:00
committed by Mateusz Filipowicz
parent cdab90bb8e
commit 7c8724bc5c

View File

@@ -66,6 +66,12 @@ func resourcePortProfile() *schema.Resource {
Optional: true,
Default: false,
},
"excluded_network_ids": {
Description: "List of network IDs to exclude on the port profile when forward is set to customize.",
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"forward": {
Description: "The type forwarding to use for the port profile. Can be `all`, `native`, `customize` or `disabled`.",
Type: schema.TypeString,
@@ -158,7 +164,7 @@ func resourcePortProfile() *schema.Resource {
ValidateFunc: validation.IntBetween(0, 100),
},
"speed": {
Description: "The link speed to set for the port profile. Can be one of `10`, `100`, `1000`, `2500`, `5000`, `10000`, `20000`, `25000`, `40000`, `50000` or `100000`",
Description: "The link speed to set for the port profile in Mbps. Can be one of `10`, `100`, `1000`, `2500`, `5000`, `10000`, `20000`, `25000`, `40000`, `50000` or `100000`. When `autoneg` is true, this setting is ignored.",
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntInSlice([]int{10, 100, 1000, 2500, 5000, 10000, 20000, 25000, 40000, 50000, 100000}),
@@ -276,12 +282,18 @@ func resourcePortProfileGetResourceData(d *schema.ResourceData) (*unifi.PortProf
return nil, err
}
excludedNetworkIDs, err := setToStringSlice(d.Get("excluded_network_ids").(*schema.Set))
if err != nil {
return nil, err
}
return &unifi.PortProfile{
Autoneg: d.Get("autoneg").(bool),
Dot1XCtrl: d.Get("dot1x_ctrl").(string),
Dot1XIDleTimeout: d.Get("dot1x_idle_timeout").(int),
EgressRateLimitKbps: d.Get("egress_rate_limit_kbps").(int),
EgressRateLimitKbpsEnabled: d.Get("egress_rate_limit_kbps_enabled").(bool),
ExcludedNetworkIDs: excludedNetworkIDs,
Forward: d.Get("forward").(string),
FullDuplex: d.Get("full_duplex").(bool),
Isolation: d.Get("isolation").(bool),
@@ -321,6 +333,7 @@ func resourcePortProfileSetResourceData(resp *unifi.PortProfile, d *schema.Resou
d.Set("dot1x_idle_timeout", resp.Dot1XIDleTimeout)
d.Set("egress_rate_limit_kbps", resp.EgressRateLimitKbps)
d.Set("egress_rate_limit_kbps_enabled", resp.EgressRateLimitKbpsEnabled)
d.Set("excluded_network_ids", stringSliceToSet(resp.ExcludedNetworkIDs))
d.Set("forward", resp.Forward)
d.Set("full_duplex", resp.FullDuplex)
d.Set("isolation", resp.Isolation)