Skip to content

Commit

Permalink
Add support for physical media type (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdewulfPersonal authored Jan 30, 2024
1 parent 4238071 commit 42d67fb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
11 changes: 6 additions & 5 deletions aci_access_policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ module "aci_lldp_policy" {
module "aci_link_level_policy" {
source = "./modules/terraform-aci-link-level-policy"

for_each = { for llp in try(local.access_policies.interface_policies.link_level_policies, []) : llp.name => llp if local.modules.aci_link_level_policy && var.manage_access_policies }
name = "${each.value.name}${local.defaults.apic.access_policies.interface_policies.link_level_policies.name_suffix}"
speed = try(each.value.speed, local.defaults.apic.access_policies.interface_policies.link_level_policies.speed)
auto = try(each.value.auto, local.defaults.apic.access_policies.interface_policies.link_level_policies.auto)
fec_mode = try(each.value.fec_mode, local.defaults.apic.access_policies.interface_policies.link_level_policies.fec_mode)
for_each = { for llp in try(local.access_policies.interface_policies.link_level_policies, []) : llp.name => llp if local.modules.aci_link_level_policy && var.manage_access_policies }
name = "${each.value.name}${local.defaults.apic.access_policies.interface_policies.link_level_policies.name_suffix}"
speed = try(each.value.speed, local.defaults.apic.access_policies.interface_policies.link_level_policies.speed)
auto = try(each.value.auto, local.defaults.apic.access_policies.interface_policies.link_level_policies.auto)
fec_mode = try(each.value.fec_mode, local.defaults.apic.access_policies.interface_policies.link_level_policies.fec_mode)
physical_media_type = try(each.value.physical_media_type, null)
}

module "aci_port_channel_policy" {
Expand Down
1 change: 1 addition & 0 deletions modules/terraform-aci-link-level-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module "aci_link_level_policy" {
| <a name="input_speed"></a> [speed](#input\_speed) | Interface speed. Choices: `inherit`, `auto`, `100M`, `1G`, `10G`, `25G`, `40G`, `100G`, `400G`. | `string` | `"inherit"` | no |
| <a name="input_auto"></a> [auto](#input\_auto) | Auto negotiation. | `bool` | `true` | no |
| <a name="input_fec_mode"></a> [fec\_mode](#input\_fec\_mode) | Forward error correction (FEC) mode. Choices: `inherit`, `cl91-rs-fec`, `cl74-fc-fec`, `ieee-rs-fec`, `cons16-rs-fec`, `disable-fec`. | `string` | `"inherit"` | no |
| <a name="input_physical_media_type"></a> [physical\_media\_type](#input\_physical\_media\_type) | Physical Media Type. Choices: `auto`, `sfp-10g-tx`. | `string` | `null` | no |

## Outputs

Expand Down
10 changes: 6 additions & 4 deletions modules/terraform-aci-link-level-policy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ resource "aci_rest_managed" "fabricHIfPol" {
dn = "uni/infra/hintfpol-${var.name}"
class_name = "fabricHIfPol"
content = {
name = var.name
speed = var.speed
autoNeg = var.auto == true ? "on" : "off"
fecMode = var.fec_mode
name = var.name
speed = var.speed
autoNeg = var.auto == true ? "on" : "off"
fecMode = var.fec_mode
portPhyMediaType = try(var.physical_media_type, null) != null ? var.physical_media_type : null
}
}

11 changes: 11 additions & 0 deletions modules/terraform-aci-link-level-policy/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,14 @@ variable "fec_mode" {
error_message = "Allowed values: `inherit`, `cl91-rs-fec`, `cl74-fc-fec`, `ieee-rs-fec`, `cons16-rs-fec`, `disable-fec`."
}
}

variable "physical_media_type" {
description = "Physical Media Type. Choices: `auto`, `sfp-10g-tx`."
type = string
default = null

validation {
condition = var.physical_media_type == null ? true : (contains(["auto", "sfp-10g-tx"], var.physical_media_type))
error_message = "Allowed values: `auto`, `sfp-10g-tx`."
}
}

0 comments on commit 42d67fb

Please sign in to comment.