vinogorod: проект СКС «Винный город» — скрипты, документация, снимки справочников NetBox
- скрипты: экспорт справочников (export_netbox_refs) и портовой модели (export_netbox_inventory) для составления CSV-импорта устройств/соединений - docs: CSV-снимки справочников + inventory JSON (2026-10-12, сайт «Винный город») - статус/план/конспекты проекта; .gitignore исключает .venv, skc_pdfs, skc_texts
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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))
|
||||
Reference in New Issue
Block a user