-
Notifications
You must be signed in to change notification settings - Fork 98
/
data_source_aci_infraspineaccnodepgrp.go
117 lines (105 loc) · 4.44 KB
/
data_source_aci_infraspineaccnodepgrp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package aci
import (
"context"
"fmt"
"log"
"github.com/ciscoecosystem/aci-go-client/v2/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func dataSourceAciSpineSwitchPolicyGroup() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceAciSpineSwitchPolicyGroupRead,
SchemaVersion: 1,
Schema: AppendBaseAttrSchema(AppendNameAliasAttrSchema(map[string]*schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
"relation_infra_rs_iacl_spine_profile": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"relation_infra_rs_spine_bfd_ipv4_inst_pol": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"relation_infra_rs_spine_bfd_ipv6_inst_pol": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"relation_infra_rs_spine_copp_profile": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"relation_infra_rs_spine_p_grp_to_cdp_if_pol": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"relation_infra_rs_spine_p_grp_to_lldp_if_pol": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
})),
}
}
func dataSourceAciSpineSwitchPolicyGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
aciClient := m.(*client.Client)
name := d.Get("name").(string)
rn := fmt.Sprintf("infra/funcprof/spaccnodepgrp-%s", name)
dn := fmt.Sprintf("uni/%s", rn)
log.Printf("[DEBUG] %s: Data Source - Beginning Read", dn)
infraSpineAccNodePGrp, err := getRemoteSpineSwitchPolicyGroup(aciClient, dn)
if err != nil {
return diag.FromErr(err)
}
d.SetId(dn)
_, err = setSpineSwitchPolicyGroupAttributes(infraSpineAccNodePGrp, d)
if err != nil {
return diag.FromErr(err)
}
// infraRsIaclSpineProfile - Beginning Read
log.Printf("[DEBUG] %s: infraRsIaclSpineProfile - Beginning Read with parent DN", dn)
_, err = getAndSetReadRelationinfraRsIaclSpineProfile(aciClient, dn, d)
if err == nil {
log.Printf("[DEBUG] %s: infraRsIaclSpineProfile - Read finished successfully", d.Get("relation_infra_rs_iacl_spine_profile"))
}
// infraRsIaclSpineProfile - Read finished successfully
// infraRsSpineBfdIpv4InstPol - Beginning Read
log.Printf("[DEBUG] %s: infraRsSpineBfdIpv4InstPol - Beginning Read with parent DN", dn)
_, err = getAndSetReadRelationinfraRsSpineBfdIpv4InstPol(aciClient, dn, d)
if err == nil {
log.Printf("[DEBUG] %s: infraRsSpineBfdIpv4InstPol - Read finished successfully", d.Get("relation_infra_rs_spine_bfd_ipv4_inst_pol"))
}
// infraRsSpineBfdIpv4InstPol - Read finished successfully
// infraRsSpineBfdIpv6InstPol - Beginning Read
log.Printf("[DEBUG] %s: infraRsSpineBfdIpv6InstPol - Beginning Read with parent DN", dn)
_, err = getAndSetReadRelationinfraRsSpineBfdIpv6InstPol(aciClient, dn, d)
if err == nil {
log.Printf("[DEBUG] %s: infraRsSpineBfdIpv6InstPol - Read finished successfully", d.Get("relation_infra_rs_spine_bfd_ipv6_inst_pol"))
}
// infraRsSpineBfdIpv6InstPol - Read finished successfully
// infraRsSpineCoppProfile - Beginning Read
log.Printf("[DEBUG] %s: infraRsSpineCoppProfile - Beginning Read with parent DN", dn)
_, err = getAndSetReadRelationinfraRsSpineCoppProfile(aciClient, dn, d)
if err == nil {
log.Printf("[DEBUG] %s: infraRsSpineCoppProfile - Read finished successfully", d.Get("relation_infra_rs_spine_copp_profile"))
}
// infraRsSpineCoppProfile - Read finished successfully
// infraRsSpinePGrpToCdpIfPol - Beginning Read
log.Printf("[DEBUG] %s: infraRsSpinePGrpToCdpIfPol - Beginning Read with parent DN", dn)
_, err = getAndSetReadRelationinfraRsSpinePGrpToCdpIfPol(aciClient, dn, d)
if err == nil {
log.Printf("[DEBUG] %s: infraRsSpinePGrpToCdpIfPol - Read finished successfully", d.Get("relation_infra_rs_spine_p_grp_to_cdp_if_pol"))
}
// infraRsSpinePGrpToCdpIfPol - Read finished successfully
// infraRsSpinePGrpToLldpIfPol - Beginning Read
log.Printf("[DEBUG] %s: infraRsSpinePGrpToLldpIfPol - Beginning Read with parent DN", dn)
_, err = getAndSetReadRelationinfraRsSpinePGrpToLldpIfPol(aciClient, dn, d)
if err == nil {
log.Printf("[DEBUG] %s: infraRsSpinePGrpToLldpIfPol - Read finished successfully", d.Get("relation_infra_rs_spine_p_grp_to_lldp_if_pol"))
}
// infraRsSpinePGrpToLldpIfPol - Read finished successfully
log.Printf("[DEBUG] %s: Data Source - Read finished successfully", dn)
return nil
}