Skip to content

Commit 66962c1

Browse files
committed
Adding fc_zone_policies
1 parent 7dca377 commit 66962c1

File tree

5 files changed

+121
-5
lines changed

5 files changed

+121
-5
lines changed

modules/policies/README.md

Lines changed: 4 additions & 2 deletions
Large diffs are not rendered by default.

modules/policies/fc_zone_policies.tf

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#_________________________________________________________________________
2+
#
3+
# FC Zone Policies
4+
# GUI Location: Configure > Policies > Create Policy > FC Zone
5+
#_________________________________________________________________________
6+
7+
variable "fc_zone_policies" {
8+
default = {
9+
default = {
10+
description = ""
11+
fc_target_zoning_type = "None"
12+
tags = []
13+
targets = []
14+
/* Example FC Target
15+
targets = [
16+
{
17+
name = "example"
18+
switch_id = "A"
19+
vsan_id = 100
20+
wwpn = "20:00:00:25:B5:0A:00:00"
21+
}
22+
] */
23+
}
24+
}
25+
description = <<-EOT
26+
key - Name of the FC Zoning Policy
27+
* description - Description for the Policy.
28+
* fc_target_zoning_type - Default is "None". Type of FC zoning. Allowed values are SIST, SIMT and None.
29+
- None - FC zoning is not configured.
30+
- SIMT - The system automatically creates one zone for each vHBA. Configure this type of zoning if the number of zones created is likely to exceed the maximum supported number of zones.
31+
- SIST - The system automatically creates one zone for each vHBA and storage port pair. Each zone has two members.
32+
* tags - Default is []. List of Key/Value Pairs to Assign as Attributes to the Policy.
33+
* targets - Default is []. A List of FC Target Details to assign to the Policy
34+
- name - Name given to the target member.
35+
- Gold
36+
- switch_id - Unique identifier for the Fabric object.
37+
* A - Switch Identifier of Fabric Interconnect A.
38+
* B - Switch Identifier of Fabric Interconnect B.
39+
- vsan_id - VSAN with scope defined as Storage in the VSAN policy.
40+
- wwpn - WWPN that is a member of the FC zone.
41+
EOT
42+
type = map(object(
43+
{
44+
description = optional(string)
45+
fc_target_zoning_type = optional(string)
46+
tags = optional(list(map(string)))
47+
targets = list(object(
48+
{
49+
name = string
50+
switch_id = string
51+
vsan_id = number
52+
wwpn = string
53+
}
54+
))
55+
}
56+
))
57+
}
58+
59+
#_______________________________________________________________________________
60+
#
61+
# FC Zone Policies
62+
# GUI Location: Configure > Policies > Create Policy > FC Zone
63+
#_______________________________________________________________________________
64+
65+
resource "intersight_fabric_fc_zone_policy" "fc_zone_policies" {
66+
depends_on = [
67+
local.org_moid
68+
]
69+
for_each = local.fc_zone_policies
70+
description = each.value.description != "" ? each.value.description : "${each.key} FC Zone Policy"
71+
fc_target_zoning_type = each.value.fc_target_zoning_type
72+
name = each.key
73+
organization {
74+
moid = local.org_moid
75+
object_type = "organization.Organization"
76+
}
77+
dynamic "fc_target_members" {
78+
for_each = each.value.targets
79+
content {
80+
name = fc_target_members.key
81+
switch_id = fc_target_members.value.switch_id
82+
vsan_id = fc_target_members.value.vsan_id
83+
wwpn = fc_target_members.value.wwpn
84+
}
85+
}
86+
dynamic "tags" {
87+
for_each = length(each.value.tags) > 0 ? each.value.tags : local.tags
88+
content {
89+
key = tags.value.key
90+
value = tags.value.value
91+
}
92+
}
93+
}

modules/policies/imc_access_policies.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ resource "intersight_access_policy" "imc_access_policies" {
6565
}
6666

6767
dynamic "inband_ip_pool" {
68-
for_each = { for k, v in toset([each.value.inband_ip_pool]): k => v if length(each.value.inband_ip_pool) > 0 }
68+
for_each = { for k, v in toset([each.value.inband_ip_pool]) : k => v if length(each.value.inband_ip_pool) > 0 }
6969
content {
7070
moid = each.value.inband_ip_pool != "" ? local.ip_pools[each.value.inband_ip_pool] : null
7171
object_type = "ippool.Pool"
@@ -76,7 +76,7 @@ resource "intersight_access_policy" "imc_access_policies" {
7676
object_type = "organization.Organization"
7777
}
7878
dynamic "out_of_band_ip_pool" {
79-
for_each = { for k, v in toset([each.value.out_of_band_ip_pool]): k => v if length(each.value.out_of_band_ip_pool) > 0 }
79+
for_each = { for k, v in toset([each.value.out_of_band_ip_pool]) : k => v if length(each.value.out_of_band_ip_pool) > 0 }
8080
content {
8181
moid = each.value.out_of_band_ip_pool != "" ? local.ip_pools[each.value.out_of_band_ip_pool] : null
8282
object_type = "ippool.Pool"

modules/policies/locals.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,27 @@ locals {
946946
}
947947

948948

949+
#__________________________________________________________
950+
#
951+
# FC Zoning Policy Section - Locals
952+
#__________________________________________________________
953+
954+
fc_zone_policies = {
955+
for k, v in var.fc_zone_policies : k => {
956+
description = v.description != null ? v.description : ""
957+
fc_target_zoning_type = v.fc_target_zoning_type != null ? v.fc_target_zoning_type : "None"
958+
tags = v.tags != null ? v.tags : []
959+
targets = length(v.targets) > 0 ? {
960+
for key, value in v.targets : value.name => {
961+
switch_id = value.switch_id
962+
vsan_id = value.vsan_id
963+
wwpn = value.wwpn
964+
}
965+
} : {}
966+
}
967+
}
968+
969+
949970
#__________________________________________________________
950971
#
951972
# Fibre Channel Adapter Policy Section - Locals

modules/policies/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ terraform {
88
required_providers {
99
intersight = {
1010
source = "CiscoDevNet/intersight"
11-
version = ">=1.0.28"
11+
version = ">=1.0.31"
1212
}
1313
}
1414
}

0 commit comments

Comments
 (0)