-
Notifications
You must be signed in to change notification settings - Fork 32
Add l3out schema, template and on_apic attributes (DCNE-161) #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
d17dcf0
e9a8d18
8c86e7a
d9e9b6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,23 @@ func resourceMSOSchemaSiteExternalEpg() *schema.Resource { | |
| Computed: true, | ||
| ValidateFunc: validation.StringLenBetween(1, 1000), | ||
| }, | ||
| "l3out_template_name": &schema.Schema{ | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Computed: true, | ||
| ValidateFunc: validation.StringLenBetween(1, 1000), | ||
| }, | ||
| "l3out_schema_id": &schema.Schema{ | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Computed: true, | ||
| ValidateFunc: validation.StringLenBetween(1, 1000), | ||
| }, | ||
| "l3out_on_apic": &schema.Schema{ | ||
| Type: schema.TypeBool, | ||
| Optional: true, | ||
| Default: false, | ||
| }, | ||
| }), | ||
| } | ||
| } | ||
|
|
@@ -106,15 +123,29 @@ func resourceMSOSchemaSiteExternalEpgImport(d *schema.ResourceData, m interface{ | |
| d.Set("site_id", apiSiteId) | ||
|
|
||
| l3outRef := models.StripQuotes(externalEpgCont.S("l3outRef").String()) | ||
| l3outDn := models.StripQuotes(externalEpgCont.S("l3outDn").String()) | ||
| if l3outRef != "{}" && l3outRef != "" { | ||
| reL3out := regexp.MustCompile("/schemas/(.*?)/templates/(.*?)/l3outs/(.*)") | ||
| matchL3out := reL3out.FindStringSubmatch(l3outRef) | ||
| log.Printf("[TRACE] resourceMSOSchemaSiteExternalEpgRead l3outRef: %s matchL3out: %s", l3outRef, matchL3out) | ||
| if len(matchL3out) >= 4 { | ||
| d.Set("l3out_name", matchL3out[3]) | ||
| d.Set("l3out_schema_id", matchL3out[1]) | ||
| d.Set("l3out_template_name", matchL3out[2]) | ||
| d.Set("l3out_on_apic", false) | ||
| } else { | ||
| return nil, fmt.Errorf("Error in parsing l3outRef to get L3Out name") | ||
| } | ||
| } else if l3outDn != "{}" && l3outDn != "" { | ||
| reL3out := regexp.MustCompile("uni/tn-(.*?)/out-(.*)") | ||
| matchL3out := reL3out.FindStringSubmatch(l3outDn) | ||
| log.Printf("[TRACE] resourceMSOSchemaSiteExternalEpgRead l3outDn: %s matchL3out: %s", l3outDn, matchL3out) | ||
| if len(matchL3out) >= 2 { | ||
| d.Set("l3out_name", matchL3out[1]) | ||
| d.Set("l3out_on_apic", true) | ||
| } else { | ||
| return fmt.Errorf("Error in parsing l3outDn to get L3Out name") | ||
| } | ||
| } | ||
|
|
||
| found = true | ||
|
|
@@ -147,6 +178,9 @@ func resourceMSOSchemaSiteExternalEpgCreate(d *schema.ResourceData, m interface{ | |
| externalEpgName := d.Get("external_epg_name").(string) | ||
| templateName := d.Get("template_name").(string) | ||
| l3outName := d.Get("l3out_name").(string) | ||
| l3outTemplate := d.Get("l3out_template_name").(string) | ||
| l3outSchema := d.Get("l3out_schema_id").(string) | ||
| l3outOnApic := d.Get("l3out_on_apic").(bool) | ||
|
|
||
| siteEpgMap := make(map[string]interface{}) | ||
|
|
||
|
|
@@ -156,14 +190,19 @@ func resourceMSOSchemaSiteExternalEpgCreate(d *schema.ResourceData, m interface{ | |
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| l3outRefMap := make(map[string]interface{}) | ||
|
|
||
| l3outRefMap["schemaId"] = schemaId | ||
| l3outRefMap["templateName"] = templateName | ||
| l3outRefMap["l3outName"] = l3outName | ||
| if l3outOnApic { | ||
| siteEpgMap["l3outRef"] = "" | ||
| } else { | ||
| l3outRefMap["schemaId"] = l3outSchema | ||
| l3outRefMap["templateName"] = l3outTemplate | ||
| l3outRefMap["l3outName"] = l3outName | ||
|
||
|
|
||
| siteEpgMap["l3outRef"] = l3outRefMap | ||
| siteEpgMap["l3outRef"] = l3outRefMap | ||
| } | ||
|
|
||
| siteEpgMap["l3outDn"] = fmt.Sprintf("uni/tn-%s/out-%s", tenantName, l3outName) | ||
| } else { | ||
| siteEpgMap["l3outDn"] = "" | ||
|
|
@@ -248,15 +287,29 @@ func resourceMSOSchemaSiteExternalEpgRead(d *schema.ResourceData, m interface{}) | |
| d.Set("site_id", apiSiteId) | ||
|
|
||
| l3outRef := models.StripQuotes(externalEpgCont.S("l3outRef").String()) | ||
| l3outDn := models.StripQuotes(externalEpgCont.S("l3outDn").String()) | ||
| if l3outRef != "{}" && l3outRef != "" { | ||
| reL3out := regexp.MustCompile("/schemas/(.*?)/templates/(.*?)/l3outs/(.*)") | ||
| matchL3out := reL3out.FindStringSubmatch(l3outRef) | ||
| log.Printf("[TRACE] resourceMSOSchemaSiteExternalEpgRead l3outRef: %s matchL3out: %s", l3outRef, matchL3out) | ||
| if len(matchL3out) >= 4 { | ||
| d.Set("l3out_name", matchL3out[3]) | ||
| d.Set("l3out_schema_id", matchL3out[1]) | ||
| d.Set("l3out_template_name", matchL3out[2]) | ||
| d.Set("l3out_on_apic", false) | ||
| } else { | ||
| return fmt.Errorf("Error in parsing l3outRef to get L3Out name") | ||
| } | ||
| } else if l3outDn != "{}" && l3outDn != "" { | ||
| reL3out := regexp.MustCompile("uni/tn-(.*?)/out-(.*)") | ||
| matchL3out := reL3out.FindStringSubmatch(l3outDn) | ||
| log.Printf("[TRACE] resourceMSOSchemaSiteExternalEpgRead l3outDn: %s matchL3out: %s", l3outDn, matchL3out) | ||
| if len(matchL3out) >= 2 { | ||
| d.Set("l3out_name", matchL3out[1]) | ||
| d.Set("l3out_on_apic", true) | ||
| } else { | ||
| return fmt.Errorf("Error in parsing l3outDn to get L3Out name") | ||
| } | ||
| } | ||
|
|
||
| found = true | ||
|
|
@@ -287,6 +340,9 @@ func resourceMSOSchemaSiteExternalEpgUpdate(d *schema.ResourceData, m interface{ | |
| templateName := d.Get("template_name").(string) | ||
| externalEpgName := d.Get("external_epg_name").(string) | ||
| l3outName := d.Get("l3out_name").(string) | ||
| l3outTemplate := d.Get("l3out_template_name").(string) | ||
| l3outSchema := d.Get("l3out_schema_id").(string) | ||
| l3outOnApic := d.Get("l3out_on_apic").(bool) | ||
|
|
||
| siteEpgMap := make(map[string]interface{}) | ||
|
|
||
|
|
@@ -299,11 +355,16 @@ func resourceMSOSchemaSiteExternalEpgUpdate(d *schema.ResourceData, m interface{ | |
|
|
||
| l3outRefMap := make(map[string]interface{}) | ||
|
|
||
| l3outRefMap["schemaId"] = schemaId | ||
| l3outRefMap["templateName"] = templateName | ||
| l3outRefMap["l3outName"] = l3outName | ||
| if l3outOnApic { | ||
| siteEpgMap["l3outRef"] = "" | ||
| } else { | ||
|
|
||
| l3outRefMap["schemaId"] = l3outSchema | ||
| l3outRefMap["templateName"] = l3outTemplate | ||
| l3outRefMap["l3outName"] = l3outName | ||
|
|
||
| siteEpgMap["l3outRef"] = l3outRefMap | ||
| siteEpgMap["l3outRef"] = l3outRefMap | ||
| } | ||
| siteEpgMap["l3outDn"] = fmt.Sprintf("uni/tn-%s/out-%s", tenantName, l3outName) | ||
| } else { | ||
| siteEpgMap["l3outDn"] = "" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a default here? Is not providing it not the same as false. In documentation we should mention the default.