Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module "iosxr" {
| [iosxr_logging_source_interface.logging_source_interface](https://registry.terraform.io/providers/CiscoDevNet/iosxr/latest/docs/resources/logging_source_interface) | resource |
| [iosxr_mpls_oam.mpls_oam](https://registry.terraform.io/providers/CiscoDevNet/iosxr/latest/docs/resources/mpls_oam) | resource |
| [iosxr_ntp.ntp](https://registry.terraform.io/providers/CiscoDevNet/iosxr/latest/docs/resources/ntp) | resource |
| [iosxr_policy_map_qos.policy_map_qos](https://registry.terraform.io/providers/CiscoDevNet/iosxr/latest/docs/resources/policy_map_qos) | resource |
| [iosxr_router_static_ipv4_unicast.router_static_ipv4_unicast](https://registry.terraform.io/providers/CiscoDevNet/iosxr/latest/docs/resources/router_static_ipv4_unicast) | resource |
| [iosxr_segment_routing.segment_routing](https://registry.terraform.io/providers/CiscoDevNet/iosxr/latest/docs/resources/segment_routing) | resource |
| [iosxr_service_timestamps.service_timestamps](https://registry.terraform.io/providers/CiscoDevNet/iosxr/latest/docs/resources/service_timestamps) | resource |
Expand Down
34 changes: 34 additions & 0 deletions iosxr_policy_map_qos.tf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Line 4 - You only need to iterate on one item (policy_map_name).
  • Line 7 - Please add the resource name to the key.
    "${device.name}-policy_map_qos-${policy_map_name}"
  • Please check all your default fallbacks. They have underscores instead of periods.
    policy_map_qos_description should be policy_map_qos.description
  • You are missing alot of attributes in the schema (after queue limits). Please include all attributes, not just the example usage ones.
  • Line 21 not needed

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
locals {
device_policy_map_qos = flatten([
for device in local.devices : [
for policy_map_name, policy_map in try(local.device_config[device.name].policy_map_qos, {}) : {
device_name = device.name
policy_map_name = policy_map_name
key = "${device.name}-${policy_map_name}"
description = try(policy_map.description, local.defaults.iosxr.configuration.policy_map_qos_description, null)
classes = try(length(policy_map.classes) == 0, true) ? null : [for class in policy_map.classes : {
name = try(class.name, local.defaults.iosxr.configuration.policy_map_qos_classes_name, null)
type = try(class.type, local.defaults.iosxr.configuration.policy_map_qos_classes_type, null)
set_mpls_experimental_topmost = try(class.set_mpls_experimental_topmost, local.defaults.iosxr.configuration.policy_map_qos_classes_set_mpls_experimental_topmost, null)
set_dscp = try(class.set_dscp, local.defaults.iosxr.configuration.policy_map_qos_classes_set_dscp, null)
queue_limits = try(length(class.queue_limits) == 0, true) ? null : [for limit in class.queue_limits : {
value = try(limit.value, local.defaults.iosxr.configuration.policy_map_qos_classes_queue_limits_value, null)
unit = try(limit.unit, local.defaults.iosxr.configuration.policy_map_qos_classes_queue_limits_unit, null)
}]
}]
}
]
if try(local.device_config[device.name].policy_map_qos, null) != null || try(local.defaults.iosxr.configuration.policy_map_qos, null) != null
])
}

resource "iosxr_policy_map_qos" "policy_map_qos" {
for_each = { for policy_map in local.device_policy_map_qos : policy_map.key => policy_map }

device = each.value.device_name
policy_map_name = each.value.policy_map_name

# Optional attributes
description = each.value.description
classes = each.value.classes
}