That's correct.
I definitely wouldn't want interfaces to be destroyed and created when a device type is changed. I have the opposite situation to you: I might create a device of type "unknown", add a bunch of interfaces and configure them, and later change the device to a more specific type "foo". I wouldn't want to see all that work destroyed.
However I did have a case where I added ports to a Device Type and wanted to see them added to all instances of that Device too. Ideally there would be some sort of 'resync components' button which would add missing components, and update existing components with matching type and name.
What I did was to write a script, which at least creates all the missing interfaces on all devices - where "missing" is defined as "no such port exists with the given name"
import
django
import
os
os.environ.setdefault(
'DJANGO_SETTINGS_MODULE'
,
'netbox.settings'
)
django.setup()
from dcim.models
import
Device, ConsolePort, ConsoleServerPort, PowerPort, PowerOutlet, Interface, RearPort, FrontPort, DeviceBay
for
device
in
Device.objects.all():
# Based on Device.save()
ConsolePort.objects.bulk_create(
device.device_type.consoleport_templates.all()
)
ConsoleServerPort.objects.bulk_create(
[ConsoleServerPort(device=device, name=template.name)
for
template
in
device.device_type.consoleserverport_templates.all()
)
PowerPort.objects.bulk_create(
device.device_type.powerport_templates.all()
)
PowerOutlet.objects.bulk_create(
device.device_type.poweroutlet_templates.all()
)
Interface.objects.bulk_create(
[Interface(device=device, name=template.name, form_factor=template.form_factor,
mgmt_only=template.mgmt_only)
for
template
in
device.device_type.interface_templates.all()
)
RearPort.objects.bulk_create([
RearPort(
device=device,
type
=template.
type
,
positions=template.positions
)
for
template
in
device.device_type.rearport_templates.all()
])
FrontPort.objects.bulk_create([
FrontPort(
device=device,
type
=template.
type
,
rear_port_position=template.rear_port_position,
)
for
template
in
device.device_type.frontport_templates.all()
])
DeviceBay.objects.bulk_create(
device.device_type.device_bay_templates.all()
)
Brian.