-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsan_connectivity.tf
210 lines (206 loc) · 9.93 KB
/
san_connectivity.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
#__________________________________________________________________
#
# Intersight SAN Connectivity Policy
# GUI Location: Policies > Create Policy > SAN Connectivity
#__________________________________________________________________
resource "intersight_vnic_san_connectivity_policy" "map" {
for_each = local.san_connectivity
description = coalesce(each.value.description, "${each.value.name} SAN Connectivity Policy.")
name = each.value.name
placement_mode = each.value.vhba_placement_mode
static_wwnn_address = each.value.wwnn_static_address
target_platform = each.value.target_platform
wwnn_address_type = length(compact([each.value.wwnn_static_address])) > 0 ? "STATIC" : "POOL"
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
}
}
dynamic "wwnn_pool" {
for_each = { for v in [each.value.wwnn_pool] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.pools.wwnn.moids), wwnn_pool.value
) == true ? local.pools.wwnn.moids[wwnn_pool.value] : local.pools_data["wwnn"][wwnn_pool.value].moid
object_type = "fcpool.Pool"
}
}
}
#_________________________________________________________________________
#
# vHBA Template(s)
# GUI Location: Templates > vHBA Templates > Create vHBA Template
#_________________________________________________________________________
resource "intersight_vnic_vhba_template" "map" {
depends_on = [
intersight_fabric_fc_zone_policy.map,
intersight_vnic_fc_adapter_policy.map,
intersight_vnic_fc_network_policy.map,
intersight_vnic_fc_qos_policy.map
]
for_each = local.vhba_template
enable_override = each.value.allow_override
name = each.value.name
persistent_bindings = each.value.persistent_lun_bindings
pin_group_name = each.value.pin_group_name
switch_id = each.value.placement_switch_id
type = each.value.vhba_type
organization { moid = var.orgs[each.value.org] }
fc_adapter_policy {
moid = contains(keys(local.fibre_channel_adapter), each.value.fibre_channel_adapter_policy
) == true ? intersight_vnic_fc_adapter_policy.map[each.value.fibre_channel_adapter_policy
].moid : local.policies_data["fibre_channel_adapter"][each.value.fibre_channel_adapter_policy].moid
}
fc_network_policy {
moid = contains(keys(local.fibre_channel_network), each.value.fibre_channel_network_policy
) == true ? intersight_vnic_fc_network_policy.map[each.value.fibre_channel_network_policy
].moid : local.policies_data["fibre_channel_network"][each.value.fibre_channel_network_policy].moid
}
fc_qos_policy {
moid = contains(keys(local.fibre_channel_qos), each.value.fibre_channel_qos_policy) == true ? intersight_vnic_fc_qos_policy.map[each.value.fibre_channel_qos_policy
].moid : local.policies_data["fibre_channel_qos"][each.value.fibre_channel_qos_policy].moid
}
dynamic "fc_zone_policies" {
for_each = { for v in each.value.fc_zone_policies : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.fc_zone), fc_zone_policies.value) == true ? intersight_fabric_fc_zone_policy.map[fc_zone_policies.value
].moid : local.policies_data["fc_zone"][fc_zone_policies.value].moid
}
}
dynamic "wwpn_pool" {
for_each = { for v in [each.value.wwpn_pool] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.pools.wwpn.moids), wwpn_pool.value
) == true ? local.pools.wwpn.moids[wwpn_pool.value] : local.pools_data["wwpn_pool"][wwpn_pool.value].moid
object_type = "fcpool.Pool"
}
}
}
#_________________________________________________________________________
#
# SAN Connectivity Policy - Add vHBA
# GUI Location: Configure > Policies > Create Policy > SAN Connectivity
#_________________________________________________________________________
resource "intersight_vnic_fc_if" "map" {
depends_on = [
intersight_fabric_fc_zone_policy.map,
intersight_vnic_fc_adapter_policy.map,
intersight_vnic_fc_network_policy.map,
intersight_vnic_fc_qos_policy.map,
intersight_vnic_san_connectivity_policy.map
]
for_each = local.vhbas
name = each.value.name
order = each.value.placement.pci_order
persistent_bindings = each.value.persistent_lun_bindings
pin_group_name = each.value.pin_group_name
static_wwpn_address = each.value.wwpn_static_address
type = each.value.vhba_type
wwpn_address_type = length(compact([each.value.wwpn_static_address])) > 0 ? "STATIC" : "POOL"
fc_adapter_policy {
moid = contains(keys(local.fibre_channel_adapter), each.value.fibre_channel_adapter_policy
) == true ? intersight_vnic_fc_adapter_policy.map[each.value.fibre_channel_adapter_policy
].moid : local.policies_data["fibre_channel_adapter"][each.value.fibre_channel_adapter_policy].moid
}
fc_network_policy {
moid = contains(keys(local.fibre_channel_network), each.value.fibre_channel_network_policy
) == true ? intersight_vnic_fc_network_policy.map[each.value.fibre_channel_network_policy
].moid : local.policies_data["fibre_channel_network"][each.value.fibre_channel_network_policy].moid
}
fc_qos_policy {
moid = contains(keys(local.fibre_channel_qos), each.value.fibre_channel_qos_policy) == true ? intersight_vnic_fc_qos_policy.map[each.value.fibre_channel_qos_policy
].moid : local.policies_data["fibre_channel_qos"][each.value.fibre_channel_qos_policy].moid
}
san_connectivity_policy {
moid = intersight_vnic_san_connectivity_policy.map[each.value.san_connectivity].moid
}
placement {
auto_pci_link = each.value.placement.automatic_pci_link_assignment
auto_slot_id = each.value.placement.automatic_slot_id_assignment
id = each.value.placement.slot_id
pci_link = each.value.placement.pci_link
switch_id = each.value.placement.switch_id
uplink = each.value.placement.uplink_port
}
dynamic "fc_zone_policies" {
for_each = { for v in each.value.fc_zone_policies : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.fc_zone), fc_zone_policies.value) == true ? intersight_fabric_fc_zone_policy.map[fc_zone_policies.value
].moid : local.policies_data["fc_zone"][fc_zone_policies.value].moid
}
}
dynamic "wwpn_pool" {
for_each = { for v in [each.value.wwpn_pool] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.pools.wwpn.moids), wwpn_pool.value
) == true ? local.pools.wwpn.moids[wwpn_pool.value] : local.pools_data["wwpn"][wwpn_pool.value].moid
object_type = "fcpool.Pool"
}
}
}
#_________________________________________________________________________
#
# SAN Connectivity Policy - Add vHBA from Template
# GUI Location: Configure > Policies > Create Policy > SAN Connectivity
#_________________________________________________________________________
resource "intersight_vnic_fc_if" "from_template" {
depends_on = [
intersight_fabric_fc_zone_policy.map,
intersight_vnic_fc_adapter_policy.map,
intersight_vnic_fc_network_policy.map,
intersight_vnic_fc_qos_policy.map,
intersight_vnic_san_connectivity_policy.map
]
for_each = local.vhbas_from_template
name = each.value.name
order = each.value.placement.pci_order
pin_group_name = each.value.pin_group_name
static_wwpn_address = each.value.wwpn_static_address
wwpn_address_type = length(compact([each.value.wwpn_static_address])) > 0 ? "STATIC" : "POOL"
san_connectivity_policy {
moid = intersight_vnic_san_connectivity_policy.map[each.value.san_connectivity].moid
}
placement {
auto_pci_link = each.value.placement.automatic_pci_link_assignment
auto_slot_id = each.value.placement.automatic_slot_id_assignment
id = each.value.placement.slot_id
pci_link = each.value.placement.pci_link
switch_id = each.value.placement.switch_id
uplink = each.value.placement.uplink_port
}
src_template {
moid = contains(keys(local.vhba_template), each.value.vhba_template) == true ? intersight_vnic_vhba_template.map[each.value.vhba_template
].moid : local.data_vhba_template[each.value.vhba_template].moid
}
dynamic "fc_adapter_policy" {
for_each = { for v in each.value.fibre_channel_adapter : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.fibre_channel_adapter), intersight_vnic_fc_adapter_policy.value) == true ? intersight_fabric_fc_zone_policy.map[fc_adapter_policy.value
].moid : local.policies_data["fibre_channel_adapter"][fc_adapter_policy.value].moid
}
}
dynamic "fc_network_policy" {
for_each = { for v in each.value.fibre_channel_network : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.fibre_channel_network), intersight_vnic_fc_network_policy.value) == true ? fc_network_policy.map[fc_adapter_policy.value
].moid : local.policies_data["fibre_channel_network"][fc_network_policy.value].moid
}
}
dynamic "fc_zone_policies" {
for_each = { for v in each.value.fc_zone_policies : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.fc_zone), fc_zone_policies.value) == true ? intersight_fabric_fc_zone_policy.map[fc_zone_policies.value
].moid : local.policies_data["fc_zone"][fc_zone_policies.value].moid
}
}
dynamic "wwpn_pool" {
for_each = { for v in [each.value.wwpn_pool] : v => v if element(split("/", v), 1) != "UNUSED" }
content {
moid = contains(keys(local.pools.wwpn.moids), wwpn_pool.value
) == true ? local.pools.wwpn.moids[wwpn_pool.value] : local.pools_data["wwpn"][wwpn_pool.value].moid
object_type = "fcpool.Pool"
}
}
}