Refactor Qtech model and update TTP template

- Removed the `interfaces` method from the `Qtech` model, simplifying the interface processing.
- Updated the TTP template to use `mask` instead of `netmask` for IP address configuration, enhancing clarity in CIDR notation.
This commit is contained in:
IluaAir
2026-02-28 10:44:20 +03:00
parent c382627f9f
commit bf6dd0c189
2 changed files with 2 additions and 13 deletions

View File

@@ -8,17 +8,6 @@ from oxi.interfaces.base import BaseDevice
class Qtech(BaseDevice): class Qtech(BaseDevice):
template = "qtech.ttp" template = "qtech.ttp"
def interfaces(self) -> list[dict]:
interfaces_ttp = self.raw["interfaces"]
for item in interfaces_ttp:
if item.get("ip_address") and item.get("netmask"):
ipaddress = ip_interface(
f"{item.get('ip_address')}/{item.get('netmask')}"
)
item["mask"] = ipaddress.network.prefixlen
item.pop("netmask", "Key not found")
return interfaces_ttp
def vlans(self) -> list[dict]: def vlans(self) -> list[dict]:
vlans_ttp = self.raw["vlans"] vlans_ttp = self.raw["vlans"]
vlans = [] vlans = []
@@ -46,4 +35,4 @@ if __name__ == "__main__":
data = file.read() data = file.read()
qtech = Qtech(data) qtech = Qtech(data)
qt = qtech.parse() qt = qtech.parse()
# print(qt) print(qt)

View File

@@ -16,7 +16,7 @@ default_system = {
<group name="interfaces"> <group name="interfaces">
interface {{ interface }} interface {{ interface }}
description {{ description | ORPHRASE }} description {{ description | ORPHRASE }}
ip address {{ ip_address }} {{ netmask }} ip address {{ ip_address }} {{ mask | to_cidr }}
</group> </group>
<group name="vlans"> <group name="vlans">