-
Notifications
You must be signed in to change notification settings - Fork 0
/
port.tf
492 lines (459 loc) · 20.3 KB
/
port.tf
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
#__________________________________________________________________
#
# Intersight Port Policy
# GUI Location: Policies > Create Policy > Port
#__________________________________________________________________
resource "intersight_fabric_port_policy" "map" {
depends_on = [
intersight_fabric_eth_network_control_policy.map,
intersight_fabric_eth_network_group_policy.map,
intersight_fabric_flow_control_policy.map,
intersight_fabric_link_aggregation_policy.map,
intersight_fabric_link_control_policy.map
]
for_each = local.port
description = coalesce(each.value.description, "${each.value.name} Port Policy.")
device_model = each.value.device_model
name = each.value.name
organization { moid = var.orgs[each.value.org] }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#________________________________________________________________________________________________
#
# Intersight Port Policy - Port Role - Appliance
# GUI Location: Policies > Create Policy > Port > Port Roles > Configure > Port Role - Appliance
#________________________________________________________________________________________________
resource "intersight_fabric_appliance_pc_role" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_channel_appliances
admin_speed = each.value.admin_speed
# fec = each.value.fec
mode = each.value.mode
pc_id = each.value.pc_id
priority = each.value.priority
eth_network_control_policy {
moid = contains(keys(local.ethernet_network_control), each.value.ethernet_network_control_policy
) == true ? intersight_fabric_eth_network_control_policy.map[each.value.ethernet_network_control_policy
].moid : local.policies_data["ethernet_network_control"][each.value.ethernet_network_control_policy].moid
}
eth_network_group_policy {
moid = contains(keys(local.ethernet_network_group), each.value.ethernet_network_group_policy
) == true ? intersight_fabric_eth_network_group_policy.map[each.value.ethernet_network_group_policy
].moid : local.policies_data["ethernet_network_group"][each.value.ethernet_network_group_policy].moid
}
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "link_aggregation_policy" {
for_each = { for v in [each.value.link_aggregation_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.link_aggregation), link_aggregation_policy.value) == true ? intersight_fabric_link_aggregation_policy.map[link_aggregation_policy.value
].moid : local.policies_data["link_aggregation"][link_aggregation_policy.value].moid
}
}
dynamic "ports" {
for_each = each.value.interfaces
content {
aggregate_port_id = lookup(ports.value, "breakout_port_id", 0)
port_id = ports.value.port_id
slot_id = lookup(ports.value, "slot_id", 1)
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#______________________________________________________________________________________________________________________
#
# Intersight Port Policy - Ethernet Uplink Port Channel
# GUI Location: Policies > Create Policy > Port > Port Channels > Create a Port Channel > Ethernet Uplink Port Channel
#______________________________________________________________________________________________________________________
resource "intersight_fabric_uplink_pc_role" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_channel_ethernet_uplinks
admin_speed = each.value.admin_speed
# fec = each.value.fec
pc_id = each.value.pc_id
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "eth_network_group_policy" {
for_each = { for v in [each.value.ethernet_network_group_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.ethernet_network_group), eth_network_group_policy.value
) == true ? intersight_fabric_eth_network_group_policy.map[eth_network_group_policy.value
].moid : local.policies_data["ethernet_network_group"][eth_network_group_policy.value].moid
}
}
dynamic "flow_control_policy" {
for_each = { for v in [each.value.flow_control_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.flow_control), flow_control_policy.value) == true ? intersight_fabric_flow_control_policy.map[flow_control_policy.value
].moid : local.policies_data["flow_control"][flow_control_policy.value].moid
}
}
dynamic "link_aggregation_policy" {
for_each = { for v in [each.value.link_aggregation_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.link_aggregation), link_aggregation_policy.value) == true ? intersight_fabric_link_aggregation_policy.map[link_aggregation_policy.value
].moid : local.policies_data["link_aggregation"][link_aggregation_policy.value].moid
}
}
dynamic "link_control_policy" {
for_each = { for v in [each.value.link_control_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.link_control), link_control_policy.value) == true ? intersight_fabric_link_control_policy.map[link_control_policy.value
].moid : local.policies_data["link_control"][link_control_policy.value].moid
}
}
dynamic "ports" {
for_each = each.value.interfaces
content {
aggregate_port_id = lookup(ports.value, "breakout_port_id", 0)
port_id = ports.value.port_id
slot_id = lookup(ports.value, "slot_id", 1)
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#________________________________________________________________________________________________________________
#
# Intersight Port Policy - FC Uplink Port Channel
# GUI Location: Policies > Create Policy > Port > Port Channels > Create a Port Channel > FC Uplink Port Channel
#________________________________________________________________________________________________________________
resource "intersight_fabric_fc_uplink_pc_role" "map" {
depends_on = [
intersight_fabric_port_policy.map,
intersight_fabric_port_mode.map
]
for_each = local.port_channel_fc_uplinks
admin_speed = each.value.admin_speed
pc_id = each.value.pc_id
vsan_id = each.value.vsan_id
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "ports" {
for_each = each.value.interfaces
content {
aggregate_port_id = lookup(ports.value, "breakout_port_id", 0)
port_id = ports.value.port_id
slot_id = lookup(ports.value, "slot_id", 1)
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#______________________________________________________________________________________________________________________
#
# Intersight Port Policy - FCoE Uplink Port Channel
# GUI Location: Policies > Create Policy > Port > Port Channels > Create a Port Channel > FCoE Uplink Port Channel
#______________________________________________________________________________________________________________________
resource "intersight_fabric_fcoe_uplink_pc_role" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_channel_fcoe_uplinks
admin_speed = each.value.admin_speed
# fec = each.value.fec
pc_id = each.value.pc_id
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "link_aggregation_policy" {
for_each = { for v in [each.value.link_aggregation_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.link_aggregation), link_aggregation_policy.value) == true ? intersight_fabric_link_aggregation_policy.map[link_aggregation_policy.value
].moid : local.policies_data["link_aggregation"][link_aggregation_policy.value].moid
}
}
dynamic "link_control_policy" {
for_each = { for v in [each.value.link_control_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.link_control), link_control_policy.value) == true ? intersight_fabric_link_control_policy.map[link_control_policy.value
].moid : local.policies_data["link_control"][link_control_policy.value].moid
}
}
dynamic "ports" {
for_each = each.value.interfaces
content {
aggregate_port_id = lookup(ports.value, "breakout_port_id", 0)
port_id = ports.value.port_id
slot_id = lookup(ports.value, "slot_id", 1)
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#__________________________________________________________________
#
# Intersight Port Policy - Move the Slider for Port mode
# GUI Location: Policies > Create Policy > Port > Move the Slider
#__________________________________________________________________
resource "intersight_fabric_port_mode" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_modes
custom_mode = each.value.custom_mode
port_id_end = element(each.value.port_list, 1)
port_id_start = element(each.value.port_list, 0)
slot_id = lookup(each.value, "slot_id", 1)
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#________________________________________________________________________________________________
#
# Intersight Port Policy - Port Role - Appliance
# GUI Location: Policies > Create Policy > Port > Port Roles > Configure > Port Role - Appliance
#________________________________________________________________________________________________
resource "intersight_fabric_appliance_role" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_role_appliances
admin_speed = each.value.admin_speed
aggregate_port_id = lookup(each.value, "breakout_port_id", 0)
fec = each.value.fec
mode = each.value.mode
port_id = each.value.port_id
priority = each.value.priority
slot_id = lookup(each.value, "slot_id", 1)
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
eth_network_control_policy {
moid = contains(keys(local.ethernet_network_control), each.value.ethernet_network_control_policy
) == true ? intersight_fabric_eth_network_control_policy.map[each.value.ethernet_network_control_policy
].moid : local.policies_data["ethernet_network_control"][each.value.ethernet_network_control_policy].moid
}
eth_network_group_policy {
moid = contains(keys(local.ethernet_network_group), each.value.ethernet_network_group_policy
) == true ? intersight_fabric_eth_network_group_policy.map[each.value.ethernet_network_group_policy
].moid : local.policies_data["ethernet_network_group"][each.value.ethernet_network_group_policy].moid
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#__________________________________________________________________________________________
#
# Intersight Port Policy - Ethernet Uplink
# GUI Location: Policies > Create Policy > Port > Port Roles > Configure > Ethernet Uplink
#__________________________________________________________________________________________
resource "intersight_fabric_uplink_role" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_role_ethernet_uplinks
admin_speed = each.value.admin_speed
aggregate_port_id = lookup(each.value, "breakout_port_id", 0)
fec = each.value.fec
port_id = each.value.port_id
slot_id = lookup(each.value, "slot_id", 1)
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "eth_network_group_policy" {
for_each = { for v in [each.value.ethernet_network_group_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.ethernet_network_group), eth_network_group_policy.value
) == true ? intersight_fabric_eth_network_group_policy.map[eth_network_group_policy.value
].moid : local.policies_data["ethernet_network_group"][eth_network_group_policy.value].moid
}
}
dynamic "flow_control_policy" {
for_each = { for v in [each.value.flow_control_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.flow_control), flow_control_policy.value) == true ? intersight_fabric_flow_control_policy.map[flow_control_policy.value
].moid : local.policies_data["flow_control"][flow_control_policy.value].moid
}
}
dynamic "link_control_policy" {
for_each = { for v in [each.value.link_control_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.link_control), link_control_policy.value) == true ? intersight_fabric_link_control_policy.map[link_control_policy.value
].moid : local.policies_data["link_control"][link_control_policy.value].moid
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#________________________________________________________________________
#
# Intersight Port Policy - FC Uplink
# GUI Location: Policies > Create Policy > Port > Port Roles > FC Uplink
#________________________________________________________________________
resource "intersight_fabric_fc_storage_role" "map" {
depends_on = [
intersight_fabric_port_policy.map,
intersight_fabric_port_mode.map
]
for_each = local.port_role_fc_storage
admin_speed = each.value.admin_speed
aggregate_port_id = lookup(each.value, "breakout_port_id", 0)
port_id = each.value.port_id
slot_id = lookup(each.value, "slot_id", 1)
vsan_id = each.value.vsan_id
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#________________________________________________________________________
#
# Intersight Port Policy - FC Uplink
# GUI Location: Policies > Create Policy > Port > Port Roles > FC Uplink
#________________________________________________________________________
resource "intersight_fabric_fc_uplink_role" "map" {
depends_on = [
intersight_fabric_port_policy.map,
intersight_fabric_port_mode.map
]
for_each = local.port_role_fc_uplinks
admin_speed = each.value.admin_speed
aggregate_port_id = lookup(each.value, "breakout_port_id", 0)
port_id = each.value.port_id
slot_id = lookup(each.value, "slot_id", 1)
vsan_id = each.value.vsan_id
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#__________________________________________________________________________________________
#
# Intersight Port Policy - Ethernet Uplink
# GUI Location: Policies > Create Policy > Port > Port Roles > Configure > Ethernet Uplink
#__________________________________________________________________________________________
resource "intersight_fabric_fcoe_uplink_role" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_role_fcoe_uplinks
admin_speed = each.value.admin_speed
aggregate_port_id = lookup(each.value, "breakout_port_id", 0)
fec = each.value.fec
port_id = each.value.port_id
slot_id = lookup(each.value, "slot_id", 1)
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "link_control_policy" {
for_each = { for v in [each.value.link_control_policy] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.link_control), link_control_policy.value) == true ? intersight_fabric_link_control_policy.map[link_control_policy.value
].moid : local.policies_data["link_control"][link_control_policy.value].moid
}
}
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
#_____________________________________________________________________
#
# Intersight Port Policy - Server Ports
# GUI Location: Policies > Create Policy > Port > Port Roles > Server
#_____________________________________________________________________
resource "intersight_fabric_server_role" "map" {
depends_on = [intersight_fabric_port_policy.map]
for_each = local.port_role_servers
aggregate_port_id = lookup(each.value, "breakout_port_id", 0)
auto_negotiation_disabled = lookup(each.value, "auto_negotiation", false)
fec = lookup(each.value, "fec", "Auto") # Auto, Cl74, Cl91
port_id = each.value.port_id
preferred_device_id = lookup(each.value, "device_number", null)
preferred_device_type = lookup(each.value, "connected_device_type", "Auto") # Chassis, RackServer
slot_id = lookup(each.value, "slot_id", 1)
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
resource "intersight_fabric_lan_pin_group" "map" {
depends_on = [
intersight_fabric_port_policy.map,
intersight_fabric_uplink_pc_role.map,
intersight_fabric_fc_uplink_pc_role.map,
intersight_fabric_uplink_role.map,
intersight_fabric_fc_storage_role.map,
intersight_fabric_fc_uplink_role.map
]
for_each = { for k, v in local.port_pin_groups : k => v if v.pin_group_type == "lan" }
name = each.value.pin_group_name
dynamic "pin_target_interface_role" {
for_each = { for v in [0] : v => v if each.value.enabled == true }
content {
moid = local.pin_group_maps[each.value.interface_type].moids[each.value.policy_name]
object_type = local.pin_group_maps[each.value.interface_type].object
}
}
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}
resource "intersight_fabric_san_pin_group" "map" {
depends_on = [
intersight_fabric_port_policy.map,
intersight_fabric_uplink_pc_role.map,
intersight_fabric_fc_uplink_pc_role.map,
intersight_fabric_uplink_role.map,
intersight_fabric_fc_storage_role.map,
intersight_fabric_fc_uplink_role.map
]
for_each = { for k, v in local.port_pin_groups : k => v if v.pin_group_type == "san" }
name = each.value.pin_group_name
dynamic "pin_target_interface_role" {
for_each = { for v in [0] : v => v if each.value.enabled == true }
content {
moid = local.pin_group_maps[each.value.interface_type].moids[each.value.policy_name]
object_type = local.pin_group_maps[each.value.interface_type].object
}
}
port_policy { moid = intersight_fabric_port_policy.map[each.value.port_policy].moid }
dynamic "tags" {
for_each = { for v in each.value.tags : v.key => v }
content {
key = tags.value.key
value = tags.value.value
}
}
}