Refactor Mikrotik model and update TTP template for improved configuration handling

- Removed unused imports and main execution block from the Mikrotik model for cleaner code.
- Updated the Mikrotik TTP template to adjust the order of parameters in the 'add' command, enhancing clarity in the generated configurations.
- Added a new configuration file `config.conf` for Mikrotik devices to facilitate testing and validation of parsing functionality.
This commit is contained in:
IluaAir
2026-06-07 09:06:24 +03:00
parent a617bd6ecd
commit 2ea056aa17
3 changed files with 124 additions and 10 deletions

View File

@@ -1,4 +1,3 @@
import os
from oxi.interfaces import register_parser
from oxi.interfaces.base import BaseDevice
@@ -6,11 +5,3 @@ from oxi.interfaces.base import BaseDevice
@register_parser(["routeros", "ros", "mikrotik"])
class Mikrotik(BaseDevice):
template = "mikrotik.ttp"
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())

View File

@@ -42,6 +42,6 @@ add comment={{ comment | _start_ | ORPHRASE | exclude("disabled=") | strip('"')}
## disabled with comment with/without quotes
add comment={{ comment | _start_ | ORPHRASE | exclude("disabled=") | strip('"')}} disabled={{ disabled | replace("yes","True") | strip('"') }} interface={{ interface }} name={{ name | ORPHRASE | strip('"') }} vlan-id={{ vlan_id }}
## disabled no comment
add interface={{ interface | _start_ }} name={{ name | ORPHRASE | strip('"') }} vlan-id={{ vlan_id }} disabled={{ disabled | replace("yes","True") | strip('"') }}
add disabled={{ disabled | _start_ | replace("yes","True") | strip('"') }} interface={{ interface }} name={{ name | ORPHRASE | strip('"') }} vlan-id={{ vlan_id }}
</group>