netbox-routing-plugin 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- netbox_routing_plugin/__init__.py +29 -0
- netbox_routing_plugin/api/__init__.py +0 -0
- netbox_routing_plugin/api/_serializers/__init__.py +0 -0
- netbox_routing_plugin/api/_serializers/bgp.py +408 -0
- netbox_routing_plugin/api/_serializers/community.py +141 -0
- netbox_routing_plugin/api/_serializers/eigrp.py +169 -0
- netbox_routing_plugin/api/_serializers/eigrp_redistribution.py +45 -0
- netbox_routing_plugin/api/_serializers/eigrp_summary.py +37 -0
- netbox_routing_plugin/api/_serializers/isis.py +486 -0
- netbox_routing_plugin/api/_serializers/isis_routes.py +103 -0
- netbox_routing_plugin/api/_serializers/objects.py +411 -0
- netbox_routing_plugin/api/_serializers/ospf.py +458 -0
- netbox_routing_plugin/api/_serializers/static.py +107 -0
- netbox_routing_plugin/api/field_serializers/__init__.py +3 -0
- netbox_routing_plugin/api/field_serializers/ip.py +28 -0
- netbox_routing_plugin/api/serializers.py +59 -0
- netbox_routing_plugin/api/urls.py +60 -0
- netbox_routing_plugin/api/views/__init__.py +95 -0
- netbox_routing_plugin/api/views/bgp.py +157 -0
- netbox_routing_plugin/api/views/community.py +28 -0
- netbox_routing_plugin/api/views/eigrp.py +51 -0
- netbox_routing_plugin/api/views/eigrp_redistribution.py +19 -0
- netbox_routing_plugin/api/views/eigrp_summary.py +19 -0
- netbox_routing_plugin/api/views/isis.py +194 -0
- netbox_routing_plugin/api/views/objects.py +139 -0
- netbox_routing_plugin/api/views/ospf.py +147 -0
- netbox_routing_plugin/api/views/static.py +10 -0
- netbox_routing_plugin/choices/__init__.py +6 -0
- netbox_routing_plugin/choices/base.py +15 -0
- netbox_routing_plugin/choices/bgp.py +134 -0
- netbox_routing_plugin/choices/eigrp.py +40 -0
- netbox_routing_plugin/choices/isis.py +325 -0
- netbox_routing_plugin/choices/objects.py +65 -0
- netbox_routing_plugin/choices/ospf.py +203 -0
- netbox_routing_plugin/choices/static.py +22 -0
- netbox_routing_plugin/constants/__init__.py +3 -0
- netbox_routing_plugin/constants/eigrp.py +14 -0
- netbox_routing_plugin/constants/isis.py +30 -0
- netbox_routing_plugin/constants/ospf.py +124 -0
- netbox_routing_plugin/fields/__init__.py +0 -0
- netbox_routing_plugin/fields/generic.py +13 -0
- netbox_routing_plugin/fields/ip.py +55 -0
- netbox_routing_plugin/filtersets/__init__.py +60 -0
- netbox_routing_plugin/filtersets/bgp.py +555 -0
- netbox_routing_plugin/filtersets/community.py +146 -0
- netbox_routing_plugin/filtersets/eigrp.py +303 -0
- netbox_routing_plugin/filtersets/eigrp_redistribution.py +20 -0
- netbox_routing_plugin/filtersets/eigrp_summary.py +20 -0
- netbox_routing_plugin/filtersets/isis.py +701 -0
- netbox_routing_plugin/filtersets/objects.py +311 -0
- netbox_routing_plugin/filtersets/ospf.py +772 -0
- netbox_routing_plugin/filtersets/static.py +163 -0
- netbox_routing_plugin/forms/__init__.py +178 -0
- netbox_routing_plugin/forms/bgp.py +4 -0
- netbox_routing_plugin/forms/bulk_edit/__init__.py +61 -0
- netbox_routing_plugin/forms/bulk_edit/base.py +17 -0
- netbox_routing_plugin/forms/bulk_edit/bgp.py +448 -0
- netbox_routing_plugin/forms/bulk_edit/community.py +81 -0
- netbox_routing_plugin/forms/bulk_edit/eigrp.py +148 -0
- netbox_routing_plugin/forms/bulk_edit/isis.py +809 -0
- netbox_routing_plugin/forms/bulk_edit/objects.py +207 -0
- netbox_routing_plugin/forms/bulk_edit/ospf.py +845 -0
- netbox_routing_plugin/forms/bulk_edit/static.py +80 -0
- netbox_routing_plugin/forms/bulk_import/__init__.py +62 -0
- netbox_routing_plugin/forms/bulk_import/bgp.py +513 -0
- netbox_routing_plugin/forms/bulk_import/community.py +189 -0
- netbox_routing_plugin/forms/bulk_import/eigrp.py +171 -0
- netbox_routing_plugin/forms/bulk_import/isis.py +537 -0
- netbox_routing_plugin/forms/bulk_import/objects.py +407 -0
- netbox_routing_plugin/forms/bulk_import/ospf.py +673 -0
- netbox_routing_plugin/forms/bulk_import/static.py +97 -0
- netbox_routing_plugin/forms/community.py +4 -0
- netbox_routing_plugin/forms/filtersets/__init__.py +107 -0
- netbox_routing_plugin/forms/filtersets/bgp.py +480 -0
- netbox_routing_plugin/forms/filtersets/community.py +101 -0
- netbox_routing_plugin/forms/filtersets/eigrp.py +195 -0
- netbox_routing_plugin/forms/filtersets/eigrp_redistribution.py +11 -0
- netbox_routing_plugin/forms/filtersets/eigrp_summary.py +11 -0
- netbox_routing_plugin/forms/filtersets/isis.py +491 -0
- netbox_routing_plugin/forms/filtersets/objects.py +222 -0
- netbox_routing_plugin/forms/filtersets/ospf.py +756 -0
- netbox_routing_plugin/forms/filtersets/static.py +103 -0
- netbox_routing_plugin/forms/model_objects/__init__.py +7 -0
- netbox_routing_plugin/forms/model_objects/bgp.py +639 -0
- netbox_routing_plugin/forms/model_objects/community.py +168 -0
- netbox_routing_plugin/forms/model_objects/eigrp.py +247 -0
- netbox_routing_plugin/forms/model_objects/eigrp_redistribution.py +46 -0
- netbox_routing_plugin/forms/model_objects/eigrp_summary.py +35 -0
- netbox_routing_plugin/forms/model_objects/isis.py +1140 -0
- netbox_routing_plugin/forms/model_objects/objects.py +593 -0
- netbox_routing_plugin/forms/model_objects/ospf.py +968 -0
- netbox_routing_plugin/forms/model_objects/static.py +106 -0
- netbox_routing_plugin/forms/objects.py +4 -0
- netbox_routing_plugin/forms/widgets.py +13 -0
- netbox_routing_plugin/graphql/__init__.py +0 -0
- netbox_routing_plugin/graphql/bgp/__init__.py +0 -0
- netbox_routing_plugin/graphql/bgp/filters.py +67 -0
- netbox_routing_plugin/graphql/bgp/types.py +349 -0
- netbox_routing_plugin/graphql/community/__init__.py +0 -0
- netbox_routing_plugin/graphql/community/filters.py +63 -0
- netbox_routing_plugin/graphql/community/types.py +47 -0
- netbox_routing_plugin/graphql/eigrp/__init__.py +0 -0
- netbox_routing_plugin/graphql/eigrp/filters.py +98 -0
- netbox_routing_plugin/graphql/eigrp/routes.py +85 -0
- netbox_routing_plugin/graphql/eigrp/types.py +89 -0
- netbox_routing_plugin/graphql/filter_mixins.py +41 -0
- netbox_routing_plugin/graphql/filters.py +60 -0
- netbox_routing_plugin/graphql/isis/__init__.py +0 -0
- netbox_routing_plugin/graphql/isis/filters.py +155 -0
- netbox_routing_plugin/graphql/isis/types.py +321 -0
- netbox_routing_plugin/graphql/objects/__init__.py +0 -0
- netbox_routing_plugin/graphql/objects/filters.py +116 -0
- netbox_routing_plugin/graphql/objects/types.py +148 -0
- netbox_routing_plugin/graphql/ospf/__init__.py +0 -0
- netbox_routing_plugin/graphql/ospf/filters.py +193 -0
- netbox_routing_plugin/graphql/ospf/types.py +322 -0
- netbox_routing_plugin/graphql/schema.py +317 -0
- netbox_routing_plugin/graphql/static/__init__.py +0 -0
- netbox_routing_plugin/graphql/static/filters.py +21 -0
- netbox_routing_plugin/graphql/static/types.py +26 -0
- netbox_routing_plugin/graphql/types.py +60 -0
- netbox_routing_plugin/helpers/__init__.py +0 -0
- netbox_routing_plugin/helpers/aspath.py +171 -0
- netbox_routing_plugin/helpers/community.py +241 -0
- netbox_routing_plugin/helpers/isis.py +164 -0
- netbox_routing_plugin/helpers/prefix_list.py +352 -0
- netbox_routing_plugin/helpers/redistribution.py +74 -0
- netbox_routing_plugin/helpers/route_policy.py +227 -0
- netbox_routing_plugin/migrations/0001_initial.py +6015 -0
- netbox_routing_plugin/migrations/__init__.py +0 -0
- netbox_routing_plugin/models/__init__.py +102 -0
- netbox_routing_plugin/models/base.py +5 -0
- netbox_routing_plugin/models/bgp.py +1878 -0
- netbox_routing_plugin/models/community.py +301 -0
- netbox_routing_plugin/models/eigrp.py +820 -0
- netbox_routing_plugin/models/isis.py +2536 -0
- netbox_routing_plugin/models/mixins.py +2 -0
- netbox_routing_plugin/models/objects.py +709 -0
- netbox_routing_plugin/models/ospf.py +2955 -0
- netbox_routing_plugin/models/policy.py +38 -0
- netbox_routing_plugin/models/static.py +245 -0
- netbox_routing_plugin/navigation/__init__.py +26 -0
- netbox_routing_plugin/navigation/bfd.py +22 -0
- netbox_routing_plugin/navigation/bgp.py +41 -0
- netbox_routing_plugin/navigation/community.py +48 -0
- netbox_routing_plugin/navigation/eigrp.py +112 -0
- netbox_routing_plugin/navigation/isis.py +60 -0
- netbox_routing_plugin/navigation/objects.py +151 -0
- netbox_routing_plugin/navigation/ospf.py +238 -0
- netbox_routing_plugin/navigation/static.py +28 -0
- netbox_routing_plugin/search/__init__.py +96 -0
- netbox_routing_plugin/search/bgp.py +108 -0
- netbox_routing_plugin/search/community.py +40 -0
- netbox_routing_plugin/search/eigrp.py +55 -0
- netbox_routing_plugin/search/eigrp_routes.py +28 -0
- netbox_routing_plugin/search/isis.py +193 -0
- netbox_routing_plugin/search/objects.py +85 -0
- netbox_routing_plugin/search/ospf.py +149 -0
- netbox_routing_plugin/search/static.py +18 -0
- netbox_routing_plugin/signals.py +150 -0
- netbox_routing_plugin/tables/__init__.py +9 -0
- netbox_routing_plugin/tables/bgp.py +381 -0
- netbox_routing_plugin/tables/community.py +143 -0
- netbox_routing_plugin/tables/eigrp.py +112 -0
- netbox_routing_plugin/tables/eigrp_redistribution.py +40 -0
- netbox_routing_plugin/tables/eigrp_summary.py +17 -0
- netbox_routing_plugin/tables/isis.py +491 -0
- netbox_routing_plugin/tables/objects.py +314 -0
- netbox_routing_plugin/tables/ospf.py +490 -0
- netbox_routing_plugin/tables/static.py +62 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/aspath_duplicate.html +25 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/aspath_match.html +35 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/aspath_match_results.html +64 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/aspath_resequence.html +25 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/buttons/duplicate.html +5 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/buttons/resequence.html +5 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/community_match.html +35 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/community_match_results.html +56 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/communitylist_duplicate.html +25 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/device_routing.html +21 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/panels/bgp_no_policy.html +17 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/panels/overlaps.html +29 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/panels/prefix_list_references.html +23 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/panels/unreachable.html +17 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/prefix_match.html +35 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/prefix_match_results.html +54 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/prefixlist_duplicate.html +25 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/prefixlist_resequence.html +25 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/routepolicy_duplicate.html +25 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/routepolicy_match.html +71 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/routepolicy_match_results.html +51 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/routepolicy_resequence.html +25 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/widgets/radio.html +1 -0
- netbox_routing_plugin/templates/netbox_routing_plugin/widgets/radio_option.html +2 -0
- netbox_routing_plugin/ui/__init__.py +82 -0
- netbox_routing_plugin/ui/attributes/__init__.py +3 -0
- netbox_routing_plugin/ui/attributes/gfk.py +18 -0
- netbox_routing_plugin/ui/panels/__init__.py +85 -0
- netbox_routing_plugin/ui/panels/bgp.py +286 -0
- netbox_routing_plugin/ui/panels/community.py +35 -0
- netbox_routing_plugin/ui/panels/core.py +49 -0
- netbox_routing_plugin/ui/panels/eigrp.py +86 -0
- netbox_routing_plugin/ui/panels/eigrp_redistribution.py +22 -0
- netbox_routing_plugin/ui/panels/eigrp_summary.py +12 -0
- netbox_routing_plugin/ui/panels/isis.py +337 -0
- netbox_routing_plugin/ui/panels/objects.py +131 -0
- netbox_routing_plugin/ui/panels/ospf.py +353 -0
- netbox_routing_plugin/ui/panels/static.py +33 -0
- netbox_routing_plugin/urls.py +381 -0
- netbox_routing_plugin/views/__init__.py +251 -0
- netbox_routing_plugin/views/bgp.py +1388 -0
- netbox_routing_plugin/views/community.py +512 -0
- netbox_routing_plugin/views/core.py +134 -0
- netbox_routing_plugin/views/eigrp.py +455 -0
- netbox_routing_plugin/views/eigrp_redistribution.py +83 -0
- netbox_routing_plugin/views/eigrp_summary.py +73 -0
- netbox_routing_plugin/views/isis.py +1318 -0
- netbox_routing_plugin/views/objects.py +1503 -0
- netbox_routing_plugin/views/ospf.py +1022 -0
- netbox_routing_plugin/views/static.py +113 -0
- netbox_routing_plugin-1.0.0.dist-info/METADATA +173 -0
- netbox_routing_plugin-1.0.0.dist-info/RECORD +225 -0
- netbox_routing_plugin-1.0.0.dist-info/WHEEL +5 -0
- netbox_routing_plugin-1.0.0.dist-info/licenses/LICENSE +201 -0
- netbox_routing_plugin-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from netbox.plugins import PluginConfig
|
|
2
|
+
from importlib.metadata import metadata
|
|
3
|
+
|
|
4
|
+
plugin = metadata('netbox-routing-plugin')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class NetboxRouting(PluginConfig):
|
|
8
|
+
# The distribution is published as netbox-routing-plugin, but the app
|
|
9
|
+
# label, URLs and migrations stay under the module name.
|
|
10
|
+
name = 'netbox_routing_plugin'
|
|
11
|
+
verbose_name = 'Netbox Routing Protocols'
|
|
12
|
+
description = plugin.get('Summary')
|
|
13
|
+
version = plugin.get('Version')
|
|
14
|
+
author = plugin.get('Author')
|
|
15
|
+
author_email = plugin.get('Author-email')
|
|
16
|
+
base_url = 'routing'
|
|
17
|
+
min_version = '4.7.0'
|
|
18
|
+
required_settings = []
|
|
19
|
+
caching_config = {}
|
|
20
|
+
default_settings = {}
|
|
21
|
+
graphql_schema = 'graphql.schema.schema'
|
|
22
|
+
|
|
23
|
+
def ready(self):
|
|
24
|
+
super().ready()
|
|
25
|
+
|
|
26
|
+
from netbox_routing_plugin import signals # noqa: F401
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
config = NetboxRouting
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
from rest_framework import serializers
|
|
2
|
+
|
|
3
|
+
from dcim.api.serializers_.devices import DeviceSerializer
|
|
4
|
+
from ipam.api.serializers_.asns import ASNSerializer
|
|
5
|
+
from dcim.api.serializers_.device_components import InterfaceSerializer
|
|
6
|
+
from ipam.api.serializers_.ip import IPAddressSerializer, PrefixSerializer
|
|
7
|
+
from ipam.api.serializers_.vrfs import VRFSerializer
|
|
8
|
+
from ipam.models import ASN
|
|
9
|
+
from netbox.api.fields import SerializedPKRelatedField
|
|
10
|
+
from netbox.api.serializers import NetBoxModelSerializer
|
|
11
|
+
from tenancy.api.serializers_.tenants import TenantSerializer
|
|
12
|
+
|
|
13
|
+
from netbox_routing_plugin.api._serializers.objects import (
|
|
14
|
+
PrefixListSerializer,
|
|
15
|
+
RoutePolicySerializer,
|
|
16
|
+
)
|
|
17
|
+
from netbox_routing_plugin.models import (
|
|
18
|
+
EIGRPAddressFamily,
|
|
19
|
+
ISISInstance,
|
|
20
|
+
OSPFInstance,
|
|
21
|
+
)
|
|
22
|
+
from netbox_routing_plugin.models.bgp import *
|
|
23
|
+
|
|
24
|
+
__all__ = (
|
|
25
|
+
'BGPInstanceSerializer',
|
|
26
|
+
'BGPAddressFamilySerializer',
|
|
27
|
+
'BGPPeerGroupSerializer',
|
|
28
|
+
'BGPListenRangeSerializer',
|
|
29
|
+
'BGPRedistributionSerializer',
|
|
30
|
+
'BGPOriginatedNetworkSerializer',
|
|
31
|
+
'BGPAggregateSerializer',
|
|
32
|
+
'BGPPeerSerializer',
|
|
33
|
+
'BGPPeerAddressFamilySerializer',
|
|
34
|
+
'BFDProfileSerializer',
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
_COMMON = (
|
|
38
|
+
'description',
|
|
39
|
+
'comments',
|
|
40
|
+
'tags',
|
|
41
|
+
'custom_fields',
|
|
42
|
+
'created',
|
|
43
|
+
'last_updated',
|
|
44
|
+
)
|
|
45
|
+
_SESSION = (
|
|
46
|
+
'remote_as',
|
|
47
|
+
'local_as',
|
|
48
|
+
'enabled',
|
|
49
|
+
'bfd',
|
|
50
|
+
'ebgp_multihop',
|
|
51
|
+
'ttl_security_hops',
|
|
52
|
+
'passive',
|
|
53
|
+
'as_override',
|
|
54
|
+
'soft_reconfiguration_inbound',
|
|
55
|
+
'graceful_shutdown',
|
|
56
|
+
'import_policy',
|
|
57
|
+
'export_policy',
|
|
58
|
+
'passphrase',
|
|
59
|
+
'passphrase_md5',
|
|
60
|
+
'show_md5',
|
|
61
|
+
'route_reflector_client',
|
|
62
|
+
'extended_nexthop',
|
|
63
|
+
'keepalive',
|
|
64
|
+
'hold_time',
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class BGPInstanceSerializer(NetBoxModelSerializer):
|
|
69
|
+
url = serializers.HyperlinkedIdentityField(
|
|
70
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgpinstance-detail'
|
|
71
|
+
)
|
|
72
|
+
device = DeviceSerializer(nested=True)
|
|
73
|
+
vrf = VRFSerializer(nested=True, required=False, allow_null=True)
|
|
74
|
+
asn = ASNSerializer(nested=True)
|
|
75
|
+
confederation_identifier = ASNSerializer(
|
|
76
|
+
nested=True, required=False, allow_null=True
|
|
77
|
+
)
|
|
78
|
+
confederation_peers = SerializedPKRelatedField(
|
|
79
|
+
queryset=ASN.objects.all(),
|
|
80
|
+
serializer=ASNSerializer,
|
|
81
|
+
nested=True,
|
|
82
|
+
required=False,
|
|
83
|
+
many=True,
|
|
84
|
+
)
|
|
85
|
+
import_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
86
|
+
export_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
87
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
88
|
+
|
|
89
|
+
class Meta:
|
|
90
|
+
model = BGPInstance
|
|
91
|
+
fields = (
|
|
92
|
+
'url',
|
|
93
|
+
'id',
|
|
94
|
+
'display',
|
|
95
|
+
'name',
|
|
96
|
+
'device',
|
|
97
|
+
'vrf',
|
|
98
|
+
'asn',
|
|
99
|
+
'router_id',
|
|
100
|
+
'asdot',
|
|
101
|
+
'cluster_id',
|
|
102
|
+
'confederation_identifier',
|
|
103
|
+
'confederation_peers',
|
|
104
|
+
'graceful_restart',
|
|
105
|
+
'graceful_restart_time',
|
|
106
|
+
'graceful_restart_stale_time',
|
|
107
|
+
'graceful_restart_helper_only',
|
|
108
|
+
'import_policy',
|
|
109
|
+
'export_policy',
|
|
110
|
+
'tenant',
|
|
111
|
+
*_COMMON,
|
|
112
|
+
)
|
|
113
|
+
brief_fields = ('url', 'id', 'display', 'name', 'device', 'vrf', 'asn')
|
|
114
|
+
|
|
115
|
+
def validate(self, data):
|
|
116
|
+
data = super().validate(data)
|
|
117
|
+
instance = self.instance
|
|
118
|
+
peers = data.get(
|
|
119
|
+
'confederation_peers',
|
|
120
|
+
instance.confederation_peers.all() if instance else [],
|
|
121
|
+
)
|
|
122
|
+
errors = BGPInstance.confederation_errors(
|
|
123
|
+
data.get('asn', instance.asn if instance else None),
|
|
124
|
+
data.get(
|
|
125
|
+
'confederation_identifier',
|
|
126
|
+
instance.confederation_identifier if instance else None,
|
|
127
|
+
),
|
|
128
|
+
peers,
|
|
129
|
+
)
|
|
130
|
+
if errors:
|
|
131
|
+
raise serializers.ValidationError(errors)
|
|
132
|
+
return data
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class BGPAddressFamilySerializer(NetBoxModelSerializer):
|
|
136
|
+
url = serializers.HyperlinkedIdentityField(
|
|
137
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgpaddressfamily-detail'
|
|
138
|
+
)
|
|
139
|
+
instance = BGPInstanceSerializer(nested=True)
|
|
140
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
141
|
+
|
|
142
|
+
class Meta:
|
|
143
|
+
model = BGPAddressFamily
|
|
144
|
+
fields = (
|
|
145
|
+
'url',
|
|
146
|
+
'id',
|
|
147
|
+
'display',
|
|
148
|
+
'instance',
|
|
149
|
+
'address_family',
|
|
150
|
+
'maximum_paths',
|
|
151
|
+
'default_metric',
|
|
152
|
+
'default_originate',
|
|
153
|
+
'auto_summary',
|
|
154
|
+
'distance_ebgp',
|
|
155
|
+
'distance_ibgp',
|
|
156
|
+
'additional_paths_send',
|
|
157
|
+
'additional_paths_receive',
|
|
158
|
+
'additional_paths_install',
|
|
159
|
+
'long_lived_stale_time',
|
|
160
|
+
'tenant',
|
|
161
|
+
*_COMMON,
|
|
162
|
+
)
|
|
163
|
+
brief_fields = ('url', 'id', 'display', 'instance', 'address_family')
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class BGPPeerGroupSerializer(NetBoxModelSerializer):
|
|
167
|
+
url = serializers.HyperlinkedIdentityField(
|
|
168
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgppeergroup-detail'
|
|
169
|
+
)
|
|
170
|
+
instance = BGPInstanceSerializer(nested=True)
|
|
171
|
+
remote_as = ASNSerializer(nested=True, required=False, allow_null=True)
|
|
172
|
+
local_as = ASNSerializer(nested=True, required=False, allow_null=True)
|
|
173
|
+
bfd = serializers.PrimaryKeyRelatedField(
|
|
174
|
+
queryset=BFDProfile.objects.all(), required=False, allow_null=True
|
|
175
|
+
)
|
|
176
|
+
passphrase_md5 = serializers.CharField(
|
|
177
|
+
source='md5_digest', read_only=True, allow_null=True
|
|
178
|
+
)
|
|
179
|
+
import_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
180
|
+
export_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
181
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
182
|
+
|
|
183
|
+
class Meta:
|
|
184
|
+
model = BGPPeerGroup
|
|
185
|
+
fields = (
|
|
186
|
+
'url',
|
|
187
|
+
'id',
|
|
188
|
+
'display',
|
|
189
|
+
'name',
|
|
190
|
+
'instance',
|
|
191
|
+
'listen_limit',
|
|
192
|
+
*_SESSION,
|
|
193
|
+
'tenant',
|
|
194
|
+
*_COMMON,
|
|
195
|
+
)
|
|
196
|
+
brief_fields = ('url', 'id', 'display', 'name', 'instance')
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class BGPListenRangeSerializer(NetBoxModelSerializer):
|
|
200
|
+
url = serializers.HyperlinkedIdentityField(
|
|
201
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgplistenrange-detail'
|
|
202
|
+
)
|
|
203
|
+
peer_group = BGPPeerGroupSerializer(nested=True)
|
|
204
|
+
prefix = PrefixSerializer(nested=True)
|
|
205
|
+
|
|
206
|
+
class Meta:
|
|
207
|
+
model = BGPListenRange
|
|
208
|
+
fields = ('url', 'id', 'display', 'peer_group', 'prefix', *_COMMON)
|
|
209
|
+
brief_fields = ('url', 'id', 'display', 'peer_group', 'prefix')
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class BGPRedistributionSerializer(NetBoxModelSerializer):
|
|
213
|
+
url = serializers.HyperlinkedIdentityField(
|
|
214
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgpredistribution-detail'
|
|
215
|
+
)
|
|
216
|
+
address_family = BGPAddressFamilySerializer(nested=True)
|
|
217
|
+
# the sources are the OSPF, IS-IS and EIGRP serializers' modules, which import this one
|
|
218
|
+
ospf_source = serializers.PrimaryKeyRelatedField(
|
|
219
|
+
queryset=OSPFInstance.objects.all(), required=False, allow_null=True
|
|
220
|
+
)
|
|
221
|
+
isis_source = serializers.PrimaryKeyRelatedField(
|
|
222
|
+
queryset=ISISInstance.objects.all(), required=False, allow_null=True
|
|
223
|
+
)
|
|
224
|
+
eigrp_source = serializers.PrimaryKeyRelatedField(
|
|
225
|
+
queryset=EIGRPAddressFamily.objects.all(), required=False, allow_null=True
|
|
226
|
+
)
|
|
227
|
+
route_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
228
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
229
|
+
|
|
230
|
+
class Meta:
|
|
231
|
+
model = BGPRedistribution
|
|
232
|
+
fields = (
|
|
233
|
+
'url',
|
|
234
|
+
'id',
|
|
235
|
+
'display',
|
|
236
|
+
'address_family',
|
|
237
|
+
'protocol',
|
|
238
|
+
'ospf_source',
|
|
239
|
+
'isis_source',
|
|
240
|
+
'eigrp_source',
|
|
241
|
+
'metric',
|
|
242
|
+
'route_policy',
|
|
243
|
+
'ospf_match',
|
|
244
|
+
'tenant',
|
|
245
|
+
*_COMMON,
|
|
246
|
+
)
|
|
247
|
+
brief_fields = ('url', 'id', 'display', 'address_family', 'protocol')
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class BGPOriginatedNetworkSerializer(NetBoxModelSerializer):
|
|
251
|
+
url = serializers.HyperlinkedIdentityField(
|
|
252
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgporiginatednetwork-detail'
|
|
253
|
+
)
|
|
254
|
+
address_family = BGPAddressFamilySerializer(nested=True)
|
|
255
|
+
prefix = PrefixSerializer(nested=True)
|
|
256
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
257
|
+
|
|
258
|
+
class Meta:
|
|
259
|
+
model = BGPOriginatedNetwork
|
|
260
|
+
fields = (
|
|
261
|
+
'url',
|
|
262
|
+
'id',
|
|
263
|
+
'display',
|
|
264
|
+
'address_family',
|
|
265
|
+
'prefix',
|
|
266
|
+
'tenant',
|
|
267
|
+
*_COMMON,
|
|
268
|
+
)
|
|
269
|
+
brief_fields = ('url', 'id', 'display', 'address_family', 'prefix')
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class BGPAggregateSerializer(NetBoxModelSerializer):
|
|
273
|
+
url = serializers.HyperlinkedIdentityField(
|
|
274
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgpaggregate-detail'
|
|
275
|
+
)
|
|
276
|
+
address_family = BGPAddressFamilySerializer(nested=True)
|
|
277
|
+
prefix = PrefixSerializer(nested=True)
|
|
278
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
279
|
+
|
|
280
|
+
class Meta:
|
|
281
|
+
model = BGPAggregate
|
|
282
|
+
fields = (
|
|
283
|
+
'url',
|
|
284
|
+
'id',
|
|
285
|
+
'display',
|
|
286
|
+
'address_family',
|
|
287
|
+
'prefix',
|
|
288
|
+
'summary_only',
|
|
289
|
+
'as_set',
|
|
290
|
+
'tenant',
|
|
291
|
+
*_COMMON,
|
|
292
|
+
)
|
|
293
|
+
brief_fields = ('url', 'id', 'display', 'address_family', 'prefix')
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
class BGPPeerSerializer(NetBoxModelSerializer):
|
|
297
|
+
url = serializers.HyperlinkedIdentityField(
|
|
298
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgppeer-detail'
|
|
299
|
+
)
|
|
300
|
+
instance = BGPInstanceSerializer(nested=True)
|
|
301
|
+
peer = IPAddressSerializer(nested=True, required=False, allow_null=True)
|
|
302
|
+
interface = InterfaceSerializer(nested=True, required=False, allow_null=True)
|
|
303
|
+
source = IPAddressSerializer(nested=True, required=False, allow_null=True)
|
|
304
|
+
peer_group = BGPPeerGroupSerializer(nested=True, required=False, allow_null=True)
|
|
305
|
+
remote_as = ASNSerializer(nested=True, required=False, allow_null=True)
|
|
306
|
+
local_as = ASNSerializer(nested=True, required=False, allow_null=True)
|
|
307
|
+
bfd = serializers.PrimaryKeyRelatedField(
|
|
308
|
+
queryset=BFDProfile.objects.all(), required=False, allow_null=True
|
|
309
|
+
)
|
|
310
|
+
passphrase_md5 = serializers.CharField(
|
|
311
|
+
source='md5_digest', read_only=True, allow_null=True
|
|
312
|
+
)
|
|
313
|
+
import_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
314
|
+
export_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
315
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
316
|
+
|
|
317
|
+
class Meta:
|
|
318
|
+
model = BGPPeer
|
|
319
|
+
fields = (
|
|
320
|
+
'url',
|
|
321
|
+
'id',
|
|
322
|
+
'display',
|
|
323
|
+
'name',
|
|
324
|
+
'instance',
|
|
325
|
+
'peer',
|
|
326
|
+
'interface',
|
|
327
|
+
'source',
|
|
328
|
+
'peer_group',
|
|
329
|
+
'status',
|
|
330
|
+
*_SESSION,
|
|
331
|
+
'tenant',
|
|
332
|
+
*_COMMON,
|
|
333
|
+
)
|
|
334
|
+
brief_fields = ('url', 'id', 'display', 'name', 'instance', 'peer')
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
class BGPPeerAddressFamilySerializer(NetBoxModelSerializer):
|
|
338
|
+
url = serializers.HyperlinkedIdentityField(
|
|
339
|
+
view_name='plugins-api:netbox_routing_plugin-api:bgppeeraddressfamily-detail'
|
|
340
|
+
)
|
|
341
|
+
peer = BGPPeerSerializer(nested=True, required=False, allow_null=True)
|
|
342
|
+
peer_group = BGPPeerGroupSerializer(nested=True, required=False, allow_null=True)
|
|
343
|
+
address_family = BGPAddressFamilySerializer(nested=True)
|
|
344
|
+
prefixlist_in = PrefixListSerializer(nested=True, required=False, allow_null=True)
|
|
345
|
+
prefixlist_out = PrefixListSerializer(nested=True, required=False, allow_null=True)
|
|
346
|
+
import_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
347
|
+
export_policy = RoutePolicySerializer(nested=True, required=False, allow_null=True)
|
|
348
|
+
tenant = TenantSerializer(nested=True, required=False, allow_null=True)
|
|
349
|
+
|
|
350
|
+
class Meta:
|
|
351
|
+
model = BGPPeerAddressFamily
|
|
352
|
+
fields = (
|
|
353
|
+
'url',
|
|
354
|
+
'id',
|
|
355
|
+
'display',
|
|
356
|
+
'peer',
|
|
357
|
+
'peer_group',
|
|
358
|
+
'address_family',
|
|
359
|
+
'enabled',
|
|
360
|
+
'prefixlist_in',
|
|
361
|
+
'prefixlist_out',
|
|
362
|
+
'import_policy',
|
|
363
|
+
'export_policy',
|
|
364
|
+
'send_community',
|
|
365
|
+
'next_hop_self',
|
|
366
|
+
'remove_private_as',
|
|
367
|
+
'allowas_in',
|
|
368
|
+
'maximum_prefix',
|
|
369
|
+
'maximum_prefix_warning',
|
|
370
|
+
'maximum_prefix_action',
|
|
371
|
+
'maximum_prefix_restart',
|
|
372
|
+
'tenant',
|
|
373
|
+
*_COMMON,
|
|
374
|
+
)
|
|
375
|
+
brief_fields = ('url', 'id', 'display', 'peer', 'peer_group', 'address_family')
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
class BFDProfileSerializer(NetBoxModelSerializer):
|
|
379
|
+
url = serializers.HyperlinkedIdentityField(
|
|
380
|
+
view_name='plugins-api:netbox_routing_plugin-api:bfdprofile-detail'
|
|
381
|
+
)
|
|
382
|
+
tenant = TenantSerializer(nested=True, required=False)
|
|
383
|
+
|
|
384
|
+
class Meta:
|
|
385
|
+
model = BFDProfile
|
|
386
|
+
fields = (
|
|
387
|
+
'url',
|
|
388
|
+
'id',
|
|
389
|
+
'display',
|
|
390
|
+
'description',
|
|
391
|
+
'comments',
|
|
392
|
+
'name',
|
|
393
|
+
'min_rx_int',
|
|
394
|
+
'min_tx_int',
|
|
395
|
+
'multiplier',
|
|
396
|
+
'mode',
|
|
397
|
+
'min_echo_rx_int',
|
|
398
|
+
'authentication',
|
|
399
|
+
'authentication_key_id',
|
|
400
|
+
'passphrase',
|
|
401
|
+
'tenant',
|
|
402
|
+
)
|
|
403
|
+
brief_fields = (
|
|
404
|
+
'url',
|
|
405
|
+
'id',
|
|
406
|
+
'display',
|
|
407
|
+
'name',
|
|
408
|
+
)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from django.core.exceptions import ValidationError as DjangoValidationError
|
|
2
|
+
from rest_framework import serializers
|
|
3
|
+
|
|
4
|
+
from ipam.api.serializers_.roles import RoleSerializer
|
|
5
|
+
from netbox.api.fields import ChoiceField
|
|
6
|
+
from netbox.api.serializers import PrimaryModelSerializer
|
|
7
|
+
from tenancy.api.serializers_.tenants import TenantSerializer
|
|
8
|
+
|
|
9
|
+
from netbox_routing_plugin.choices import (
|
|
10
|
+
ActionChoices,
|
|
11
|
+
CommunityStatusChoices,
|
|
12
|
+
CommunityTypeChoices,
|
|
13
|
+
)
|
|
14
|
+
from netbox_routing_plugin.helpers import community as community_helpers
|
|
15
|
+
from netbox_routing_plugin.models.community import *
|
|
16
|
+
|
|
17
|
+
__all__ = (
|
|
18
|
+
'CommunityListSerializer',
|
|
19
|
+
'CommunitySerializer',
|
|
20
|
+
'CommunityListEntrySerializer',
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CommunitySerializer(PrimaryModelSerializer):
|
|
25
|
+
"""`type` and `well_known` are derived from `community`, which is stored normalised"""
|
|
26
|
+
|
|
27
|
+
url = serializers.HyperlinkedIdentityField(
|
|
28
|
+
view_name='plugins-api:netbox_routing_plugin-api:community-detail'
|
|
29
|
+
)
|
|
30
|
+
status = ChoiceField(choices=CommunityStatusChoices, required=False)
|
|
31
|
+
type = ChoiceField(choices=CommunityTypeChoices, read_only=True)
|
|
32
|
+
well_known = serializers.CharField(read_only=True)
|
|
33
|
+
role = RoleSerializer(nested=True, required=False)
|
|
34
|
+
tenant = TenantSerializer(nested=True, required=False)
|
|
35
|
+
|
|
36
|
+
class Meta:
|
|
37
|
+
model = Community
|
|
38
|
+
fields = (
|
|
39
|
+
'url',
|
|
40
|
+
'id',
|
|
41
|
+
'display',
|
|
42
|
+
'name',
|
|
43
|
+
'community',
|
|
44
|
+
'type',
|
|
45
|
+
'well_known',
|
|
46
|
+
'role',
|
|
47
|
+
'status',
|
|
48
|
+
'tenant',
|
|
49
|
+
'description',
|
|
50
|
+
'owner',
|
|
51
|
+
'comments',
|
|
52
|
+
'tags',
|
|
53
|
+
'custom_fields',
|
|
54
|
+
'created',
|
|
55
|
+
'last_updated',
|
|
56
|
+
)
|
|
57
|
+
brief_fields = ('url', 'id', 'display', 'name', 'community', 'description')
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class CommunityListSerializer(PrimaryModelSerializer):
|
|
61
|
+
url = serializers.HyperlinkedIdentityField(
|
|
62
|
+
view_name='plugins-api:netbox_routing_plugin-api:communitylist-detail'
|
|
63
|
+
)
|
|
64
|
+
type = ChoiceField(choices=CommunityTypeChoices, required=False)
|
|
65
|
+
tenant = TenantSerializer(nested=True, required=False)
|
|
66
|
+
|
|
67
|
+
class Meta:
|
|
68
|
+
model = CommunityList
|
|
69
|
+
fields = (
|
|
70
|
+
'url',
|
|
71
|
+
'id',
|
|
72
|
+
'display',
|
|
73
|
+
'name',
|
|
74
|
+
'type',
|
|
75
|
+
'tenant',
|
|
76
|
+
'description',
|
|
77
|
+
'owner',
|
|
78
|
+
'comments',
|
|
79
|
+
'tags',
|
|
80
|
+
'custom_fields',
|
|
81
|
+
'created',
|
|
82
|
+
'last_updated',
|
|
83
|
+
)
|
|
84
|
+
brief_fields = ('url', 'id', 'display', 'name', 'description')
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class CommunityListEntrySerializer(PrimaryModelSerializer):
|
|
88
|
+
"""An empty `sequence` takes the next free one of the list"""
|
|
89
|
+
|
|
90
|
+
url = serializers.HyperlinkedIdentityField(
|
|
91
|
+
view_name='plugins-api:netbox_routing_plugin-api:communitylistentry-detail'
|
|
92
|
+
)
|
|
93
|
+
community_list = CommunityListSerializer(nested=True)
|
|
94
|
+
community = CommunitySerializer(nested=True)
|
|
95
|
+
action = ChoiceField(choices=ActionChoices)
|
|
96
|
+
|
|
97
|
+
class Meta:
|
|
98
|
+
model = CommunityListEntry
|
|
99
|
+
extra_kwargs = {'sequence': {'required': False, 'allow_null': True}}
|
|
100
|
+
fields = (
|
|
101
|
+
'url',
|
|
102
|
+
'id',
|
|
103
|
+
'display',
|
|
104
|
+
'community_list',
|
|
105
|
+
'sequence',
|
|
106
|
+
'action',
|
|
107
|
+
'community',
|
|
108
|
+
'description',
|
|
109
|
+
'owner',
|
|
110
|
+
'comments',
|
|
111
|
+
'tags',
|
|
112
|
+
'custom_fields',
|
|
113
|
+
'created',
|
|
114
|
+
'last_updated',
|
|
115
|
+
)
|
|
116
|
+
brief_fields = (
|
|
117
|
+
'url',
|
|
118
|
+
'id',
|
|
119
|
+
'display',
|
|
120
|
+
'community_list',
|
|
121
|
+
'sequence',
|
|
122
|
+
'action',
|
|
123
|
+
'community',
|
|
124
|
+
'description',
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
def validate(self, data):
|
|
128
|
+
# A new entry without sequence gets the next one of its list. The serializer of a
|
|
129
|
+
# bulk request is shared by the entries, so they get consecutive numbers.
|
|
130
|
+
if self.instance is None and data.get('sequence') is None:
|
|
131
|
+
community_list = data.get('community_list')
|
|
132
|
+
if community_list is not None:
|
|
133
|
+
assigned = self.context.setdefault('community_list_sequences', {})
|
|
134
|
+
try:
|
|
135
|
+
sequence = community_helpers.next_sequence(
|
|
136
|
+
community_list, assigned.get(community_list.pk, 0)
|
|
137
|
+
)
|
|
138
|
+
except DjangoValidationError as e:
|
|
139
|
+
raise serializers.ValidationError({'sequence': e.messages})
|
|
140
|
+
assigned[community_list.pk] = data['sequence'] = sequence
|
|
141
|
+
return super().validate(data)
|