Skip to content

Commit b700288

Browse files
authored
feat: NetBox 4.1 support (#21)
Signed-off-by: Michal Fiedorowicz <[email protected]>
1 parent 47aee1d commit b700288

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Diode NetBox Plugin
22

3-
The Diode NetBox plugin is a [NetBox](https://netboxlabs.com/oss/netbox/) plugin. It is a required component of the [Diode](https://github.com/netboxlabs/diode) ingestion service.
3+
The Diode NetBox plugin is a [NetBox](https://netboxlabs.com/oss/netbox/) plugin. It is a required component of
4+
the [Diode](https://github.com/netboxlabs/diode) ingestion service.
45

56
Diode is a NetBox ingestion service that greatly simplifies and enhances the process to add and update network data
67
in NetBox, ensuring your network source of truth is always accurate and can be trusted to power your network automation
@@ -12,8 +13,9 @@ at [https://netboxlabs.com/blog/introducing-diode-streamlining-data-ingestion-in
1213
## Compatibility
1314

1415
| NetBox Version | Plugin Version |
15-
|----------------|----------------|
16-
| >= 3.7.2 | 0.1.0 |
16+
|:--------------:|:--------------:|
17+
| >= 3.7.2 | 0.1.0 |
18+
| >= 4.1.0 | 0.3.0 |
1719

1820
## Installation
1921

@@ -55,7 +57,8 @@ cd /opt/netbox
5557
source venv/bin/activate
5658
```
5759

58-
Three API keys will be needed (these are random 40 character long alphanumeric strings). They can be generated and set to the appropriate environment variables with the following commands:
60+
Three API keys will be needed (these are random 40 character long alphanumeric strings). They can be generated and set
61+
to the appropriate environment variables with the following commands:
5962

6063
```shell
6164
# API key for the Diode service to interact with NetBox

docker/Dockerfile-diode-netbox-plugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM netboxcommunity/netbox:v4.0-2.9.1
1+
FROM netboxcommunity/netbox:v4.1-beta1-2.9.1
22

33
COPY ./netbox/configuration/ /etc/netbox/config/
44
RUN chmod 755 /etc/netbox/config/* && \

docker/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: diode-netbox-plugin
22
services:
33
netbox: &netbox
4-
image: netboxcommunity/netbox:v4.0-2.9.1-diode-netbox-plugin
4+
image: netboxcommunity/netbox:v4.1-beta1-2.9.1-diode-netbox-plugin
55
build:
66
context: .
77
dockerfile: Dockerfile-diode-netbox-plugin

netbox_diode_plugin/api/serializers.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@
1313
PlatformSerializer,
1414
SiteSerializer,
1515
)
16-
from django.core.exceptions import FieldDoesNotExist
17-
from extras.models import ObjectChange
16+
from django.conf import settings
17+
from packaging import version
18+
19+
if version.parse(version.parse(settings.VERSION).base_version) >= version.parse("4.1"):
20+
from core.models import ObjectChange
21+
else:
22+
from extras.models import ObjectChange
1823
from ipam.api.serializers import IPAddressSerializer, PrefixSerializer
1924
from rest_framework import serializers
2025
from rest_framework.utils.serializer_helpers import ReturnDict
@@ -23,9 +28,9 @@
2328
ClusterGroupSerializer,
2429
ClusterSerializer,
2530
ClusterTypeSerializer,
26-
VMInterfaceSerializer,
2731
VirtualDiskSerializer,
2832
VirtualMachineSerializer,
33+
VMInterfaceSerializer,
2934
)
3035

3136
logger = logging.getLogger("netbox.netbox_diode_plugin.api.serializers")
@@ -329,6 +334,7 @@ class Meta:
329334
model = VirtualDiskSerializer.Meta.model
330335
fields = VirtualDiskSerializer.Meta.fields
331336

337+
332338
class DiodeVMInterfaceSerializer(VMInterfaceSerializer):
333339
"""Diode VM Interface Serializer."""
334340

0 commit comments

Comments
 (0)