From 586e52282b536f7f0f6358e9a2b9cb88ff1c094b Mon Sep 17 00:00:00 2001 From: IluaAir Date: Thu, 12 Mar 2026 23:39:47 +0300 Subject: [PATCH] Refactor Quasar interface handling and update TTP template - Enhanced the `interfaces` method in the `Quasar` model to process bulk interfaces, returning a structured list of interface details. - Updated the TTP template to reflect the change from `interfaces` to `bulkinterfaces` for better organization of interface configurations. --- oxi/interfaces/models/quasar.py | 19 ++++++++++++++----- oxi/interfaces/models/templates/quasar.ttp | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/oxi/interfaces/models/quasar.py b/oxi/interfaces/models/quasar.py index f01a005..cce3a97 100644 --- a/oxi/interfaces/models/quasar.py +++ b/oxi/interfaces/models/quasar.py @@ -6,11 +6,20 @@ class Quasar(BaseDevice): template = "quasar.ttp" def interfaces(self) -> list[dict]: - inter = self.raw["interfaces"] - # test = self.raw["mass"] - print(inter) - # print(test) - return inter + ether_interfaces: dict = self.raw["interfaces"] + interfaces: list[dict] = [] + bulk_interfaces: dict = self.raw["bulkinterfaces"] + for key, value in bulk_interfaces.items(): + interfaces.append( + { + "interface": key, + "description": value.get("description"), + "ip_address": value.get("ip_address"), + "mask": value.get("mask"), + } + ) + interfaces.append(ether_interfaces) + return interfaces if __name__ == "__main__": diff --git a/oxi/interfaces/models/templates/quasar.ttp b/oxi/interfaces/models/templates/quasar.ttp index 45ded7a..acbd313 100644 --- a/oxi/interfaces/models/templates/quasar.ttp +++ b/oxi/interfaces/models/templates/quasar.ttp @@ -55,7 +55,7 @@ default_system = { {{ ignore("\s*") }}config {{ interface }} ipv4 address {{ ip_address }}/{{ mask }} gateway {{ gateway }} {{ ignore }} - + {{ ignore("\s*") }}config interface {{ interface | _start_ }} fec none mode force-up enable {{ ignore("\s*") }}config interface {{ interface | _start_ }} description {{ description | ORPHRASE | strip('"')}} \ No newline at end of file