-
Notifications
You must be signed in to change notification settings - Fork 4
/
datasource_link_aggregation_groups.go
213 lines (208 loc) · 5.9 KB
/
datasource_link_aggregation_groups.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package provider
import (
"context"
"github.com/PacketFabric/terraform-provider-packetfabric/internal/packetfabric"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func datasourceLinkAggregationGroups() *schema.Resource {
return &schema.Resource{
ReadContext: datasourceLinkAggregationGroupsRead,
Schema: map[string]*schema.Schema{
"lag_circuit_id": {
Type: schema.TypeString,
Required: true,
Description: "ID of a LAG.",
},
"interfaces": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"autoneg": {
Type: schema.TypeBool,
Computed: true,
Description: "TRUE when Interface Autoneg is enabled.",
},
"port_circuit_id": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Circuit ID.",
},
"state": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port State.",
},
"status": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Status.",
},
"speed": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Speed.",
},
"media": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Media type.",
},
"zone": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Zone.",
},
"region": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Region.",
},
"market": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Market.",
},
"market_description": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Market description.",
},
"pop": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port POP.",
},
"site": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Site.",
},
"site_code": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Site code.",
},
"operational_status": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Operational status.",
},
"admin_status": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Admin status.",
},
"mtu": {
Type: schema.TypeInt,
Computed: true,
Description: "Interface Port MTU.",
},
"description": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Description.",
},
"vc_mode": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port VC Mode.",
},
"is_lag": {
Type: schema.TypeBool,
Computed: true,
Description: "TRUE when Interface Port is LAG.",
},
"is_lag_member": {
Type: schema.TypeBool,
Computed: true,
Description: "TRUE when Interface Port is LAG member.",
},
"is_cloud": {
Type: schema.TypeBool,
Computed: true,
Description: "TRUE when Interface Port is Cloud.",
},
"is_ptp": {
Type: schema.TypeBool,
Computed: true,
Description: "TRUE when Interface Port is Point to Point.",
},
"is_nni": {
Type: schema.TypeBool,
Computed: true,
Description: "TRUE when Interface Port is NNI.",
},
"lag_interval": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port LAG interval.",
},
"member_count": {
Type: schema.TypeInt,
Computed: true,
Description: "Interface Port Member Count.",
},
"parent_lag_circuit_id": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Parent LAG Circuit ID.",
},
"account_uuid": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Account UUID.",
},
"subscription_term": {
Type: schema.TypeInt,
Computed: true,
Description: "Interface Port Subscription term.",
},
"disabled": {
Type: schema.TypeBool,
Computed: true,
Description: "TRUE when Interface Port is diabled.",
},
"customer_name": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Customer name.",
},
"customer_uuid": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port Customer UUID.",
},
"time_created": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port time created.",
},
"time_updated": {
Type: schema.TypeString,
Computed: true,
Description: "Interface Port time updated.",
},
},
},
},
},
}
}
func datasourceLinkAggregationGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*packetfabric.PFClient)
c.Ctx = ctx
var diags diag.Diagnostics
lagID := d.Get("lag_circuit_id")
interfs, err := c.GetLAGInterfaces(lagID.(string))
if err != nil {
return diag.FromErr(err)
}
err = d.Set("interfaces", flattenInterfaces(interfs))
if err != nil {
return diag.FromErr(err)
}
d.SetId(lagID.(string) + "-data")
return diags
}