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

[minor_changes] Adding missing parameters to function_node resource/datasource. #1144

Merged
merged 10 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
6 changes: 6 additions & 0 deletions aci/data_source_aci_cloudlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ func dataSourceAciCloudL4L7LoadBalancer() *schema.Resource {
Computed: true,
Set: schema.HashString,
},
"static_ip_address": &schema.Schema{
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Set: schema.HashString,
},
}),
}
}
Expand Down
16 changes: 16 additions & 0 deletions aci/data_source_aci_vnsabsnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ func dataSourceAciFunctionNode() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_consumer_connector_type": &schema.Schema{
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_provider_connector_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_consumer_att_notify": &schema.Schema{
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_provider_att_notify": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
}),
}
}
Expand Down
46 changes: 46 additions & 0 deletions aci/resource_aci_cloudlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
const (
CloudLBClassName = "cloudLB"
CloudRsLDevToCloudSubnetClassName = "cloudRsLDevToCloudSubnet"
CloudFrontendIPv4AddrClassName = "cloudFrontendIPv4Addr"
RnCloudLB = "clb-%s"
)

Expand Down Expand Up @@ -277,6 +278,12 @@ func resourceAciCloudL4L7LoadBalancer() *schema.Resource {
Optional: true,
Set: schema.HashString,
},
"static_ip_address": &schema.Schema{
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Set: schema.HashString,
},
}, GetNameAliasAttrSchema(), GetAnnotationAttrSchema()),
}
}
Expand Down Expand Up @@ -334,6 +341,23 @@ func mapCloudRsLDevToCloudSubnetAttrs(annotation, status string, subnetTargetDnL
return cloudSubnetAttrsList
}

func mapCloudFrontendIPv4AddrAttrs(annotation, status string, subnetStaticIPList []string) []interface{} {
cloudSubnetAttrsList := make([]interface{}, len(subnetStaticIPList))
for index, ip := range subnetStaticIPList {
cloudSubnetAttrsMap := map[string]interface{}{
CloudFrontendIPv4AddrClassName: map[string]interface{}{
"attributes": map[string]string{
"annotation": annotation,
"ip": ip,
"status": status,
},
},
}
cloudSubnetAttrsList[index] = cloudSubnetAttrsMap
}
return cloudSubnetAttrsList
}

func getAndSetRemoteCloudL4L7LoadBalancerAttributes(client *client.Client, dn string, d *schema.ResourceData) (*schema.ResourceData, error) {
dnUrl := fmt.Sprintf("%s/%s.json?rsp-subtree=full", client.MOURL, dn)
cloudLBCont, err := client.GetViaURL(dnUrl)
Expand Down Expand Up @@ -386,6 +410,7 @@ func getAndSetRemoteCloudL4L7LoadBalancerAttributes(client *client.Client, dn st

cloudLBChildSubnetList := make([]string, 0)
cloudLBChildAaaDomainList := make([]string, 0)
cloudLBChildStaticIPList := make([]string, 0)

cloudLBChild := cloudLBCont.S("imdata").Index(0).S(CloudLBClassName).S("children")
for i := 0; i < cloudLBChildCount; i++ {
Expand All @@ -394,13 +419,19 @@ func getAndSetRemoteCloudL4L7LoadBalancerAttributes(client *client.Client, dn st
cloudLBChildSubnetList = append(cloudLBChildSubnetList, cloudSubnetTDn)
continue
}
staticIPAddress := models.StripQuotes(cloudLBChild.Index(i).S(CloudFrontendIPv4AddrClassName).S("attributes").S("ip").String())
if staticIPAddress != "{}" {
cloudLBChildStaticIPList = append(cloudLBChildStaticIPList, staticIPAddress)
continue
}
aaaDomainName := models.StripQuotes(cloudLBChild.Index(i).S("aaaRbacAnnotation").S("attributes").S("domain").String())
if aaaDomainName != "{}" {
cloudLBChildAaaDomainList = append(cloudLBChildAaaDomainList, fmt.Sprintf("uni/userext/domain-%s", aaaDomainName))
continue
}
}
d.Set("relation_cloud_rs_ldev_to_cloud_subnet", cloudLBChildSubnetList)
d.Set("static_ip_address", cloudLBChildStaticIPList)
d.Set("aaa_domain_dn", cloudLBChildAaaDomainList)

d.SetId(cloudLBDistinguishedName)
Expand Down Expand Up @@ -451,6 +482,11 @@ func resourceAciCloudL4L7LoadBalancerCreate(ctx context.Context, d *schema.Resou
cloudLBChildList = append(cloudLBChildList, mapListOfAaaDomainAttrs("created", toStringList(aaaDomainDn.(*schema.Set).List()))...)
}

if staticIPAddress, ok := d.GetOk("static_ip_address"); ok {
cloudLBChildList = append(cloudLBChildList, mapCloudFrontendIPv4AddrAttrs(annotation, "created", toStringList(staticIPAddress.(*schema.Set).List())))

}

cloudLBMapAttrs := mapCloudL4L7LoadBalancerAttrs("created", d)
deleteEmptyValuesfromMap(cloudLBMapAttrs)
cloudLBMap := map[string]interface{}{
Expand Down Expand Up @@ -511,6 +547,16 @@ func resourceAciCloudL4L7LoadBalancerUpdate(ctx context.Context, d *schema.Resou
cloudLBChildList = append(cloudLBChildList, mapCloudRsLDevToCloudSubnetAttrs(annotation, "created, modified", relToCreate)...)
}

if d.HasChange("static_ip_address") {
oldRel, newRel := d.GetChange("static_ip_address")
oldRelSet := oldRel.(*schema.Set)
newRelSet := newRel.(*schema.Set)
relToDelete := toStringList(oldRelSet.Difference(newRelSet).List())
relToCreate := toStringList(newRelSet.Difference(oldRelSet).List())
cloudLBChildList = append(cloudLBChildList, mapCloudFrontendIPv4AddrAttrs(annotation, "deleted", relToDelete)...)
cloudLBChildList = append(cloudLBChildList, mapCloudFrontendIPv4AddrAttrs(annotation, "created, modified", relToCreate)...)
}

if d.HasChange("aaa_domain_dn") {
oldRel, newRel := d.GetChange("aaa_domain_dn")
oldRelSet := oldRel.(*schema.Set)
Expand Down
66 changes: 56 additions & 10 deletions aci/resource_aci_vnsabsnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,63 @@ func resourceAciFunctionNode() *schema.Resource {
},

"relation_vns_rs_node_to_abs_func_prof": &schema.Schema{
Type: schema.TypeString,

Type: schema.TypeString,
Optional: true,
},
"relation_vns_rs_node_to_l_dev": &schema.Schema{
Type: schema.TypeString,

Type: schema.TypeString,
Optional: true,
},
"relation_vns_rs_node_to_m_func": &schema.Schema{
Type: schema.TypeString,

Type: schema.TypeString,
Optional: true,
},
"relation_vns_rs_default_scope_to_term": &schema.Schema{
Type: schema.TypeString,

Type: schema.TypeString,
Optional: true,
},
"relation_vns_rs_node_to_cloud_l_dev": &schema.Schema{
Type: schema.TypeString,

Type: schema.TypeString,
Optional: true,
},
"l4_l7_device_interface_consumer_connector_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"none",
"redir",
}, false),
},
"l4_l7_device_interface_provider_connector_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"none",
"redir",
"dnat",
"snat",
"snat_dnat",
}, false),
},
"l4_l7_device_interface_consumer_att_notify": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"no",
"yes",
}, false),
},
"l4_l7_device_interface_provider_att_notify": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"no",
"yes",
}, false),
},
}),
}
Expand Down Expand Up @@ -231,6 +265,8 @@ func getAndSetFunctionNodeRelationalAttributes(client *client.Client, dn string,
}
d.Set("conn_consumer_dn", vnsAbsFuncConn.DistinguishedName)
d.Set("l4_l7_device_interface_consumer_name", vnsAbsFuncConn.DeviceLIfName)
d.Set("l4_l7_device_interface_consumer_connector_type", vnsAbsFuncConn.ConnType)
d.Set("l4_l7_device_interface_consumer_att_notify", vnsAbsFuncConn.AttNotify)

// Provider Part
provDn := fmt.Sprintf("%s/AbsFConn-provider", dn)
Expand All @@ -244,6 +280,8 @@ func getAndSetFunctionNodeRelationalAttributes(client *client.Client, dn string,
}
d.Set("conn_provider_dn", vnsAbsFuncConn.DistinguishedName)
d.Set("l4_l7_device_interface_provider_name", vnsAbsFuncConn.DeviceLIfName)
d.Set("l4_l7_device_interface_provider_connector_type", vnsAbsFuncConn.ConnType)
d.Set("l4_l7_device_interface_provider_att_notify", vnsAbsFuncConn.AttNotify)

vnsRsNodeToAbsFuncProfData, err := client.ReadRelationvnsRsNodeToAbsFuncProfFromFunctionNode(dn)
if err != nil {
Expand Down Expand Up @@ -361,6 +399,8 @@ func resourceAciFunctionNodeCreate(ctx context.Context, d *schema.ResourceData,
vnsAbsFuncConnAttr := models.FunctionConnectorAttributes{}
vnsAbsFuncConnAttr.Annotation = "{}"
vnsAbsFuncConnAttr.DeviceLIfName = d.Get("l4_l7_device_interface_consumer_name").(string)
vnsAbsFuncConnAttr.AttNotify = d.Get("l4_l7_device_interface_consumer_att_notify").(string)
vnsAbsFuncConnAttr.ConnType = d.Get("l4_l7_device_interface_consumer_connector_type").(string)
vnsAbsFuncConn := models.NewFunctionConnector(fmt.Sprintf("AbsFConn-%s", "consumer"), vnsAbsNode.DistinguishedName, "", vnsAbsFuncConnAttr)
err = aciClient.Save(vnsAbsFuncConn)
if err != nil {
Expand All @@ -369,6 +409,8 @@ func resourceAciFunctionNodeCreate(ctx context.Context, d *schema.ResourceData,
d.Set("conn_consumer_dn", vnsAbsFuncConn.DistinguishedName)

vnsAbsFuncConnAttr.DeviceLIfName = d.Get("l4_l7_device_interface_provider_name").(string)
vnsAbsFuncConnAttr.AttNotify = d.Get("l4_l7_device_interface_provider_att_notify").(string)
vnsAbsFuncConnAttr.ConnType = d.Get("l4_l7_device_interface_provider_connector_type").(string)
vnsAbsFuncConn = models.NewFunctionConnector(fmt.Sprintf("AbsFConn-%s", "provider"), vnsAbsNode.DistinguishedName, "", vnsAbsFuncConnAttr)
err = aciClient.Save(vnsAbsFuncConn)
if err != nil {
Expand Down Expand Up @@ -509,6 +551,8 @@ func resourceAciFunctionNodeUpdate(ctx context.Context, d *schema.ResourceData,
vnsAbsFuncConnAttr := models.FunctionConnectorAttributes{}
vnsAbsFuncConnAttr.Annotation = "{}"
vnsAbsFuncConnAttr.DeviceLIfName = d.Get("l4_l7_device_interface_consumer_name").(string)
vnsAbsFuncConnAttr.AttNotify = d.Get("l4_l7_device_interface_consumer_att_notify").(string)
vnsAbsFuncConnAttr.ConnType = d.Get("l4_l7_device_interface_consumer_connector_type").(string)
vnsAbsFuncConn := models.NewFunctionConnector(fmt.Sprintf("AbsFConn-%s", "consumer"), vnsAbsNode.DistinguishedName, "", vnsAbsFuncConnAttr)
err = aciClient.Save(vnsAbsFuncConn)
if err != nil {
Expand All @@ -521,6 +565,8 @@ func resourceAciFunctionNodeUpdate(ctx context.Context, d *schema.ResourceData,
vnsAbsFuncConnAttr := models.FunctionConnectorAttributes{}
vnsAbsFuncConnAttr.Annotation = "{}"
vnsAbsFuncConnAttr.DeviceLIfName = d.Get("l4_l7_device_interface_provider_name").(string)
vnsAbsFuncConnAttr.AttNotify = d.Get("l4_l7_device_interface_provider_att_notify").(string)
vnsAbsFuncConnAttr.ConnType = d.Get("l4_l7_device_interface_provider_connector_type").(string)
vnsAbsFuncConn := models.NewFunctionConnector(fmt.Sprintf("AbsFConn-%s", "provider"), vnsAbsNode.DistinguishedName, "", vnsAbsFuncConnAttr)
err = aciClient.Save(vnsAbsFuncConn)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion docs/data-sources/cloud_l4_l7_native_load_balancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ data "aci_cloud_l4_l7_native_load_balancer" "example" {
* `trunking` - (Read-Only) For virtual devices, if a trunking port group is to be used. Type: String.
* `cloud_l4l7_load_balancer_type` - (Read-Only) Type of the Cloud L4-L7 Native Load Balancer object. Type: String.
* `relation_cloud_rs_ldev_to_cloud_subnet` - (Read-Only) Represents the relation to a Relation from Cloud LDev to Cloud Subnet (class cloudSubnet). Type: List.
* `aaa_domain_dn` - (Read-Only) Represents the relation to a Relation from AAA Domain to Cloud L4L7 Native Load Balancer (class aaaRbacAnnotation). Type: List.
* `aaa_domain_dn` - (Read-Only) Represents the relation to a Relation from AAA Domain to Cloud L4L7 Native Load Balancer (class aaaRbacAnnotation). Type: List.
* `static_ip_address` - (Read-Only) A list of unique Static IP Address of the Cloud L4-L7 Native Load Balancer object. Type: List.
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 11 additions & 11 deletions docs/data-sources/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ data "aci_connection" "check" {

## Argument Reference

- `l4_l7_service_graph_template_dn` - (Required) Distinguished name of parent L4-L7 Service Graph Template object.
- `name` - (Required) Name of Object connection.
- `l4_l7_service_graph_template_dn` - (Required) Distinguished name of parent L4-L7 Service Graph Template object. Type: String.
- `name` - (Required) Name of Object connection. Type: String.

## Attribute Reference

- `id` - Attribute id set to the Dn of the Connection.
- `adj_type` - Connector adjacency type.
- `annotation` - Annotation for object connection.
- `description` - Description for object connection.
- `conn_dir` - Connection direction for object connection.
- `conn_type` - Connection type for object connection.
- `direct_connect` - Direct connect for object connection.
- `name_alias` - Name alias for object connection.
- `unicast_route` - Unicast route for object connection.
- `id` - Attribute id set to the Dn of the Connection. Type: String.
- `adj_type` - Connector adjacency type. Type: String.
- `annotation` - Annotation for object connection. Type: String.
- `description` - Description for object connection. Type: String.
- `conn_dir` - Connection direction for object connection. Type: String.
- `conn_type` - Connection type for object connection. Type: String.
- `direct_connect` - Direct connect for object connection. Type: String.
- `name_alias` - Name alias for object connection. Type: String.
- `unicast_route` - Unicast route for object connection. Type: String.
2 changes: 1 addition & 1 deletion docs/resources/cloud_l4_l7_native_load_balancer.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ resource "aci_cloud_l4_l7_native_load_balancer" "example" {
* `cloud_l4l7_load_balancer_type` - (Optional) Type of the Cloud L4-L7 Native Load Balancer object. Allowed values are "application", "network", and default value is "application". Type: String.
* `relation_cloud_rs_ldev_to_cloud_subnet` - (Optional) Represents the relation to a Relation from Cloud LDev to Cloud Subnet (class cloudSubnet). Type: List.
* `aaa_domain_dn` - (Optional) Represents the relation to a Relation from AAA Domain to Cloud L4L7 Native Load Balancer (class aaaRbacAnnotation). Type: List.

* `static_ip_address` - (Optional) A list of unique Static IP Address of the Cloud L4-L7 Native Load Balancer object. Type: List.
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved

## Importing ##

Expand Down
27 changes: 13 additions & 14 deletions docs/resources/connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,24 @@ resource "aci_connection" "conn2" {

## Argument Reference

- `l4_l7_service_graph_template_dn` - (Required) Distinguished name of parent L4-L7 Service Graph Template object.
- `name` - (Required) Name of object connection.
- `adj_type` - (Optional) Connector adjacency type. Allowed values are "L2", "L3". Default value is "L2".
- `annotation` - (Optional) Annotation for object connection.
- `description` - (Optional) Description for object connection.
- `conn_dir` - (Optional) Connection directory for object connection. Allowed values are "consumer", "provider". Default value is "provider".
- `conn_type` - (Optional) Connection type of connection object. Allowed values are "external", "internal". Default value is "external".
- `direct_connect` - (Optional) Direct connect for object connection. Allowed values are "yes" and "no". Default value is "no".
- `name_alias` - (Optional) Name alias for object connection.
- `unicast_route` - (Optional) Unicast route for connection object. Unicast route setting should be true for L3 connections. Allowed values are "yes" and "no". Default value is "yes".

- `relation_vns_rs_abs_copy_connection` - (Optional) List of relation to class vnsAConn. Cardinality - ONE_TO_M. Type - Set of String.
- `relation_vns_rs_abs_connection_conns` - (Optional) list of relation to class vnsAConn. Cardinality - ONE_TO_M. Type - Set of String.
- `l4_l7_service_graph_template_dn` - (Required) Distinguished name of parent L4-L7 Service Graph Template object. Type: String.
- `name` - (Required) Name of object connection. The valid connection name format is `CONX`, where X is a number starting with 0. Type: String.
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved
anvitha-jain marked this conversation as resolved.
Show resolved Hide resolved
- `adj_type` - (Optional) Connector adjacency type. Allowed values are "L2", "L3". Default value is "L2". Type: String.
- `annotation` - (Optional) Annotation for object connection. Type: String.
- `description` - (Optional) Description for object connection. Type: String.
- `conn_dir` - (Optional) Connection directory for object connection. Allowed values are "consumer", "provider". Default value is "provider". Type: String.
- `conn_type` - (Optional) Connection type of connection object. Allowed values are "external", "internal". Default value is "external". Type: String.
- `direct_connect` - (Optional) Direct connect for object connection. Allowed values are "yes" and "no". Default value is "no". Type: String.
- `name_alias` - (Optional) Name alias for object connection. Type: String.
- `unicast_route` - (Optional) Unicast route for connection object. Unicast route setting should be true for L3 connections. Allowed values are "yes" and "no". Default value is "yes". Type: String.

- `relation_vns_rs_abs_copy_connection` - (Optional) A list of relation to class vnsAConn. Cardinality - ONE_TO_M. Type: List.
- `relation_vns_rs_abs_connection_conns` - (Optional) A list of relation to class vnsAConn. Cardinality - ONE_TO_M. Type: List.

## Attribute Reference

The only attribute that this resource exports is the `id`, which is set to the
Dn of the Connection.

## Importing

An existing Connection can be [imported][docs-import] into this resource via its Dn, via the following command:
Expand Down
Loading