bbf8b20802
- скрипты: экспорт справочников (export_netbox_refs) и портовой модели (export_netbox_inventory) для составления CSV-импорта устройств/соединений - docs: CSV-снимки справочников + inventory JSON (2026-10-12, сайт «Винный город») - статус/план/конспекты проекта; .gitignore исключает .venv, skc_pdfs, skc_texts
14 lines
573 B
Python
14 lines
573 B
Python
import json
|
|
from django.apps import apps
|
|
from dcim.models import Cable
|
|
|
|
out = {}
|
|
out['cable_fields'] = [f.name for f in Cable._meta.get_fields()]
|
|
out['cables'] = []
|
|
for c in Cable.objects.all():
|
|
t = c.terminations.all().order_by('id')
|
|
out['cables'].append({
|
|
'label': c.label, 'type': c.type, 'status': c.status, 'length': str(c.length), 'len_unit': c.length_unit,
|
|
'terms': [{'end': x.cable_end, 'type': x.termination_type.split('.')[-1], 'obj': str(x.termination)} for x in t]
|
|
})
|
|
print(json.dumps(out, ensure_ascii=False, indent=1, default=str)) |