Skip to content

Commit

Permalink
feat: NetBox 4.1 support (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Fiedorowicz <[email protected]>
  • Loading branch information
mfiedorowicz authored Sep 3, 2024
1 parent 47aee1d commit b700288
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Diode NetBox Plugin

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.
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.

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

| NetBox Version | Plugin Version |
|----------------|----------------|
| >= 3.7.2 | 0.1.0 |
|:--------------:|:--------------:|
| >= 3.7.2 | 0.1.0 |
| >= 4.1.0 | 0.3.0 |

## Installation

Expand Down Expand Up @@ -55,7 +57,8 @@ cd /opt/netbox
source venv/bin/activate
```

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:
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:

```shell
# API key for the Diode service to interact with NetBox
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile-diode-netbox-plugin
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM netboxcommunity/netbox:v4.0-2.9.1
FROM netboxcommunity/netbox:v4.1-beta1-2.9.1

COPY ./netbox/configuration/ /etc/netbox/config/
RUN chmod 755 /etc/netbox/config/* && \
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: diode-netbox-plugin
services:
netbox: &netbox
image: netboxcommunity/netbox:v4.0-2.9.1-diode-netbox-plugin
image: netboxcommunity/netbox:v4.1-beta1-2.9.1-diode-netbox-plugin
build:
context: .
dockerfile: Dockerfile-diode-netbox-plugin
Expand Down
12 changes: 9 additions & 3 deletions netbox_diode_plugin/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
PlatformSerializer,
SiteSerializer,
)
from django.core.exceptions import FieldDoesNotExist
from extras.models import ObjectChange
from django.conf import settings
from packaging import version

if version.parse(version.parse(settings.VERSION).base_version) >= version.parse("4.1"):
from core.models import ObjectChange
else:
from extras.models import ObjectChange
from ipam.api.serializers import IPAddressSerializer, PrefixSerializer
from rest_framework import serializers
from rest_framework.utils.serializer_helpers import ReturnDict
Expand All @@ -23,9 +28,9 @@
ClusterGroupSerializer,
ClusterSerializer,
ClusterTypeSerializer,
VMInterfaceSerializer,
VirtualDiskSerializer,
VirtualMachineSerializer,
VMInterfaceSerializer,
)

logger = logging.getLogger("netbox.netbox_diode_plugin.api.serializers")
Expand Down Expand Up @@ -329,6 +334,7 @@ class Meta:
model = VirtualDiskSerializer.Meta.model
fields = VirtualDiskSerializer.Meta.fields


class DiodeVMInterfaceSerializer(VMInterfaceSerializer):
"""Diode VM Interface Serializer."""

Expand Down

0 comments on commit b700288

Please sign in to comment.