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:
@@ -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)
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
Reference in New Issue
Block a user