Skip to content

Add Nokia SRL (Service Router Linux) Platform Driver #245

@jtdub

Description

@jtdub

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

  • Platform.NOKIA_SRL enum value exists
  • HConfigDriverNokiaSRL driver implemented with appropriate rules
  • Driver registered in get_hconfig_driver()
  • Test file covers basic and platform-specific scenarios
  • Full lint + test suite passes (poetry run ./scripts/build.py lint-and-test)
  • 95% test coverage maintained
  • CHANGELOG.md updated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions