Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Nokia SRL platform driver (`Platform.NOKIA_SRL`) (#245)

---

## [3.6.0] - 2026-03-26
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Hierarchical Configuration has been used extensively on:
In addition to the Cisco-style syntax, hier_config offers experimental support for Juniper-style configurations using set and delete commands. This allows users to remediate Junos configurations in native syntax. However, please note that Juniper syntax support is still in an experimental phase and has not been tested extensively. Use with caution in production environments.

- [x] Juniper JunOS
- [x] Nokia SRL (Service Router Linux)
- [x] VyOS

Hier Config is compatible with any NOS that utilizes a structured CLI syntax similar to Cisco IOS or Junos OS.
Expand Down
1 change: 1 addition & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ A frozen Pydantic model holding lists of typed rule objects:
| `HP_COMWARE5` | `HConfigDriverHPComware5` | `platforms/hp_comware5/driver.py` |
| `HP_PROCURVE` | `HConfigDriverHPProcurve` | `platforms/hp_procurve/driver.py` |
| `JUNIPER_JUNOS` | `HConfigDriverJuniperJUNOS` | `platforms/juniper_junos/driver.py` |
| `NOKIA_SRL` | `HConfigDriverNokiaSRL` | `platforms/nokia_srl/driver.py` |
| `VYOS` | `HConfigDriverVYOS` | `platforms/vyos/driver.py` |

See [Drivers](drivers.md) for full documentation on customising or creating drivers.
Expand Down
33 changes: 33 additions & 0 deletions docs/drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The following drivers are included in Hier Config:
- **HP_PROCURVE**
- **HUAWEI_VRP**
- **JUNIPER_JUNOS**
- **NOKIA_SRL**
- **VYOS**

To activate a driver, use the `get_hconfig_driver` utility provided by Hier Config:
Expand Down Expand Up @@ -144,6 +145,38 @@ driver = get_hconfig_driver(Platform.VYOS)

---

### Nokia SRL (Service Router Linux) Driver

Nokia SR Linux uses `set` and `delete` command syntax, similar to VyOS and JunOS. The driver converts hierarchical SRL configuration (from `info` output) into flat `set`/`delete` commands via a preprocessor.

> **Experimental:** Nokia SRL support has not been tested extensively in production environments. Use with caution.

- **[Declaration prefix](glossary.md#declaration-prefix)**: `set ` (prepended to each positive command).
- **[Negation prefix](glossary.md#negation-prefix)**: `delete ` (replaces `no `).

Platform enum: `Platform.NOKIA_SRL`

```python
from hier_config import Platform, get_hconfig_driver

driver = get_hconfig_driver(Platform.NOKIA_SRL)
```

**Remediation example:**

```python
from hier_config import WorkflowRemediation, get_hconfig, Platform

running = get_hconfig(Platform.NOKIA_SRL, running_text)
intended = get_hconfig(Platform.NOKIA_SRL, intended_text)
workflow = WorkflowRemediation(running, intended)

for line in workflow.remediation_config.all_children_sorted():
print(line.cisco_style_text())
```

---

### Generic Driver

The `GENERIC` driver contains no platform-specific rules. It is useful as a starting point for custom drivers or for platforms that follow standard Cisco-style syntax with few special cases.
Expand Down
2 changes: 1 addition & 1 deletion docs/glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The string prepended to a command to negate (remove) it. `HConfigDriverBase.neg
|----------|----------------|
| Cisco IOS / EOS / NX-OS | `"no "` |
| HP Comware5 / H3C | `"undo "` |
| JunOS / VyOS | `"delete "` |
| JunOS / VyOS / Nokia SRL | `"delete "` |

---

Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
| HP ProCurve (Aruba AOSS) | `Platform.HP_PROCURVE` | Fully supported |
| HP Comware5 / H3C | `Platform.HP_COMWARE5` | Fully supported |
| Juniper JunOS | `Platform.JUNIPER_JUNOS` | Experimental |
| Nokia SRL | `Platform.NOKIA_SRL` | Experimental |
| VyOS | `Platform.VYOS` | Experimental |
| Generic | `Platform.GENERIC` | Base for custom drivers |

Expand Down
2 changes: 2 additions & 0 deletions hier_config/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .platforms.hp_procurve.view import HConfigViewHPProcurve
from .platforms.huawei_vrp.driver import HConfigDriverHuaweiVrp
from .platforms.juniper_junos.driver import HConfigDriverJuniperJUNOS
from .platforms.nokia_srl.driver import HConfigDriverNokiaSRL
from .platforms.view_base import HConfigViewBase
from .platforms.vyos.driver import HConfigDriverVYOS
from .root import HConfig
Expand All @@ -43,6 +44,7 @@ def get_hconfig_driver(platform: Platform) -> HConfigDriverBase:
Platform.HP_COMWARE5: HConfigDriverHPComware5,
Platform.HUAWEI_VRP: HConfigDriverHuaweiVrp,
Platform.JUNIPER_JUNOS: HConfigDriverJuniperJUNOS,
Platform.NOKIA_SRL: HConfigDriverNokiaSRL,
Platform.VYOS: HConfigDriverVYOS,
}
driver_cls = platform_drivers.get(platform)
Expand Down
1 change: 1 addition & 0 deletions hier_config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class Platform(str, Enum):
HP_PROCURVE = auto()
HUAWEI_VRP = auto()
JUNIPER_JUNOS = auto()
NOKIA_SRL = auto()
VYOS = auto()


Expand Down
Empty file.
38 changes: 38 additions & 0 deletions hier_config/platforms/nokia_srl/driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from hier_config.child import HConfigChild
from hier_config.platforms.driver_base import HConfigDriverBase, HConfigDriverRules
from hier_config.platforms.functions import convert_to_set_commands


class HConfigDriverNokiaSRL(HConfigDriverBase): # pylint: disable=too-many-instance-attributes
"""Driver for Nokia SR Linux.

Converts hierarchical SRL configuration into flat ``set``/``delete``
command syntax via a preprocessor. Overrides ``declaration_prefix`` to
``"set "`` and ``negation_prefix`` to ``"delete "``.
Platform enum: ``Platform.NOKIA_SRL``.
"""

def swap_negation(self, child: HConfigChild) -> HConfigChild:
"""Swap negation of a `self.text`."""
if child.text.startswith(self.negation_prefix):
child.text = f"{self.declaration_prefix}{child.text_without_negation}"
elif child.text.startswith(self.declaration_prefix):
child.text = f"{self.negation_prefix}{child.text.removeprefix(self.declaration_prefix)}"

return child

@property
def declaration_prefix(self) -> str:
return "set "

@property
def negation_prefix(self) -> str:
return "delete "

@staticmethod
def config_preprocessor(config_text: str) -> str:
return convert_to_set_commands(config_text)

@staticmethod
def _instantiate_rules() -> HConfigDriverRules:
return HConfigDriverRules()
1 change: 1 addition & 0 deletions hier_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"junos": Platform.JUNIPER_JUNOS,
"vyos": Platform.VYOS,
"huawei_vrp": Platform.HUAWEI_VRP,
"nokia_srl": Platform.NOKIA_SRL,
}


Expand Down
Loading
Loading