Skip to content

Commit 2a474d7

Browse files
authored
Merge pull request #22 from netboxlabs/develop
🚚 release: v0.3.0
2 parents e60458e + b700288 commit 2a474d7

File tree

4 files changed

+104
-10
lines changed

4 files changed

+104
-10
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: 95 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
# Copyright 2024 NetBox Labs Inc
33
"""Diode NetBox Plugin - Serializers."""
44

5-
import copy
65
import logging
7-
from collections import OrderedDict
86

97
from dcim.api.serializers import (
108
DeviceRoleSerializer,
@@ -15,12 +13,25 @@
1513
PlatformSerializer,
1614
SiteSerializer,
1715
)
18-
from django.core.exceptions import FieldDoesNotExist
19-
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
2023
from ipam.api.serializers import IPAddressSerializer, PrefixSerializer
2124
from rest_framework import serializers
2225
from rest_framework.utils.serializer_helpers import ReturnDict
2326
from utilities.api import get_serializer_for_model
27+
from virtualization.api.serializers import (
28+
ClusterGroupSerializer,
29+
ClusterSerializer,
30+
ClusterTypeSerializer,
31+
VirtualDiskSerializer,
32+
VirtualMachineSerializer,
33+
VMInterfaceSerializer,
34+
)
2435

2536
logger = logging.getLogger("netbox.netbox_diode_plugin.api.serializers")
2637

@@ -254,3 +265,83 @@ class Meta:
254265

255266
model = PrefixSerializer.Meta.model
256267
fields = PrefixSerializer.Meta.fields
268+
269+
270+
class DiodeClusterGroupSerializer(ClusterGroupSerializer):
271+
"""Diode Cluster Group Serializer."""
272+
273+
class Meta:
274+
"""Meta class."""
275+
276+
model = ClusterGroupSerializer.Meta.model
277+
fields = ClusterGroupSerializer.Meta.fields
278+
279+
280+
class DiodeClusterTypeSerializer(ClusterTypeSerializer):
281+
"""Diode Cluster Type Serializer."""
282+
283+
class Meta:
284+
"""Meta class."""
285+
286+
model = ClusterTypeSerializer.Meta.model
287+
fields = ClusterTypeSerializer.Meta.fields
288+
289+
290+
class DiodeClusterSerializer(ClusterSerializer):
291+
"""Diode Cluster Serializer."""
292+
293+
type = DiodeClusterTypeSerializer()
294+
group = DiodeClusterGroupSerializer()
295+
status = serializers.CharField()
296+
site = DiodeSiteSerializer()
297+
298+
class Meta:
299+
"""Meta class."""
300+
301+
model = ClusterSerializer.Meta.model
302+
fields = ClusterSerializer.Meta.fields
303+
304+
305+
class DiodeVirtualMachineSerializer(VirtualMachineSerializer):
306+
"""Diode Virtual Machine Serializer."""
307+
308+
status = serializers.CharField()
309+
site = DiodeSiteSerializer()
310+
cluster = DiodeClusterSerializer()
311+
device = DiodeDeviceSerializer()
312+
role = DiodeDeviceRoleSerializer()
313+
tenant = serializers.CharField()
314+
platform = DiodePlatformSerializer()
315+
primary_ip = DiodeIPAddressSerializer()
316+
primary_ip4 = DiodeIPAddressSerializer()
317+
primary_ip6 = DiodeIPAddressSerializer()
318+
319+
class Meta:
320+
"""Meta class."""
321+
322+
model = VirtualMachineSerializer.Meta.model
323+
fields = VirtualMachineSerializer.Meta.fields
324+
325+
326+
class DiodeVirtualDiskSerializer(VirtualDiskSerializer):
327+
"""Diode Virtual Disk Serializer."""
328+
329+
virtual_machine = DiodeVirtualMachineSerializer()
330+
331+
class Meta:
332+
"""Meta class."""
333+
334+
model = VirtualDiskSerializer.Meta.model
335+
fields = VirtualDiskSerializer.Meta.fields
336+
337+
338+
class DiodeVMInterfaceSerializer(VMInterfaceSerializer):
339+
"""Diode VM Interface Serializer."""
340+
341+
virtual_machine = DiodeVirtualMachineSerializer()
342+
343+
class Meta:
344+
"""Meta class."""
345+
346+
model = VMInterfaceSerializer.Meta.model
347+
fields = VMInterfaceSerializer.Meta.fields

0 commit comments

Comments
 (0)