mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-16 16:52:17 -06:00
* Move Module & ModuleType models to a separate file * Add ModuleTypeProfile & related fields * Initial work on JSON schema validation * Add attributes property on ModuleType * Introduce MultipleOfValidator * Introduce JSONSchemaProperty * Enable dynamic form field rendering * Misc cleanup * Fix migration conflict * Ensure deterministic ordering of attriubte fields * Support choices & default values * Include module type attributes on module view * Enable modifying individual attributes via REST API * Enable filtering by attribute values * Add documentation & tests * Schema should be optional * Include attributes column for profiles * Profile is nullable * Include some initial profiles to be installed via migration * Fix migrations conflict * Fix filterset test * Misc cleanup * Fixes #19023: get_field_value() should respect null values in bound forms (#19024) * Skip filters which do not specify a JSON-serializable value * Fix handling of array item types * Fix initial data in schema field during bulk edit * Implement sanity checking for JSON schema definitions * Fall back to filtering by string value
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from django.apps import apps
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import transaction
|
||||
|
||||
@@ -56,3 +57,22 @@ def rebuild_paths(terminations):
|
||||
for cp in cable_paths:
|
||||
cp.delete()
|
||||
create_cablepath(cp.origins)
|
||||
|
||||
|
||||
def update_interface_bridges(device, interface_templates, module=None):
|
||||
"""
|
||||
Used for device and module instantiation. Iterates all InterfaceTemplates with a bridge assigned
|
||||
and applies it to the actual interfaces.
|
||||
"""
|
||||
Interface = apps.get_model('dcim', 'Interface')
|
||||
|
||||
for interface_template in interface_templates.exclude(bridge=None):
|
||||
interface = Interface.objects.get(device=device, name=interface_template.resolve_name(module=module))
|
||||
|
||||
if interface_template.bridge:
|
||||
interface.bridge = Interface.objects.get(
|
||||
device=device,
|
||||
name=interface_template.bridge.resolve_name(module=module)
|
||||
)
|
||||
interface.full_clean()
|
||||
interface.save()
|
||||
|
||||
Reference in New Issue
Block a user