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

Terraformer phase 2 updates #921

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions aci/resource_aci_aaaldapgroupmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func setLDAPGroupMapAttributes(aaaLdapGroupMap *models.LDAPGroupMap, d *schema.R
if err != nil {
return d, err
}
d.Set("annotation", aaaLdapGroupMapMap["annotation"])
d.Set("name", aaaLdapGroupMapMap["name"])
d.Set("name_alias", aaaLdapGroupMapMap["nameAlias"])
return d, nil
Expand Down
1 change: 1 addition & 0 deletions aci/resource_aci_aaaradiusprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func setRADIUSProviderAttributes(radius_type string, aaaRadiusProvider *models.R
d.Set("retries", aaaRadiusProviderMap["retries"])
d.Set("timeout", aaaRadiusProviderMap["timeout"])
d.Set("name_alias", aaaRadiusProviderMap["nameAlias"])
d.Set("annotation", aaaRadiusProviderMap["annotation"])
return d, nil
}

Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaauserep.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func resourceAciUserManagementRead(ctx context.Context, d *schema.ResourceData,
aaaPwdProfileDn := dn + "/pwdprofile"
aaaPwdProfile, err := getRemotePasswordChangeExpirationPolicy(aciClient, aaaPwdProfileDn)
if err != nil {
return diag.FromErr(err)
return nil
}
_, err = setPasswordChangeExpirationPolicyAttributes(aaaPwdProfile, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaauserrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func getRemoteUserRole(client *client.Client, dn string) (*models.UserRole, erro
func setUserRoleAttributes(aaaUserRole *models.UserRole, d *schema.ResourceData) (*schema.ResourceData, error) {
d.SetId(aaaUserRole.DistinguishedName)
d.Set("description", aaaUserRole.Description)

d.Set("annotation", aaaUserRole.Annotation)
aaaUserRoleMap, err := aaaUserRole.ToMap()
if err != nil {
return nil, err
Expand Down
50 changes: 48 additions & 2 deletions aci/resource_aci_fabricrsoospath.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ func resourceAciOutofServiceFabricPath() *schema.Resource {
},

SchemaVersion: 1,
Schema: AppendBaseAttrSchema(map[string]*schema.Schema{
Schema: map[string]*schema.Schema{
"annotation": {
Type: schema.TypeString,
Optional: true,
Computed: true,
DefaultFunc: func() (interface{}, error) {
return "orchestrator:terraform", nil
},
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as Akini on other file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a GetAnnotation function for uniform schema implementation.

},
"pod_id": {
Type: schema.TypeInt,
Expand All @@ -51,7 +54,7 @@ func resourceAciOutofServiceFabricPath() *schema.Resource {
Required: true,
ForceNew: true,
},
}),
},
}
}

Expand All @@ -73,6 +76,49 @@ func setOutofServiceFabricPathAttributes(fabricRsOosPath *models.OutofServiceFab
if err != nil {
return d, err
}
if fabricRsOosPath.TDn != "" {
interfaceRegEx := regexp.MustCompile(`topology/pod-([0-9]+?)/paths-([0-9]+?)/pathep-\[(.*?)\]`)
fexRegEx := regexp.MustCompile(`topology/pod-([0-9]+?)/paths-([0-9]+?)/extpaths-([0-9]+?)/pathep-\[(.*?)\]`)
matchInterface := interfaceRegEx.FindStringSubmatch(fabricRsOosPath.TDn)
if len(matchInterface) > 0 {
podId, err := strconv.Atoi(matchInterface[1])
if err != nil {
return nil, err
}
d.Set("pod_id", podId)

nodeId, err := strconv.Atoi(matchInterface[2])
if err != nil {
return nil, err
}
d.Set("node_id", nodeId)

d.Set("interface", matchInterface[3])
} else {
matchFex := fexRegEx.FindStringSubmatch(fabricRsOosPath.TDn)
if len(matchFex) > 0 {
podId, err := strconv.Atoi(matchFex[1])
if err != nil {
return nil, err
}
d.Set("pod_id", podId)

nodeId, err := strconv.Atoi(matchFex[2])
if err != nil {
return nil, err
}
d.Set("node_id", nodeId)

fexId, err := strconv.Atoi(matchFex[3])
if err != nil {
return nil, err
}
d.Set("fex_id", fexId)

d.Set("interface", matchFex[4])
}
}
}
d.Set("annotation", fabricRsOosPathMap["annotation"])
return d, nil
}
Expand Down
12 changes: 10 additions & 2 deletions aci/resource_aci_fvrsconsif.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ func resourceAciContractInterfaceRelationship() *schema.Resource {
},

SchemaVersion: 1,
Schema: AppendBaseAttrSchema(map[string]*schema.Schema{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we remove this function and add the annotation as separate entries to the Schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This Function appends description and annotation attribute to the respective resource schema. Some of the ACI classes doesn't support description but may support annotation, Hence addition of annotation separately.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you consider creating separate function for annotation only and re-use this? Also have a look at the AppendAttrSchemas function in https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/aci/base_attr_schema.go, this could perhaps be leveraged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a GetAnnotation function for uniform schema implementation.

Schema: map[string]*schema.Schema{
"application_epg_dn": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"annotation": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
DefaultFunc: func() (interface{}, error) {
return "orchestrator:terraform", nil
},
},
"prio": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -49,7 +57,7 @@ func resourceAciContractInterfaceRelationship() *schema.Resource {
Required: true,
ForceNew: true,
},
}),
},
}
}

Expand Down
11 changes: 7 additions & 4 deletions aci/resource_aci_infrarsdomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,26 @@ func resourceAciInfraRsDomP() *schema.Resource {
},

SchemaVersion: 1,
Schema: AppendBaseAttrSchema(map[string]*schema.Schema{
Schema: map[string]*schema.Schema{
"attachable_access_entity_profile_dn": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"annotation": {
"annotation": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
DefaultFunc: func() (interface{}, error) {
return "orchestrator:terraform", nil
},
Copy link
Member

Choose a reason for hiding this comment

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

same comment as Akini on other file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a GetAnnotation function for uniform schema implementation.

},
"domain_dn": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
}),
},
}
}

Expand All @@ -61,11 +64,11 @@ func setInfraRsDomPAttributes(infraRsDomP *models.InfraRsDomP, d *schema.Resourc
if dn != infraRsDomP.DistinguishedName {
d.Set("attachable_access_entity_profile_dn", "")
}
d.Set("attachable_access_entity_profile_dn", GetParentDn(dn, fmt.Sprintf("/%s", fmt.Sprintf(models.RninfraRsDomP, d.Get("domain_dn")))))
infraRsDomPMap, err := infraRsDomP.ToMap()
if err != nil {
return d, err
}
d.Set("attachable_access_entity_profile_dn", GetParentDn(dn, fmt.Sprintf("/rsdomP-[%s]", infraRsDomPMap["tDn"])))
d.Set("annotation", infraRsDomPMap["annotation"])
d.Set("domain_dn", infraRsDomPMap["tDn"])
return d, nil
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_isisdompol.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func resourceAciISISDomainPolicyRead(ctx context.Context, d *schema.ResourceData
if isisCompDn != "" {
isisLvlComp, err := getRemoteISISLevel(aciClient, isisCompDn)
if err != nil {
return diag.FromErr(err)
return nil
}
_, err = setISISLevelAttributes(isisLvlComp, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_rtctrlmatchcommterm.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func resourceAciMatchCommunityTermRead(ctx context.Context, d *schema.ResourceDa
rtctrlMatchCommFactor, err := getRemoteMatchCommunityFactor(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
factorSet, err := setMatchCommunityFactorAttributes(rtctrlMatchCommFactor, make(map[string]string))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions aci/resource_aci_tacacssrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func setTACACSSourceAttributes(tacacsSrc *models.TACACSSource, d *schema.Resourc
d.Set("min_sev", tacacsSrcMap["minSev"])
d.Set("name", tacacsSrcMap["name"])
d.Set("name_alias", tacacsSrcMap["nameAlias"])
d.Set("annotation", tacacsSrcMap["annotation"])
return d, nil
}

Expand Down
4 changes: 2 additions & 2 deletions aci/resource_aci_tagannotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func resourceAciAnnotation() *schema.Resource {
},

SchemaVersion: 1,
Schema: AppendBaseAttrSchema(map[string]*schema.Schema{
Schema: map[string]*schema.Schema{
"parent_dn": {
Type: schema.TypeString,
Required: true,
Expand All @@ -38,7 +38,7 @@ func resourceAciAnnotation() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
}),
},
}
}

Expand Down
4 changes: 2 additions & 2 deletions aci/resource_aci_tagtag.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func resourceAciTag() *schema.Resource {
},

SchemaVersion: 1,
Schema: AppendBaseAttrSchema(map[string]*schema.Schema{
Schema: map[string]*schema.Schema{
"parent_dn": {
Type: schema.TypeString,
Required: true,
Expand All @@ -38,7 +38,7 @@ func resourceAciTag() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
}),
},
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/docs/d/interface_blacklist.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data "aci_outof_service_fabric_path" "example" {

* `pod_id` - (Required) The Pod ID of the switch that own the interface that need to be disabled.
* `node_id` - (Required) The Node ID of the switch that own the interface that need to be disabled.
* `fex_id` - (Required) The FEX ID of the FEX that own the interface that need to be disabled.
* `fex_id` - (Optional) The FEX ID of the FEX that own the interface that need to be disabled.
* `interface` - (Required) The interface name of the interface that need to be disabled.

## Attribute Reference ##
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/file_remote_path.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ resource "aci_file_remote_path" "example" {
## Argument Reference ##
* `name` - (Required) Name of object File Remote Path.
* `host` - (Required) Hostname or IP for export destination of object File Remote Path.
* `name_alias` - (Optional) Name alias for object File Remote Path.
* `annotation` - (Optional) Annotation of object File Remote Path.
* `auth_type` - (Optional) Authentication Type Choice. Allowed values are "usePassword" and "useSshKeyContents". Default value is "usePassword". Type: String.
* `identity_private_key_contents` - (Optional) SSH Private Key File contents for datatransfer. Must be set if `auth_type` is equal to "useSshKeyContents".
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/interface_blacklist.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ resource "aci_interface_blacklist" "example" {

* `pod_id` - (Required) The Pod ID of the switch that own the interface that need to be disabled.
* `node_id` - (Required) The Node ID of the switch that own the interface that need to be disabled.
* `fex_id` - (Required) The FEX ID of the FEX that own the interface that need to be disabled.
* `fex_id` - (Optional) The FEX ID of the FEX that own the interface that need to be disabled.
* `interface` - (Required) The interface name of the interface that need to be disabled.
* `annotation` - (Optional) Annotation of the blacklist object (fabricRsOosPath).

Expand Down
3 changes: 2 additions & 1 deletion website/docs/r/match_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ resource "aci_match_rule" "rule" {
* `tenant_dn` - (Required) Distinguished name of parent Tenant object.
* `name` - (Required) Name of object Match Rule.
* `annotation` - (Optional) Annotation of object Match Rule.

* `name_alias` - (Optional) Name alias for object Match Rule.
* `description` - (Optional) Description of object Match Rule.


## Importing ##
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/recurring_window.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ resource "aci_recurring_window" "example" {

* `scheduler_dn` - (Required) Distinguished name of parent Scheduler object.
* `name` - (Required) Name of object Recurring Window.
* `name_alias` - (Optional) Name alias for object Recurring Window.
* `annotation` - (Optional) Annotation of object Recurring Window.
* `concur_cap` - (Optional) Maximum Concurrent Tasks. The concurrency capacity limit. This is the maximum number of tasks that can be processed concurrently. Range: "1" - "65535". Default value is "unlimited"(If user sets "0" as a value, provider will accept it but it'll set it as "unlimited"). Type: String.
* `day` - (Optional) Recurring Window Schedule Day. The day of the week that the recurring window begins. Allowed values are "Friday", "Monday", "Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday", "even-day", "every-day", "odd-day", and default value is "every-day". Type: String.
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/route_control_context.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ resource "aci_route_control_context" "control" {
* `annotation` - (Optional) Annotation of object Route Control Context.
* `action` - (Optional) Action. The action required when the condition is met. Allowed values are "deny", "permit", and default value is "permit". Type: String.
* `order` - (Optional) Local Order.The order of the policy context. Allowed range is 0-9 and default value is "0".
- `description` - (Optional) Description of object Route Control Context.
- `name_alias` - (Optional) Name alias of object Route Control Context.
* `set_rule` - (Optional) Represents the relation to an Attribute Profile (class rtctrlAttrP). Type: String.
* `relation_rtctrl_rs_ctx_p_to_subj_p` - (Optional) Represents the relation to a Subject Profile (class rtctrlSubjP). Type: List.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/spine_access_port_selector.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "aci_spine_access_port_selector" "example" {
* `spine_access_port_selector_type` - (Required) The type of Spine Access Port Selector. Allowed values are "ALL" and "range". Default is "ALL". The "range" can be specified with the resource "aci_access_port_block".
* `annotation` - (Optional) Annotation of the Spine Access Port Selector.
* `name_alias` - (Optional) Name Alias of the Spine Access Port Selector.

- `description` - (Optional) Description of object Spine Access Port Selector.
* `relation_infra_rs_sp_acc_grp` - (Optional) Represents the relation to a Spine Access Group (class infraSpAccGrp). Type: String.


Expand Down