Skip to content

Commit

Permalink
[minor_change] Add support for vpc connected to fex in resource mso_s…
Browse files Browse the repository at this point in the history
…chema_site_anp_epg_bulk_staticport
  • Loading branch information
akinross committed Nov 5, 2024
1 parent 8066ab9 commit 6aa2801
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mso/resource_mso_schema_site_anp_epg_bulk_staticport.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func resourceMSOSchemaSiteAnpEpgBulkStaticPortImport(d *schema.ResourceData, m i

portPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/paths-(?P<leafValue>.*)\/extpaths-(?P<fexValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)
vpcPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/protpaths-(?P<leafValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)
vpcWithFexPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/protpaths-(?P<leafValue>.*)\/extprotpaths-(?P<fexValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)
dpcPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/paths-(?P<leafValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)

staticPortsList := make([]interface{}, 0, 1)
Expand Down Expand Up @@ -216,6 +217,9 @@ func resourceMSOSchemaSiteAnpEpgBulkStaticPortImport(d *schema.ResourceData, m i
if portPath.MatchString(pathValue) {
matchedMap = getStaticPortPathValues(pathValue, portPath)
staticPortMap["fex"] = matchedMap["fexValue"]
} else if vpcWithFexPath.MatchString(pathValue) {
matchedMap = getStaticPortPathValues(pathValue, vpcWithFexPath)
staticPortMap["fex"] = matchedMap["fexValue"]
} else if vpcPath.MatchString(pathValue) {
matchedMap = getStaticPortPathValues(pathValue, vpcPath)
} else if dpcPath.MatchString(pathValue) {
Expand Down Expand Up @@ -284,6 +288,8 @@ func resourceMSOSchemaSiteAnpEpgBulkStaticPortCreate(d *schema.ResourceData, m i

if staticPortMap["type"] == "port" && static_port_fex != "" {
portpath = fmt.Sprintf("topology/%s/paths-%s/extpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_fex, static_port_path)
} else if staticPortMap["type"] == "vpc" && static_port_fex != "" {
portpath = fmt.Sprintf("topology/%s/protpaths-%s/extprotpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_fex, static_port_path)
} else if staticPortMap["type"] == "vpc" {
portpath = fmt.Sprintf("topology/%s/protpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_path)
} else {
Expand Down Expand Up @@ -412,6 +418,7 @@ func resourceMSOSchemaSiteAnpEpgBulkStaticPortRead(d *schema.ResourceData, m int

portPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/paths-(?P<leafValue>.*)\/extpaths-(?P<fexValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)
vpcPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/protpaths-(?P<leafValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)
vpcWithFexPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/protpaths-(?P<leafValue>.*)\/extprotpaths-(?P<fexValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)
dpcPath := regexp.MustCompile(`(topology\/(?P<podValue>.*)\/paths-(?P<leafValue>.*)\/pathep-\[(?P<pathValue>.*)\])`)

staticPortsList := make([]interface{}, 0, 1)
Expand Down Expand Up @@ -446,6 +453,9 @@ func resourceMSOSchemaSiteAnpEpgBulkStaticPortRead(d *schema.ResourceData, m int
if portPath.MatchString(pathValue) {
matchedMap = getStaticPortPathValues(pathValue, portPath)
staticPortMap["fex"] = matchedMap["fexValue"]
} else if vpcWithFexPath.MatchString(pathValue) {
matchedMap = getStaticPortPathValues(pathValue, vpcWithFexPath)
staticPortMap["fex"] = matchedMap["fexValue"]
} else if vpcPath.MatchString(pathValue) {
matchedMap = getStaticPortPathValues(pathValue, vpcPath)
} else if dpcPath.MatchString(pathValue) {
Expand Down Expand Up @@ -514,6 +524,8 @@ func resourceMSOSchemaSiteAnpEpgBulkStaticPortUpdate(d *schema.ResourceData, m i

if staticPortMap["type"] == "port" && static_port_fex != "" {
portpath = fmt.Sprintf("topology/%s/paths-%s/extpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_fex, static_port_path)
} else if staticPortMap["type"] == "vpc" && static_port_fex != "" {
portpath = fmt.Sprintf("topology/%s/protpaths-%s/extprotpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_fex, static_port_path)
} else if staticPortMap["type"] == "vpc" {
portpath = fmt.Sprintf("topology/%s/protpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_path)
} else {
Expand Down Expand Up @@ -608,6 +620,8 @@ func resourceMSOSchemaSiteAnpEpgBulkStaticPortDelete(d *schema.ResourceData, m i

if staticPortMap["path_type"] == "port" && staticPort["fex"] != "" {
portpath = fmt.Sprintf("topology/%s/paths-%s/extpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_fex, static_port_path)
} else if staticPortMap["type"] == "vpc" && static_port_fex != "" {
portpath = fmt.Sprintf("topology/%s/protpaths-%s/extprotpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_fex, static_port_path)
} else if staticPortMap["path_type"] == "vpc" {
portpath = fmt.Sprintf("topology/%s/protpaths-%s/pathep-[%s]", static_port_pod, static_port_leaf, static_port_path)
} else {
Expand Down

0 comments on commit 6aa2801

Please sign in to comment.