Refactor Mikrotik model and update template structure
- Changed the parsing method in `NodeConfig` to use `parse()` instead of `parse_config()`. - Updated the template loading path in `BaseDevice` to reflect the new directory structure. - Enhanced the `Mikrotik` class with new methods for `system`, `interfaces`, and `vlans`, including debug print statements. - Expanded the TTP template for Mikrotik to include structured variable definitions and groups for system, interfaces, and VLANs.
This commit is contained in:
@@ -1,11 +1,27 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from oxi.interfaces import register_parser
|
||||
from oxi.interfaces.base import BaseDevice
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from oxi.interfaces.contract import Interfaces, System, Vlans
|
||||
|
||||
|
||||
@register_parser(["routeros", "ros", "mikrotik"])
|
||||
class Mikrotik(BaseDevice):
|
||||
template = "mikrotik.ttp"
|
||||
|
||||
def system(self) -> "System":
|
||||
print(self._raw["system"])
|
||||
print("-" * 12)
|
||||
|
||||
def interfaces(self) -> "Interfaces":
|
||||
print(f"{self._raw["interfaces"]=}")
|
||||
print("-" * 12)
|
||||
|
||||
def vlans(self) -> list["Vlans"]:
|
||||
print(f"{self._raw["vlans"]=}")
|
||||
print("-" * 12)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mikr = Mikrotik()
|
||||
|
||||
Reference in New Issue
Block a user