21 lines
589 B
Python
21 lines
589 B
Python
import pynetbox
|
|
|
|
from settings import settings
|
|
|
|
netbox = pynetbox.api(
|
|
settings.url,
|
|
token=settings.token)
|
|
netbox.http_session.verify = False
|
|
|
|
filters = {
|
|
"has_primary_ip": "true", # или True, зависит от API
|
|
"tenant": "vimpelcom", # имя или ID арендатора
|
|
"role": "Kommutator", # роль устройства
|
|
}
|
|
|
|
# Передаём словарь в filter через **
|
|
devices = netbox.dcim.devices.filter(**filters)
|
|
|
|
# Вывод результатов
|
|
for device in devices:
|
|
print(f"{device.name} (IP: {device.primary_ip})") |