Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions netbox_routing/api/_serializers/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Meta:
'instance',
'area',
'interface',
'network_type',
'passive',
'priority',
'bfd',
Expand Down
20 changes: 19 additions & 1 deletion netbox_routing/choices/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from utilities.choices import ChoiceSet


__all__ = ('AuthenticationChoices',)
__all__ = ('AuthenticationChoices', 'OSPFInterfaceTypeChoices')


class AuthenticationChoices(ChoiceSet):
Expand All @@ -14,3 +14,21 @@ class AuthenticationChoices(ChoiceSet):
(MESSAGE_DIGEST, 'Message Digest'),
(NULL, 'Null Authentication'),
]


class OSPFInterfaceTypeChoices(ChoiceSet):
BROADCAST = 'broadcast'
POINT_TO_POINT = 'point-to-point'
NON_BROADCAST = 'non-broadcast'
POINT_TO_MULTIPOINT = 'point-to-multipoint'
POINT_TO_MULTIPOINT_NON_BROADCAST = 'point-to-multipoint-non-broadcast'
LOOPBACK = 'loopback'

CHOICES = [
(BROADCAST, 'Broadcast'),
(NON_BROADCAST, 'Non-Broadcast'),
(POINT_TO_POINT, 'Point-to-Point'),
(POINT_TO_MULTIPOINT, 'Point-to-Multipoint'),
(LOOPBACK, 'Loopback'),
(POINT_TO_MULTIPOINT_NON_BROADCAST, 'Point-to-Multipoint Non-Broadcast'),
]
6 changes: 6 additions & 0 deletions netbox_routing/filtersets/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,19 @@ class OSPFInterfaceFilterSet(NetBoxModelFilterSet):
to_field_name='name',
label='Area',
)
network_type = django_filters.CharFilter(
field_name='network_type',
lookup_expr='iexact',
label='Network Type',
)

class Meta:
model = OSPFInterface
fields = (
'instance',
'area',
'interface',
'network_type',
'passive',
'bfd',
'priority',
Expand Down
7 changes: 7 additions & 0 deletions netbox_routing/forms/bulk_import/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class OSPFInterfaceImportForm(NetBoxModelImportForm):
to_field_name="name",
help_text=_("Name of interface"),
)
network_type = CSVModelChoiceField(
queryset=OSPFInterface.objects.all(),
required=True,
to_field_name="network_type",
help_text=_("Network Type"),
)

class Meta:
model = OSPFInterface
Expand All @@ -89,6 +95,7 @@ class Meta:
"instance",
"area",
"interface",
"network_type",
"passive",
"priority",
"bfd",
Expand Down
8 changes: 7 additions & 1 deletion netbox_routing/forms/filtersets/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from utilities.forms.fields import TagFilterField, DynamicModelMultipleChoiceField

from netbox_routing.models import OSPFInstance, OSPFArea, OSPFInterface
from netbox_routing import choices


__all__ = (
Expand Down Expand Up @@ -68,7 +69,7 @@ class OSPFInterfaceFilterForm(NetBoxModelFilterSetForm):
model = OSPFInterface
fieldsets = (
FieldSet('q', 'filter_id', 'tag'),
FieldSet('instance_id', 'area_id', name=_('OSPF')),
FieldSet('instance_id', 'area_id', 'network_type', name=_('OSPF')),
FieldSet('device_id', 'interface_id', 'vrf_id', name=_('Device')),
FieldSet('priority', 'bfd', 'authentication', name=_('Attributes')),
)
Expand All @@ -78,6 +79,11 @@ class OSPFInterfaceFilterForm(NetBoxModelFilterSetForm):
selector=True,
label=_('Device'),
)
network_type = forms.ChoiceField(
required=False,
label=_('Network Type'),
choices=choices.OSPFInterfaceTypeChoices,
)
vrf_id = DynamicModelMultipleChoiceField(
queryset=VRF.objects.all(),
required=False,
Expand Down
7 changes: 7 additions & 0 deletions netbox_routing/forms/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from netbox_routing.models import OSPFArea, OSPFInstance, OSPFInterface

from netbox_routing import choices

__all__ = (
'OSPFAreaForm',
Expand Down Expand Up @@ -90,6 +91,11 @@ class OSPFInterfaceForm(NetBoxModelForm):
'device_id': '$device',
},
)
network_type = forms.ChoiceField(
choices=choices.OSPFInterfaceTypeChoices,
label=_('Network Type'),
required=True,
)
comments = CommentField()

class Meta:
Expand All @@ -99,6 +105,7 @@ class Meta:
'instance',
'area',
'interface',
'network_type',
'passive',
'priority',
'bfd',
Expand Down
18 changes: 18 additions & 0 deletions netbox_routing/migrations/0017_ospfinterface_network_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.2.2 on 2025-10-30 12:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('netbox_routing', '0016_ospfinterface_interface_onetoonefield'),
]

operations = [
migrations.AddField(
model_name='ospfinterface',
name='network_type',
field=models.CharField(default='broadcast'),
),
]
7 changes: 7 additions & 0 deletions netbox_routing/models/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ class OSPFInterface(PrimaryModel):
blank=False,
null=False,
)
network_type = models.CharField(
choices=choices.OSPFInterfaceTypeChoices,
default=choices.OSPFInterfaceTypeChoices.BROADCAST,
verbose_name='Network Type',
blank=False,
null=False,
)
passive = models.BooleanField(verbose_name='Passive', blank=True, null=True)
priority = models.IntegerField(blank=True, null=True)
bfd = models.BooleanField(blank=True, null=True, verbose_name='BFD')
Expand Down
1 change: 1 addition & 0 deletions netbox_routing/tables/ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Meta(NetBoxTable.Meta):
'device',
'area',
'interface',
'network_type',
'passive',
'priority',
'bfd',
Expand Down
5 changes: 5 additions & 0 deletions netbox_routing/templates/netbox_routing/ospfinterface.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ <h5 class="card-header"></h5>
{{ object.interface|linkify }}
</td>
</tr>
<tr>
<th scope="row">Network Type</th>
<td>
{{ object.network_type|linkify }}
</td>
</table>
</div>
<div class="card">
Expand Down
1 change: 1 addition & 0 deletions netbox_routing/tests/ospf/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def setUpTestData(cls):
'instance': instance.pk,
'area': area.pk,
'interface': interfaces[3].pk,
'network_type': 'broadcast',
'passive': True,
'priority': 2,
'authentication': 'message-digest',
Expand Down
1 change: 1 addition & 0 deletions netbox_routing/tests/ospf/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def test_interface_with_correct_device(self):
'interface': Interface.objects.first().pk,
'instance': OSPFInstance.objects.first().pk,
'area': OSPFArea.objects.first().pk,
'network_type': 'broadcast',
'passive': True,
}
)
Expand Down
1 change: 1 addition & 0 deletions netbox_routing/tests/ospf/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def setUpTestData(cls):
'area': areas[3].pk,
'instance': instances[3].pk,
'passive': True,
'network_type': 'broadcast',
}

cls.bulk_edit_data = {
Expand Down