Skip to content
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

Add l3out schema, template and on_apic attributes (DCNE-161) #291

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions mso/resource_mso_schema_site_external_epg.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ func resourceMSOSchemaSiteExternalEpg() *schema.Resource {
Computed: true,
ValidateFunc: validation.StringLenBetween(1, 1000),
},
"l3out_template": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringLenBetween(1, 1000),
},
"l3out_schema": &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,
Copy link
Collaborator

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.

},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. handle the read and import of these attributes.
  2. adjust the datasource for these attributes.
  3. update the example to include a APIC and a NDO l3out
  4. update documentation with attributes missing ( website/docs/r/mso_schema_site_external_epg.html.markdown )

}),
}
}
Expand Down Expand Up @@ -147,6 +164,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").(string)
l3outSchema := d.Get("l3out_schema").(string)
l3outOnApic := d.Get("l3out_on_apic").(bool)

siteEpgMap := make(map[string]interface{})

Expand All @@ -156,14 +176,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
Copy link
Collaborator

@akinross akinross Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we still miss a thing. We can do two things actually.

  • We should do a check that the template and schema are provided because they are optional but I believe they are required for the ref to be constructed.
  • Or we can set the schema/template of the external epg when these are not provided. ( my preference )

Another thing is should we add validation of config to make l3outSchema/l3outTemplate mutually exclusive from l3out_on_apic?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behaviour should also be described in documentation.


siteEpgMap["l3outRef"] = l3outRefMap
siteEpgMap["l3outRef"] = l3outRefMap
}

siteEpgMap["l3outDn"] = fmt.Sprintf("uni/tn-%s/out-%s", tenantName, l3outName)
} else {
siteEpgMap["l3outDn"] = ""
Expand Down Expand Up @@ -287,6 +312,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").(string)
l3outSchema := d.Get("l3out_schema").(string)
l3outOnApic := d.Get("l3out_on_apic").(bool)

siteEpgMap := make(map[string]interface{})

Expand All @@ -299,11 +327,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"] = ""
Expand Down
Loading