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.
This commit is contained in:
@@ -6,11 +6,20 @@ class Quasar(BaseDevice):
|
|||||||
template = "quasar.ttp"
|
template = "quasar.ttp"
|
||||||
|
|
||||||
def interfaces(self) -> list[dict]:
|
def interfaces(self) -> list[dict]:
|
||||||
inter = self.raw["interfaces"]
|
ether_interfaces: dict = self.raw["interfaces"]
|
||||||
# test = self.raw["mass"]
|
interfaces: list[dict] = []
|
||||||
print(inter)
|
bulk_interfaces: dict = self.raw["bulkinterfaces"]
|
||||||
# print(test)
|
for key, value in bulk_interfaces.items():
|
||||||
return inter
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ default_system = {
|
|||||||
{{ ignore("\s*") }}config {{ interface }} ipv4 address {{ ip_address }}/{{ mask }} gateway {{ gateway }} {{ ignore }}
|
{{ ignore("\s*") }}config {{ interface }} ipv4 address {{ ip_address }}/{{ mask }} gateway {{ gateway }} {{ ignore }}
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group name="interfaces.{{ interface }}">
|
<group name="bulkinterfaces.{{ interface }}">
|
||||||
{{ ignore("\s*") }}config interface {{ interface | _start_ }} fec none mode force-up enable
|
{{ ignore("\s*") }}config interface {{ interface | _start_ }} fec none mode force-up enable
|
||||||
{{ ignore("\s*") }}config interface {{ interface | _start_ }} description {{ description | ORPHRASE | strip('"')}}
|
{{ ignore("\s*") }}config interface {{ interface | _start_ }} description {{ description | ORPHRASE | strip('"')}}
|
||||||
</group>
|
</group>
|
||||||
Reference in New Issue
Block a user