Files
oxipy/oxi/interfaces/models/mikrotik.py
IluaAir 2394296f5b Enhance Keenetic model and update templates for improved data handling
- Implemented the `interfaces` and `vlans` methods in the `Keenetic` model to process and decode interface and VLAN data.
- Added a `_decode_utf` method to handle UTF-8 encoded descriptions.
- Updated the Keenetic TTP template to define structured groups for system, interfaces, and VLANs.
- Refactored file paths in the `Mikrotik` model for consistency and clarity.
2026-02-22 00:21:55 +03:00

28 lines
790 B
Python

import os
from oxi.interfaces import register_parser
from oxi.interfaces.base import BaseDevice
from oxi.interfaces.contract import Interfaces, System, Vlans
@register_parser(["routeros", "ros", "mikrotik"])
class Mikrotik(BaseDevice):
template = "mikrotik.ttp"
def system(self) -> "System":
systems = self._raw.get("system")
return System(**systems)
def interfaces(self) -> "Interfaces":
return [Interfaces(**item) for item in self._raw.get("interfaces")]
def vlans(self) -> list["Vlans"]:
return [Vlans(**item) for item in self._raw.get("vlans")]
if __name__ == "__main__":
print(os.path.abspath(os.curdir))
with open("./test.txt") as file:
data = file.read()
mikr = Mikrotik(data)
print(mikr.parse().json())