Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature qos rules order #23

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -122,6 +122,7 @@ module "meraki" {
| [meraki_switch_port.devices_switch_port](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_port) | resource |
| [meraki_switch_port_schedule.net_switch_port_schedules](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_port_schedule) | resource |
| [meraki_switch_qos_rule.net_switch_qos_rule](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_qos_rule) | resource |
| [meraki_switch_qos_rule_order.net_switch_qos_rule_order](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_qos_rule_order) | resource |
| [meraki_switch_routing_interface.devices_switch_routing_interface](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_routing_interface) | resource |
| [meraki_switch_routing_interface_dhcp.devices_switch_routing_interfaces_dhcp](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_routing_interface_dhcp) | resource |
| [meraki_switch_routing_multicast.net_switch_routing_multicast](https://registry.terraform.io/providers/CiscoDevNet/meraki/0.1.3/docs/resources/switch_routing_multicast) | resource |
Expand Down
32 changes: 27 additions & 5 deletions meraki_switches.tf
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ locals {
for network in try(organization.networks, []) : [
for switch_link_aggregation in try(network.switch_link_aggregations, []) : {
network_id = meraki_network.network["${organization.name}/${network.name}"].id

switch_ports = [for p in switch_link_aggregation.switch_ports : {
serial = meraki_device.device["${organization.name}/${network.name}/devices/${p.device}"].serial
port_id = p.port_id
}]
data = try(switch_link_aggregation, null)
} if try(network.switch_link_aggregations, null) != null
] if try(organization.networks, null) != null
Expand All @@ -189,7 +192,7 @@ resource "meraki_switch_link_aggregation" "net_switch_link_aggregation" {
for_each = { for i, v in local.networks_switch_link_aggregations : i => v }
network_id = each.value.network_id

switch_ports = try(each.value.data.switch_ports, local.defaults.meraki.networks.networks_switch_link_aggregations.switch_ports, null)
switch_ports = each.value.switch_ports
switch_profile_ports = try(each.value.data.switch_profile_ports, local.defaults.meraki.networks.networks_switch_link_aggregations.switch_profile_ports, null)

depends_on = [meraki_network_device_claim.net_device_claim]
Expand Down Expand Up @@ -282,8 +285,8 @@ locals {
for network in try(organization.networks, []) : [
for switch_qos_rule in try(network.switch_qos_rules, []) : {
network_id = meraki_network.network["${organization.name}/${network.name}"].id

data = try(switch_qos_rule, null)
key = "${organization.name}/${network.name}/qos_rules/${switch_qos_rule.qos_rule_name}"
data = try(switch_qos_rule, null)
} if try(network.switch_qos_rules, null) != null
] if try(organization.networks, null) != null
] if try(domain.organizations, null) != null
Expand All @@ -292,7 +295,7 @@ locals {
}

resource "meraki_switch_qos_rule" "net_switch_qos_rule" {
for_each = { for i, v in local.networks_switch_qos_rules : i => v }
for_each = { for i, v in local.networks_switch_qos_rules : v.key => v }
network_id = each.value.network_id

vlan = try(each.value.data.vlan, local.defaults.meraki.networks.networks_switch_qos_rules.vlan, null)
Expand All @@ -307,6 +310,25 @@ resource "meraki_switch_qos_rule" "net_switch_qos_rule" {

}

locals {
networks_switch_qos_rules_orders = flatten([

for domain in try(local.meraki.domains, []) : [
for organization in try(domain.organizations, []) : [
for network in try(organization.networks, []) : {
network_id = meraki_network.network["${organization.name}/${network.name}"].id
rule_ids = [for r in network.switch_qos_rules : meraki_switch_qos_rule.net_switch_qos_rule["${organization.name}/${network.name}/qos_rules/${r.qos_rule_name}"].id]
} if try(network.switch_qos_rules, null) != null
] if try(domain.organizations, null) != null
] if try(local.meraki.domains, null) != null
])
}

resource "meraki_switch_qos_rule_order" "net_switch_qos_rule_order" {
for_each = { for i, v in local.networks_switch_qos_rules_orders : i => v }
network_id = each.value.network_id
rule_ids = each.value.rule_ids
}

locals {
networks_switch_routing_multicast = flatten([
Expand Down
Loading