diff --git a/roles/validate/files/rules/common/305_topology_switch_interfaces_vpc.py b/roles/validate/files/rules/common/305_topology_switch_interfaces_vpc.py index cf39d6b33..c6ad2ed49 100644 --- a/roles/validate/files/rules/common/305_topology_switch_interfaces_vpc.py +++ b/roles/validate/files/rules/common/305_topology_switch_interfaces_vpc.py @@ -53,6 +53,19 @@ def match(cls, data_model): ) return results + # Enforce Port-channel ID matches vPC ID to avoid mismatched configurations + port_channel_match = re.fullmatch( + r"Port-channel(\d+)", interface_name + ) + if port_channel_match: + port_channel_id = port_channel_match.group(1) + + if int(port_channel_id) != int(vpc_id): + results.append( + f"Switch {switch_name} interface {interface_name} uses vPC id {vpc_id}" + "but Port-channel ID {port_channel_id}; these values must match." + ) + # Check if vPC id is referenced by more than 1 Port-channel on the switch if vpc_id in vpc_ids: results.append(