CASMNET-2390 - canu generate network config silently emits wrong-cabinet VLANs on sw-cdu ports when a Mountain/Olympus cabinet is in the CCJ but not in SLS#760
Merged
Conversation
When a Mountain/Olympus cabinet is present in the CCJ/SHCD but absent from the SLS input (NMN_MTN_CABINETS / HMN_MTN_CABINETS), the cmm/cec branches of get_switch_nodes silently used the VLAN values left over from a previous port iteration (a different cabinet), producing CDU switch port configs that trunk/access VLANs not defined on the switch and not belonging to that cabinet. If the very first cmm/cec port hit had no SLS match the same code raised UnboundLocalError instead. Initialise nmn_mtn_vlan / hmn_mtn_vlan to None per port. When no SLS cabinet matches the CCJ rack number, emit a red WARNING via click.secho naming the switch, port, lag, cabinet, and which SLS list is missing, and skip the node so the wrong VLANs are never rendered. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a Mountain/Olympus cabinet is present in the CCJ/SHCD but absent
from SLS (NMN_MTN_CABINETS / HMN_MTN_CABINETS), the CDU config renderer
must skip the cabinet's CMM/CEC ports and warn, instead of stamping the
previous cabinet's VLANs onto them.
Adds:
* tests/data/Full_Architecture_Mountain_2cab.json -- CCJ with two
Mountain cabinets (x1000, x1001).
* tests/data/sls_input_file_csm_1.7_mtn_mismatch.json -- SLS containing
only x1000.
* tests/data/golden_configs/mtn_sls_mismatch_1.7/sw-cdu-{001,002}.cfg --
golden output produced by the fixed renderer (no x1001 stanzas).
* test_switch_config_cdu_primary_mtn_sls_mismatch and
test_switch_config_cdu_secondary_mtn_sls_mismatch in
tests/test_generate_switch_config_aruba_configs_csm_1_7.py. Each
asserts exit_code == 0, golden diff, presence of the per-port
WARNING text, and absence of any x1001 references in the rendered
config. Both tests fail against the pre-fix code.
Also extends tests/scripts/regenerate_golden_configs_1.7.sh (and its
README) with a Part 6/6 block that regenerates the new goldens via
--ccj, bumping the total from 57 to 59.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
canu generate network config silently emits wrong-cabinet VLANs on sw-cdu ports when a Mountain/Olympus cabinet is in the CCJ but not in SLS
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
trad511
reviewed
Jun 9, 2026
trad511
left a comment
Contributor
There was a problem hiding this comment.
if config.py has any more if/then statements added, then it might explode.
trad511
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary and Scope
Fixes CASMNET-2390: when a Mountain/Olympus cabinet is present in the CCJ/SHCD but absent from SLS (
Networks.NMN_MTN/HMN_MTN),canu generate switch configsilently emitted CDU CMM/CEC port stanzas that trunked/accessed the wrong cabinet's VLANs — VLANs that the SLS-driven sections of the same template never defined on the switch.Root cause: in
canu/generate/switch/config/config.py::get_switch_nodes, thecmm/cecbranches did not initialisenmn_mtn_vlan/hmn_mtn_vlanbefore the innerfor cabinets in sls_variables[...]loops. When the CCJ cabinet had no SLS match, the locals retained the stale value from a prior outer-loop iteration (a different cabinet) and were silently emitted onto the new cabinet's ports. The node was appended unconditionally — there was no skip/warn/error guard. If the very firstcmm/cecport hit had no SLS match, the same code path raisedUnboundLocalError.This PR:
nmn_mtn_vlan/hmn_mtn_vlantoNoneper port (kills both the stale-leak and theUnboundLocalErrorfirst-port case).WARNING: Skipping …viaclick.sechonaming the switch, port, lag, cabinet, and which SLS list is missing, thencontinues so the node is not appended. The switch will not silently get a misconfigured port stanza for an SLS-missing cabinet.tests/test_generate_switch_config_aruba_configs_csm_1_7.py(test_switch_config_cdu_primary_mtn_sls_mismatchandtest_switch_config_cdu_secondary_mtn_sls_mismatch) modelled on the existing CDU tests, using--ccj(matchingtest_generate_switch_config_aruba_templates_csm_1_7.py).tests/scripts/regenerate_golden_configs_1.7.sh(and itsREADME.md) with aPart 6/6block that regenerates the new goldens; total bumped from 57 to 59.Scope is limited to CSM 1.7 + Aruba CDU rendering, but the patched code path is shared across all CSM versions and vendors.
Out of scope — inverse scenario (cabinet in SLS but not in CCJ)
This PR does not change the inverse mismatch direction. The code already behaves correctly there: the outer port loop in
get_switch_nodesonly iterates CCJ-derived ports, so no CMM/CEC stanzas are rendered, and the SLS-driven VLAN/gateway build (aroundconfig.py:947) is gated byif sls_rack_int in destination_rack_list, which keeps SLS-only cabinets out ofNMN_MTN_VLANS/HMN_MTN_VLANS. The cabinet is silently omitted in both halves of the render — the resulting config is valid, but the operator gets no signal that the SHCD/CCJ may be missing an intended cabinet. Adding a symmetric warning is a separate, lower-severity follow-up.pyinstaller.py(no product files added; new files are tests/fixtures, whichpyinstaller.pyalready excludes viaexcludes=["tests"])CHANGELOG.mdfor the changes in this PRIssues and Related PRs
CASMNET-2390Testing
Reproduction (pre-fix, on
main):Two runs against the same CCJ with two Mountain cabinets (
x1000,x1001):In
output2, x1001's VLAN definitions andinterface vlanstanzas correctly disappear, but the CMM/CEC ports for x1001 still render — trunkingvlan trunk native 2000 / allowed 2000,3000(x1000's VLANs) andvlan access 3000instead of x1001's2001 / 2001,3001 / 3001. No warning or error is printed. Excerpt fromdiff output/sw-cdu-001.cfg output2/sw-cdu-001.cfg:Post-fix behaviour:
Same
single-cabinetinvocation now refuses to render the SLS-missing cabinet's ports and warns loudly per skipped port:The resulting
/tmp/output_pr/sw-cdu-001.cfgandsw-cdu-002.cfgcontain zerox1001references; the only x1000-VLAN stanzas left are the legitimate x1000 CMM/CEC ports.Other validation:
--sls-file sls_input_file.json) produces a config byte-identical to the pre-fix good output — no regression on the happy path.make unit→510 passed, 0 failed(was 508, +2 new). Both new tests fail when run against the pre-fix source (verified by temporarily revertingcanu/generate/switch/config/config.pytomain).tests/scripts/regenerate_golden_configs_1.7.shruns end-to-end and produces 59 files; the only diffs in pre-existing goldens are CANU version-banner strings, whichtests/lib/diff.py::diff_config_filesalready strips.Each new test asserts:
exit_code == 0WARNING: Skipping …text appears inresult.outputcoveringx1001, the switch name, and the missing SLS list(s) for both CMM and CEC ports.x1001references at all (defence-in-depth).