Skip to content

Commit

Permalink
Merge pull request #153 from k01ek/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
k01ek authored Sep 19, 2023
2 parents 0eed31c + 25dfb58 commit 57a8b99
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PYTHON_VER?=3.8
NETBOX_VER?=v3.5.1
NETBOX_VER?=v3.6.1

NAME=netbox-bgp

Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ This plugin provide following Models:

## Compatibility

| | |
|-------------|-------|
| NetBox 2.10 | 0.3.9 |
| NetBox 2.11 | 0.3.9 |
| NetBox 3.0 | 0.4.3 |
| NetBox 3.1 | 0.5.0 |
| NetBox 3.2 | >= 0.6.0 |
| NetBox 3.3 | >= 0.8.1 |
| NetBox 3.4 | >= 0.9.0 |
| | |
|-------------|-----------|
| NetBox 3.4 | >= 0.9.0 |
| NetBox 3.5 | >= 0.10.0 |
| NetBox 3.6 | >= 0.11.0 |

## Installation

Expand Down
2 changes: 1 addition & 1 deletion netbox_bgp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BGPConfig(PluginConfig):
base_url = 'bgp'
required_settings = []
min_version = '3.5.0'
max_version = '3.5.99'
max_version = '3.6.99'
default_settings = {
'device_ext_page': 'right',
'top_level_menu' : False,
Expand Down
52 changes: 38 additions & 14 deletions netbox_bgp/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from netbox.api.serializers import NetBoxModelSerializer
from dcim.api.nested_serializers import NestedSiteSerializer, NestedDeviceSerializer
from tenancy.api.nested_serializers import NestedTenantSerializer
from ipam.api.nested_serializers import NestedIPAddressSerializer, NestedASNSerializer
from ipam.api.nested_serializers import NestedIPAddressSerializer, NestedASNSerializer, NestedPrefixSerializer


from netbox_bgp.models import (
Expand All @@ -30,7 +30,7 @@ def to_representation(self, value):

class RoutingPolicySerializer(NetBoxModelSerializer):
class Meta:
model = RoutingPolicy
model = RoutingPolicy
fields = '__all__'


Expand All @@ -39,8 +39,8 @@ class NestedRoutingPolicySerializer(WritableNestedSerializer):

class Meta:
model = RoutingPolicy
fields = ['id', 'url', 'name', 'description']

fields = ['id', 'url', 'name', 'display', 'description']
validators = []

class BGPPeerGroupSerializer(NetBoxModelSerializer):
import_policies = SerializedPKRelatedField(
Expand Down Expand Up @@ -147,17 +147,14 @@ class Meta:
'value', 'site', 'role'
]

class NestedCommunitySerializer(WritableNestedSerializer):
url = HyperlinkedIdentityField(view_name='plugins:netbox_bgp:community')

class RoutingPolicyRuleSerializer(NetBoxModelSerializer):
class Meta:
model = RoutingPolicyRule
fields = '__all__'


class PrefixListSerializer(NetBoxModelSerializer):
class Meta:
model = PrefixList
fields = '__all__'
model = Community
fields = [
'id', 'url', 'display', 'value'
]


class NestedPrefixListSerializer(WritableNestedSerializer):
Expand All @@ -167,9 +164,36 @@ class Meta:
model = PrefixList
fields = ['id', 'url', 'display', 'name']

class PrefixListSerializer(NetBoxModelSerializer):
class Meta:
model = PrefixList
fields = '__all__'

class RoutingPolicyRuleSerializer(NetBoxModelSerializer):
match_ip_address = SerializedPKRelatedField(
queryset=PrefixList.objects.all(),
serializer=NestedPrefixListSerializer,
required=False,
allow_null=True,
many=True
)
routing_policy = NestedRoutingPolicySerializer()
match_community = SerializedPKRelatedField(
queryset=Community.objects.all(),
serializer=NestedCommunitySerializer,
required=False,
allow_null=True,
many=True
)


class Meta:
model = RoutingPolicyRule
fields = '__all__'

class PrefixListRuleSerializer(NetBoxModelSerializer):
prefix_list = NestedPrefixListSerializer()
prefix_list = NestedPrefixListSerializer()
prefix = NestedPrefixSerializer(required=False, allow_null=True)

class Meta:
model = PrefixListRule
Expand Down
17 changes: 9 additions & 8 deletions netbox_bgp/api/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rest_framework.viewsets import ModelViewSet
from netbox.api.viewsets import NetBoxModelViewSet

from .serializers import (
BGPSessionSerializer, RoutingPolicySerializer, BGPPeerGroupSerializer,
Expand All @@ -11,42 +11,43 @@
)


class BGPSessionViewSet(ModelViewSet):
class BGPSessionViewSet(NetBoxModelViewSet):
queryset = BGPSession.objects.all()
serializer_class = BGPSessionSerializer
filterset_class = BGPSessionFilterSet


class RoutingPolicyViewSet(ModelViewSet):
class RoutingPolicyViewSet(NetBoxModelViewSet):
queryset = RoutingPolicy.objects.all()
serializer_class = RoutingPolicySerializer
filterset_class = RoutingPolicyFilterSet


class RoutingPolicyRuleViewSet(ModelViewSet):
class RoutingPolicyRuleViewSet(NetBoxModelViewSet):
queryset = RoutingPolicyRule.objects.all()
serializer_class = RoutingPolicyRuleSerializer
filterset_class = RoutingPolicyRuleFilterSet


class BGPPeerGroupViewSet(ModelViewSet):
class BGPPeerGroupViewSet(NetBoxModelViewSet):
queryset = BGPPeerGroup.objects.all()
serializer_class = BGPPeerGroupSerializer
filterset_class = BGPPeerGroupFilterSet


class CommunityViewSet(ModelViewSet):
class CommunityViewSet(NetBoxModelViewSet):
queryset = Community.objects.all()
serializer_class = CommunitySerializer
filterset_class = CommunityFilterSet


class PrefixListViewSet(ModelViewSet):
class PrefixListViewSet(NetBoxModelViewSet):
queryset = PrefixList.objects.all()
serializer_class = PrefixListSerializer
filterset_class = PrefixListFilterSet

class PrefixListRuleViewSet(ModelViewSet):
class PrefixListRuleViewSet(NetBoxModelViewSet):

queryset = PrefixListRule.objects.all()
serializer_class = PrefixListRuleSerializer
filterset_class = PrefixListRuleFilterSet
2 changes: 1 addition & 1 deletion netbox_bgp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class PrefixListForm(NetBoxModelForm):

class Meta:
model = PrefixList
fields = ['name', 'description', 'tags']
fields = ['name', 'description', 'family', 'tags']


class PrefixListRuleForm(NetBoxModelForm):
Expand Down
18 changes: 18 additions & 0 deletions netbox_bgp/migrations/0029_netbox_bgp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.9 on 2023-09-19 05:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('netbox_bgp', '0028_netbox_bgp'),
]

operations = [
migrations.AlterField(
model_name='bgpsession',
name='name',
field=models.CharField(blank=True, max_length=256, null=True),
),
]
2 changes: 1 addition & 1 deletion netbox_bgp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_absolute_url(self):

class BGPSession(NetBoxModel):
name = models.CharField(
max_length=64,
max_length=256,
blank=True,
null=True
)
Expand Down
2 changes: 1 addition & 1 deletion netbox_bgp/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.10.2"
__version__ = "0.11.0"

0 comments on commit 57a8b99

Please sign in to comment.