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 8 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_addresses": &schema.Schema{
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
Set: schema.HashString,
},
}),
}
}
Expand Down
48 changes: 32 additions & 16 deletions aci/data_source_aci_vnsabsnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ func dataSourceAciFunctionNode() *schema.Resource {
Type: schema.TypeString,
Required: true,
},
"l4_l7_device_interface_consumer_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_provider_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"annotation": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -65,14 +57,6 @@ func dataSourceAciFunctionNode() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"conn_consumer_dn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"conn_provider_dn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"share_encap": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Expand All @@ -97,6 +81,38 @@ func dataSourceAciFunctionNode() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_consumer_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"conn_consumer_dn": &schema.Schema{
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_consumer_attachment_notification": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_provider_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"conn_provider_dn": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_provider_connector_type": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
"l4_l7_device_interface_provider_attachment_notification": &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_addresses": &schema.Schema{
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_addresses", 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_addresses"); 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_addresses") {
oldRel, newRel := d.GetChange("static_ip_addresses")
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
114 changes: 76 additions & 38 deletions aci/resource_aci_vnsabsnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,16 @@ func resourceAciFunctionNode() *schema.Resource {
Required: true,
ForceNew: true,
},

"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"l4_l7_device_interface_consumer_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"l4_l7_device_interface_provider_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"annotation": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"func_template_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand All @@ -69,7 +57,6 @@ func resourceAciFunctionNode() *schema.Resource {
"ADC_ONE_ARM",
}, false),
},

"func_type": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -118,25 +105,11 @@ func resourceAciFunctionNode() *schema.Resource {
"unspecified",
}, false),
},

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

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

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

"share_encap": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand All @@ -146,31 +119,84 @@ func resourceAciFunctionNode() *schema.Resource {
"no",
}, false),
},

"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_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"conn_consumer_dn": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: 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_consumer_attachment_notification": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"no",
"yes",
}, false),
},
"l4_l7_device_interface_provider_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"conn_provider_dn": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"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_provider_attachment_notification": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"no",
"yes",
}, false),
},
}),
}
Expand Down Expand Up @@ -231,6 +257,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_attachment_notification", vnsAbsFuncConn.AttNotify)

// Provider Part
provDn := fmt.Sprintf("%s/AbsFConn-provider", dn)
Expand All @@ -244,6 +272,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_attachment_notification", vnsAbsFuncConn.AttNotify)

vnsRsNodeToAbsFuncProfData, err := client.ReadRelationvnsRsNodeToAbsFuncProfFromFunctionNode(dn)
if err != nil {
Expand Down Expand Up @@ -361,6 +391,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_attachment_notification").(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 +401,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_attachment_notification").(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 +543,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_attachment_notification").(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 +557,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_attachment_notification").(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
Loading