- Revised the project description in `pyproject.toml` to better reflect the functionality of the `oxipy` client. - Improved the README.md by adding detailed explanations of the project structure, installation instructions, and usage examples. - Updated documentation files to enhance clarity and organization, including sections on extending models and writing TTP templates. - Adjusted various TTP templates to ensure consistency and accuracy in the parsing of device configurations.
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from oxi.interfaces import BaseDevice, register_parser
|
|
|
|
|
|
@register_parser(["quasar", "qos"])
|
|
class Quasar(BaseDevice):
|
|
template = "quasar.ttp"
|
|
|
|
def interfaces(self) -> list[dict]:
|
|
ether_interface: dict = self.raw.get("interfaces", {})
|
|
interfaces: list[dict] = []
|
|
bulk_interfaces: dict = self.raw.get("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"),
|
|
}
|
|
)
|
|
if ether_interface:
|
|
interfaces.append(ether_interface)
|
|
return interfaces
|
|
|
|
|
|
if __name__ == "__main__":
|
|
with open("./test7.txt") as file:
|
|
data = file.read()
|
|
quasar = Quasar(data)
|
|
qt = quasar.parse()
|
|
print(qt)
|
|
print()
|
|
with open("./test8.txt") as file:
|
|
data = file.read()
|
|
quasar = Quasar(data)
|
|
qt = quasar.parse()
|
|
print(qt)
|