Files
oxipy/oxi/interfaces/models/templates/_template.ttp
IluaAir fe6d0c4ccf Add README and documentation for Oxi API client
- Introduced a comprehensive README file detailing the installation, quick start guide, and API reference for the oxipy Python client.
- Added documentation on extending and overriding device models, including architecture, registration of new devices, and method overriding examples.
- Created a template guide for writing TTP templates, outlining structure, mandatory groups, and practical examples for new device support.
- Included a base template for device configuration parsing, enhancing usability for developers integrating with the Oxi API.
2026-02-24 23:27:14 +03:00

59 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<doc>
Базовый шаблон для нового устройства. Скопируйте этот файл, переименуйте
в <vendor>.ttp и заполните группы под формат конфигурации вашего устройства.
Обязательные группы: system, interfaces.
Опциональная группа: vlans — добавляйте только если устройство поддерживает VLAN.
--- Группа system ---
Должна возвращать одиночный словарь с полями:
model (str) — модель устройства
serial_number (str) — серийный номер
version (str) — версия прошивки
--- Группа interfaces ---
Должна возвращать список словарей. Каждый элемент:
interface (str) — имя интерфейса (alias поля name)
ip_address (str|None) — IPv4-адрес
mask (int|None) — длина префикса (напр. 24)
description (str|None) — описание интерфейса
Если устройство возвращает маску в виде 255.255.255.0, конвертируйте
её в prefix length в методе interfaces() класса устройства.
--- Группа vlans ---
Должна возвращать список словарей. Каждый элемент:
id (int) — номер VLAN (alias поля vlan_id)
description (str|None) — название VLAN (alias поля name)
--- Полезные модификаторы TTP ---
{{ field | ORPHRASE }} — одно слово или фраза до конца строки
{{ field | _start_ }} — начало новой записи группы
{{ field | strip('"') }} — убрать кавычки
{{ field | replace("yes","True") }} — замена подстроки
{{ field | exclude("pattern") }} — пропустить строку при совпадении
{{ ignore }} — захватить и выбросить значение
{{ ignore('.*') }} — выбросить всё до конца строки
Подробнее: docs/templates.md
</doc>
<vars>
default_system = {
"model": "",
"serial_number": "",
"version": ""
}
</vars>
<group name="system" default="default_system">
...
</group>
<group name="interfaces">
...
</group>
<group name="vlans">
...
</group>