Skip to content

Commit

Permalink
NetBox version 4.1.x support
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoalmeidaoliveira committed Sep 7, 2024
1 parent 50ead25 commit 074ed0e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 46 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.10
NETBOX_VER?=v4.0.8
NETBOX_VER?=v4.1.0


COMPOSE_FILE=./develop/docker-compose.yml
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ To ensure NBRisk plugin is automatically re-installed during future upgrades, cr
```shell
# echo "NbRisk==40.0.*" >> local_requirements.txt
```
### For NetBox 4.1.0 or grater
```shell
# echo "NbRisk==41.0.*" >> local_requirements.txt
```

Before installing NBRisk make sure your NetBox instance is already installed with all migrations executed.
With your NetBox fully installed, install the plugin with pip and enable it in your configuration.py

Expand Down
2 changes: 1 addition & 1 deletion develop/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG python_ver=3.10
FROM python:${python_ver}

ARG netbox_ver=v4.0.8
ARG netbox_ver=v4.1.0
ENV PYTHONUNBUFFERED 1

RUN mkdir -p /opt
Expand Down
4 changes: 2 additions & 2 deletions nb_risk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class NbriskConfig(PluginConfig):
version = __version__
author = "Renato Almdida Oliveira"
author_email = "[email protected]"
min_version = "4.0.0"
max_version = "4.0.99"
min_version = "4.1.0"
max_version = "4.1.99"
required_settings = []
default_settings = {
"supported_assets": [
Expand Down
34 changes: 0 additions & 34 deletions nb_risk/api/nested_serializers.py

This file was deleted.

11 changes: 4 additions & 7 deletions nb_risk/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from rest_framework import serializers
from django.contrib.contenttypes.models import ContentType
from netbox.api.fields import ChoiceField, ContentTypeField, SerializedPKRelatedField
from netbox.api.serializers import WritableNestedSerializer
from utilities.api import get_serializer_for_model


from netbox.api.serializers import NetBoxModelSerializer
from nb_risk.api.nested_serializers import (
NestedRiskSerializer,
)

from .. import models, choices

# ThreatSource Serializers
Expand Down Expand Up @@ -114,9 +111,9 @@ def validate(self, data):
def get_asset(self, obj):
if obj.asset is None:
return None
serializer = get_serializer_for_model(obj.asset, prefix='Nested')
serializer = get_serializer_for_model(obj.asset)
context = {'request': self.context['request']}
return serializer(obj.asset, context=context).data
return serializer(obj.asset, context=context, nested=True).data

def get_display(self, obj):
return obj.name
Expand Down Expand Up @@ -165,7 +162,7 @@ class Meta:
class ControlSerializer(NetBoxModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name="plugins-api:nb_risk-api:control-detail")
display = serializers.SerializerMethodField('get_display')
risk = NestedRiskSerializer(many=True,required=False, allow_null=True)
risk = RiskSerializer(many=True,required=False, allow_null=True, nested=True)

def get_display(self, obj):
return obj.name
Expand Down
2 changes: 1 addition & 1 deletion nb_risk/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "40.0.2"
__version__ = "41.0.1"

0 comments on commit 074ed0e

Please sign in to comment.