Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and update plugin configuration and utility functions #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions netbox_cable_labels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,41 @@

__author__ = "Jonathan Senecal"
__email__ = "[email protected]"
__version__ = "0.0.3"
__version__ = "0.0.4"


from extras.plugins import PluginConfig
from netbox.plugins import PluginConfig


class AutoCableLabelsConfig(PluginConfig):
"""Plugin configuration for the netbox_cable_labels plugin."""
"""Plugin configuration for the netbox_cable_labels plugin.

This plugin automatically adds labels to cables based on user-defined templates.
"""

# Plugin metadata
name = "netbox_cable_labels"
verbose_name = "Automatic Cable Labels"
description = "Plugin for NetBox that automatically adds labels to cables based on a customizable template."
author_email = "[email protected]"
author = "Jonathan Senecal"
version = __version__
min_version = "3.5.0"
author = __author__
author_email = __email__
description = "Plugin for NetBox that automatically adds labels to cables based on a user defined template"

# Plugin requirements
min_version = "4.2.0"
max_version = "4.99.99"

# Plugin URL configuration
base_url = "cable-labels"

# Plugin settings
required_settings = []
default_settings = {"label_template": "#{{cable.pk}}"}

def ready(self):
"""Perform plugin initialization tasks when Django is ready."""
super().ready()
from . import signals # pylint: disable=unused-import,import-outside-toplevel

# Import signals to register them
from netbox_cable_labels import signals # pylint: disable=unused-import,import-outside-toplevel

config = AutoCableLabelsConfig # pylint: disable=invalid-name

print("netbox_cable_labels plugin loaded.")
config = AutoCableLabelsConfig
4 changes: 2 additions & 2 deletions netbox_cable_labels/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dcim.models.cables import Cable

try:
from extras.plugins.utils import get_plugin_config
from netbox.plugins.utils import get_plugin_config
except ImportError:
from extras.plugins import get_plugin_config # type: ignore
from netbox.plugins import get_plugin_config # type: ignore
from jinja2 import Environment, BaseLoader


Expand Down