Enhance BaseDevice validation and update Mikrotik model

- Introduced a new method `_validate_template_groups` in `BaseDevice` to ensure TTP templates declare all required and optional sections.
- Updated `_REQUIRED_SECTIONS` and added `_OPTIONAL_SECTIONS` to improve template validation.
- Modified the `vlans` method in `Mikrotik` to streamline raw data handling and added debug print statements for clarity.
- Revised the Mikrotik TTP template to include structured variable definitions and improved group handling for interfaces and VLANs.
This commit is contained in:
IluaAir
2026-02-19 00:16:37 +03:00
parent c434712309
commit 685ff19d2f
3 changed files with 56 additions and 17 deletions

View File

@@ -1,3 +1,4 @@
import re
from typing import TYPE_CHECKING
from oxi.interfaces import register_parser
from oxi.interfaces.base import BaseDevice
@@ -19,11 +20,13 @@ class Mikrotik(BaseDevice):
print("-" * 12)
def vlans(self) -> list["Vlans"]:
print(f"{self._raw["vlans"]=}")
print("-" * 12)
raw = self._raw.get("vlans", [])
print(raw)
if __name__ == "__main__":
mikr = Mikrotik()
mikr.run()
with open("../../test.txt") as file:
data = file.read()
mikr = Mikrotik(data)
mikr.parse()
print(mikr.load)