Skip to content

Commit

Permalink
fix: vnet: add agg port support (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
pogossian authored Jul 12, 2022
1 parent c049979 commit c5a1758
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion netris/vnet/vnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

var re = regexp.MustCompile(`\w+\[slaves: (?P<port>(\w|,)+)\]`)
var re = regexp.MustCompile(`(?P<basePort>[a-zA-Z0-9]+)\[slaves: (?P<port>(\w|,)+)\]`)

func Resource() *schema.Resource {
return &schema.Resource{
Expand Down Expand Up @@ -371,6 +371,22 @@ func resourceRead(d *schema.ResourceData, m interface{}) error {
portList = append(portList, m)
}
}
basePort := v["basePort"]
if strings.HasPrefix(basePort, "agg") {
name := fmt.Sprintf("%s@%s", basePort, port.SwitchName)
if _, ok := tPorts[name]; ok {
if vl, ok := portVlanIDMap[name]; ok {
if vl == "1" {
port.Vlan = "1"
}
}
m := make(map[string]interface{})
m["name"] = name
m["vlanid"] = port.Vlan
m["lacp"] = port.Lacp
portList = append(portList, m)
}
}
} else {
m := make(map[string]interface{})
name := fmt.Sprintf("%s@%s", port.Port, port.SwitchName)
Expand Down

0 comments on commit c5a1758

Please sign in to comment.