-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from netboxlabs/develop
🚚 release
- Loading branch information
Showing
56 changed files
with
4,041 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: diode-netbox-plugin | ||
services: | ||
netbox: | ||
volumes: | ||
- ./netbox/plugins_test.py:/etc/netbox/config/plugins.py:z,ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Add your plugins and plugin settings here. | ||
# Of course uncomment this file out. | ||
|
||
# To learn how to build images with your required plugins | ||
# See https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins | ||
|
||
PLUGINS = ["netbox_diode_plugin"] | ||
|
||
PLUGINS_CONFIG = { | ||
"netbox_diode_plugin": { | ||
"enable_ingestion_logs": True, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
pytest==8.0.2 | ||
grpcio==1.62.1 | ||
Brotli==1.1.0 | ||
certifi==2024.7.4 | ||
coverage==7.6.0 | ||
grpcio==1.62.1 | ||
protobuf==5.28.1 | ||
pytest==8.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# !/usr/bin/env python | ||
# Copyright 2024 NetBox Labs Inc | ||
"""Diode NetBox Plugin - Forms.""" | ||
from netbox.forms import NetBoxModelForm | ||
from netbox.plugins import get_plugin_config | ||
from utilities.forms.rendering import FieldSet | ||
|
||
from netbox_diode_plugin.models import Setting | ||
|
||
__all__ = ("SettingsForm",) | ||
|
||
|
||
class SettingsForm(NetBoxModelForm): | ||
"""Settings form.""" | ||
|
||
fieldsets = ( | ||
FieldSet( | ||
"diode_target", | ||
), | ||
) | ||
|
||
class Meta: | ||
"""Meta class.""" | ||
|
||
model = Setting | ||
fields = ("diode_target",) | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Initialize the form.""" | ||
super().__init__(*args, **kwargs) | ||
|
||
diode_target_override = get_plugin_config( | ||
"netbox_diode_plugin", "diode_target_override" | ||
) | ||
|
||
if diode_target_override: | ||
self.fields["diode_target"].disabled = True | ||
self.fields["diode_target"].help_text = ( | ||
"This field is not allowed to be modified." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2024 NetBox Labs Inc | ||
"""Diode Netbox Plugin - Database migrations.""" | ||
|
||
import utilities.json | ||
from django.db import migrations, models | ||
from netbox.plugins import get_plugin_config | ||
|
||
|
||
def create_settings_entity(apps, schema_editor): | ||
"""Create a Setting entity.""" | ||
Setting = apps.get_model("netbox_diode_plugin", "Setting") | ||
|
||
default_diode_target = get_plugin_config("netbox_diode_plugin", "diode_target") | ||
diode_target = get_plugin_config( | ||
"netbox_diode_plugin", "diode_target_override", default_diode_target | ||
) | ||
|
||
Setting.objects.create(diode_target=diode_target) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
"""0002_setting migration.""" | ||
|
||
dependencies = [ | ||
("netbox_diode_plugin", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Setting", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, primary_key=True, serialize=False | ||
), | ||
), | ||
("created", models.DateTimeField(auto_now_add=True, null=True)), | ||
("last_updated", models.DateTimeField(auto_now=True, null=True)), | ||
( | ||
"custom_field_data", | ||
models.JSONField( | ||
blank=True, | ||
default=dict, | ||
encoder=utilities.json.CustomFieldJSONEncoder, | ||
), | ||
), | ||
("diode_target", models.CharField(max_length=255)), | ||
], | ||
options={ | ||
"verbose_name": "Setting", | ||
"verbose_name_plural": "Diode Settings", | ||
}, | ||
), | ||
migrations.RunPython( | ||
code=create_settings_entity, reverse_code=migrations.RunPython.noop | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
# Copyright 2024 NetBox Labs Inc | ||
"""Diode Netbox Plugin - Database migrations.""" | ||
|
||
from django.db import migrations | ||
|
||
|
||
def clear_diode_group_permissions(apps, schema_editor): | ||
"""Clear Diode group permissions.""" | ||
ObjectPermission = apps.get_model("users", "ObjectPermission") | ||
permission = ObjectPermission.objects.get(name="Diode") | ||
permission.groups.clear() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
"""0003_clear_permissions migration.""" | ||
|
||
dependencies = [ | ||
("netbox_diode_plugin", "0001_initial"), | ||
("netbox_diode_plugin", "0002_setting"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
code=clear_diode_group_permissions, reverse_code=migrations.RunPython.noop | ||
), | ||
] |
Oops, something went wrong.