Overview
Add a new platform driver for Nokia SRL (Service Router Linux) to enable hier_config to parse SRL configurations and generate accurate remediation commands. This is needed to support Nokia SR Linux devices in nautobot-app-golden-config.
Background
Nokia SR Linux uses a hierarchical CLI with indentation-based config blocks. SRL uses delete for negation (similar to VyOS's delete/set pattern), and has platform-specific sectional constructs for features like:
network-instance (VRF-equivalent blocks)
interface sub-configurations
routing-policy / route-table blocks
system config blocks
Required Changes
1. Add Platform Enum Entry
File: hier_config/models.py
Add NOKIA_SRL = auto() to the Platform enum.
2. Create Driver Module
New files:
hier_config/platforms/nokia_srl/
├── __init__.py
└── driver.py
driver.py must subclass HConfigDriverBase and implement _instantiate_rules() returning an HConfigDriverRules instance with Nokia SRL-specific rules. At minimum, investigate and configure:
negation_prefix / declaration_prefix (SRL uses delete for removal)
sectional_exiting rules (e.g., exit or quit within config blocks)
idempotent_commands (e.g., IP address assignments within interfaces)
per_line_sub (e.g., strip timestamps or auto-generated comments from info detail output)
config_preprocessor() if SRL's hierarchical flat-format (info flat) needs normalization
3. Register Driver
File: hier_config/constructors.py
Import HConfigDriverNokiaSRL and add it to the platform_drivers dict in get_hconfig_driver().
4. Write Tests
New file: tests/test_driver_nokia_srl.py
Follow patterns from tests/test_driver_vyos.py and tests/test_driver_arista_eos.py. Cover:
- Basic remediation (add/remove/change config lines)
- Interface configuration remediation
network-instance (VRF) block handling
- Sectional exiting behavior
- Negation behavior
5. Update Changelog
Add entry under ## [Unreleased] in CHANGELOG.md:
### Added
- Nokia SRL platform driver (`Platform.NOKIA_SRL`) (#<this issue number>)
Related Work
After this driver is merged, a follow-up PR to netutils will be needed with the following changes:
netutils: Add to hier_config lib mapper
netutils: Add to HCONFIG_PLATFORM_V2_TO_V3_MAPPING
Nokia SRL did not exist in hier_config v2, so there is no v2 equivalent to map from. However, the HCONFIG_PLATFORM_V2_TO_V3_MAPPING dict in netutils still requires a "nokia_srl" entry pointing to Platform.NOKIA_SRL so that the mapper remains complete for v3 consumers.
Nokia SRL CLI Reference
Key behaviors to validate during implementation:
- SRL config display format:
info (hierarchical) vs info flat (flat/set-style)
- Negation syntax:
delete prefix on leaf nodes
- Indentation: typically 4 spaces per level
- Config blocks end with
exit or are implicitly closed by indentation
Acceptance Criteria
Overview
Add a new platform driver for Nokia SRL (Service Router Linux) to enable hier_config to parse SRL configurations and generate accurate remediation commands. This is needed to support Nokia SR Linux devices in nautobot-app-golden-config.
Background
Nokia SR Linux uses a hierarchical CLI with indentation-based config blocks. SRL uses
deletefor negation (similar to VyOS'sdelete/setpattern), and has platform-specific sectional constructs for features like:network-instance(VRF-equivalent blocks)interfacesub-configurationsrouting-policy/route-tableblockssystemconfig blocksRequired Changes
1. Add Platform Enum Entry
File:
hier_config/models.pyAdd
NOKIA_SRL = auto()to thePlatformenum.2. Create Driver Module
New files:
driver.pymust subclassHConfigDriverBaseand implement_instantiate_rules()returning anHConfigDriverRulesinstance with Nokia SRL-specific rules. At minimum, investigate and configure:negation_prefix/declaration_prefix(SRL usesdeletefor removal)sectional_exitingrules (e.g.,exitorquitwithin config blocks)idempotent_commands(e.g., IP address assignments within interfaces)per_line_sub(e.g., strip timestamps or auto-generated comments frominfo detailoutput)config_preprocessor()if SRL's hierarchical flat-format (info flat) needs normalization3. Register Driver
File:
hier_config/constructors.pyImport
HConfigDriverNokiaSRLand add it to theplatform_driversdict inget_hconfig_driver().4. Write Tests
New file:
tests/test_driver_nokia_srl.pyFollow patterns from
tests/test_driver_vyos.pyandtests/test_driver_arista_eos.py. Cover:network-instance(VRF) block handling5. Update Changelog
Add entry under
## [Unreleased]inCHANGELOG.md:Related Work
After this driver is merged, a follow-up PR to netutils will be needed with the following changes:
netutils: Add to hier_config lib mapper
netutils/lib_mapper.pylines 420-430 — add"nokia_srl"to the hier_config platform listnetutils/lib_mapper.pylines 595-605 — add the reverse mapping entrynetutils: Add to
HCONFIG_PLATFORM_V2_TO_V3_MAPPINGNokia SRL did not exist in hier_config v2, so there is no v2 equivalent to map from. However, the
HCONFIG_PLATFORM_V2_TO_V3_MAPPINGdict in netutils still requires a"nokia_srl"entry pointing toPlatform.NOKIA_SRLso that the mapper remains complete for v3 consumers.Nokia SRL CLI Reference
Key behaviors to validate during implementation:
info(hierarchical) vsinfo flat(flat/set-style)deleteprefix on leaf nodesexitor are implicitly closed by indentationAcceptance Criteria
Platform.NOKIA_SRLenum value existsHConfigDriverNokiaSRLdriver implemented with appropriate rulesget_hconfig_driver()poetry run ./scripts/build.py lint-and-test)CHANGELOG.mdupdated