Repository navigation
Conversation
The generator wrote the MetalBox IP as next hop of the default route in the mgmt VRF. STATIC_ROUTE is rebuilt on every regen, so a deployment whose management network uses another gateway could not correct the route anywhere. The next hop now comes from the config context key _segment_mgmt_gateway_ipv4 when a device has it, in the same way as the _segment_* keys for syslog and SNMP. NetBox merges local context data over the assigned config contexts, so the key works for a whole segment and for a single switch. NTP and DNS stay on the MetalBox IP, and a device without the key gets the same config as before. A value with a prefix length is accepted, because NetBox shows addresses that way. Anything else that is not an IPv4 address is ignored with a warning and the MetalBox IP is used. Raising would make the sync skip the device, so one bad segment context would block all changes for every switch it covers. Only strings are parsed, since ipaddress reads the integer 42 as 0.0.0.42. An address outside the OOB network is used as given, with a warning. Tests: the helper with usable, unset and unusable values, and with an address outside an IPv4 and an IPv6 OOB network. In the orchestrator, the override with and without a MetalBox, the fallback for an invalid value, the unchanged None next hop without either address, and a device without an OOB IP. Part of #2396. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Christian Berendt <berendt@osism.tech>
The new page describes the default next hop of the mgmt default route, where _segment_mgmt_gateway_ipv4 can be set in NetBox, which values it accepts, when the MetalBox IP is used instead, and that NTP, DNS and the control-plane ACLs do not change. The README links it. Part of #2396. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Christian Berendt <berendt@osism.tech>
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.
A SONiC switch can now get its management gateway from NetBox. If the rendered config context of a device has a valid IPv4 address under
_segment_mgmt_gateway_ipv4, the config generator writes it as the next hop ofSTATIC_ROUTE["mgmt|0.0.0.0/0"]in place of the MetalBox IP. A device without the key gets the same config as before.Closes #2396
Commits
_get_mgmt_gateway_override, its call ingenerate_sonic_config, and the tests.ipaddressreads the integer42as0.0.0.42.None, as before. A test covers this.docs/sonic-mgmt-gateway.mdand links it in the README.Verification
Run locally with the tool versions pinned in the OSISM Zuul roles:
None. The new helper test file failed on import. All of them pass now.pytest tests/unit/tasks/conductor/sonic: 844 passed (820 onmain).pytest: 4253 passed, 3 xfailed (4229 passed, 3 xfailed onmain).flake8on the changed Python files, andblack --check .andmypyon the whole repository: no findings.git diff --stat main -- tests/e2e/ files/sonic/is empty._add_ntp_configurationand_add_dns_configurationare identical tomain.Not exercised locally, only OSISM's Zuul can verify these:
python-osism-sonic-e2epasses against the unchanged goldens. The check pipeline of this pull request runs it, because the change is underosism/tasks/conductor/.flake8,python-black,mypyandpython-osism-unit-testspass. The check pipeline runs them too. The local runs above are evidence, not a replacement.Deviations from the approved plan
None.
Open questions
None declined.
Noticed, not touched
osism sonic validate --generate(osism/commands/sonic.py:1361-1387) does not load the MetalBox cache. Onlysync_sonicdoes (osism/tasks/conductor/sonic/sync.py:68). From reading the code (not run), the command finds no MetalBox IP, so without the new key it validates a config with next hopNoneand no NTP or DNS server. This is an existing bug in another file.README.md:21-22(line numbers with this change) givespipenv install --devandpipenv run pytestfor the full unit suite.Pipfile.locklacks six packages fromrequirements.txt: boto3, fastapi, python-openstackclient, tabulate, uvicorn and websockets. CI gets them withpip install .. This is test setup, not part of the issue.README.mddoes not include the existing pagedocs/collection-plans.md. The issue asks for one new entry only.🤖 Generated with Claude Code