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

[Feature]: Not Supported for Netbox 3.7 #177

Closed
kilian0001 opened this issue Feb 21, 2024 · 4 comments · Fixed by #181
Closed

[Feature]: Not Supported for Netbox 3.7 #177

kilian0001 opened this issue Feb 21, 2024 · 4 comments · Fixed by #181
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@kilian0001
Copy link

NetBox access-list plugin version

v1.3.0

NetBox version

v3.7.2

Steps to Reproduce

Install the Plugin, as described in your docs

Expected Behavior

Normal Installation

Observed Behavior

Python error with the text, that it isnt supported for Versions above 3.5

@kilian0001 kilian0001 added the bug Something isn't working label Feb 21, 2024
Copy link

Thanks for opening this Issue! We really appreciate the feedback & testing from users like you!

@jeffgdotorg jeffgdotorg added the help wanted Extra attention is needed label Mar 20, 2024
@jeffgdotorg
Copy link
Contributor

I spent some time chasing down this breakage as an exercise to learn something related to plugin development.

After bumping max_version from 3.5.99 to 3.7.99 in netbox_acls/__init__.py and rebuilding, NetBox failed to answer web requests and produced the following exception stack trace, which quickly goes circular:

[2024-03-19 17:24:37 +0000] [3023] [ERROR] Error handling request /favicon.ico
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
    callback, callback_args, callback_kwargs = self.resolve_request(request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 313, in resolve_request
    resolver_match = resolver.resolve(request.path_info)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 663, in resolve
    for pattern in self.url_patterns:
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/netbox/netbox/netbox/urls.py", line 12, in <module>
    from netbox.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
  File "/opt/netbox/netbox/netbox/plugins/urls.py", line 31, in <module>
    urlpatterns = import_string(f"{plugin_path}.urls.urlpatterns")
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import
    module = import_module(module_path)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/urls.py", line 8, in <module>
    from . import views
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/views.py", line 12, in <module>
    from . import choices, filtersets, forms, models, tables
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/forms/__init__.py", line 11, in <module>
    from .filtersets import *
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/forms/filtersets.py", line 9, in <module>
    from utilities.forms.fields import (
ImportError: cannot import name 'ChoiceField' from 'utilities.forms.fields' (/opt/netbox/netbox/utilities/forms/fields/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/deprecation.py", line 134, in __call__
    response = response or self.get_response(request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 57, in inner
    response = response_for_exception(request, exc)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 140, in response_for_exception
    response = handle_uncaught_exception(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 184, in handle_uncaught_exception
    callback = resolver.resolve_error_handler(500)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 729, in resolve_error_handler
    callback = getattr(self.urlconf_module, "handler%s" % view_type, None)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/netbox/netbox/netbox/urls.py", line 12, in <module>
    from netbox.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
  File "/opt/netbox/netbox/netbox/plugins/urls.py", line 31, in <module>
    urlpatterns = import_string(f"{plugin_path}.urls.urlpatterns")
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import
    module = import_module(module_path)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/urls.py", line 8, in <module>
    from . import views
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/views.py", line 12, in <module>
    from . import choices, filtersets, forms, models, tables
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/forms/__init__.py", line 11, in <module>
    from .filtersets import *
  File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_acls/forms/filtersets.py", line 9, in <module>
    from utilities.forms.fields import (
ImportError: cannot import name 'ChoiceField' from 'utilities.forms.fields' (/opt/netbox/netbox/utilities/forms/fields/__init__.py)
...

I chased the ImportError for a while, but I'm a product manager with scant Python development experience and just not that effective yet in this area. I did get the plugin to load and display its top-level menu item on a NetBox 3.7.4 system by making the following changes against v1.3.0 of the plugin, rebuilding the plugin, and installing the resulting .whl:

diff --git a/netbox_acls/__init__.py b/netbox_acls/__init__.py
index 4898b59..e220878 100644
--- a/netbox_acls/__init__.py
+++ b/netbox_acls/__init__.py
@@ -18,7 +18,7 @@ class NetBoxACLsConfig(PluginConfig):
     description = "Manage simple ACLs in NetBox"
     base_url = "access-lists"
     min_version = "3.5.0"
-    max_version = "3.5.99"
+    max_version = "3.7.99"


 config = NetBoxACLsConfig
diff --git a/netbox_acls/forms/filtersets.py b/netbox_acls/forms/filtersets.py
index 37f20df..907adaf 100644
--- a/netbox_acls/forms/filtersets.py
+++ b/netbox_acls/forms/filtersets.py
@@ -4,10 +4,10 @@ Defines each django model's GUI filter/search options.

 from dcim.models import Device, Interface, Region, Site, SiteGroup, VirtualChassis
 from django import forms
+from django.forms import ChoiceField
 from ipam.models import Prefix
 from netbox.forms import NetBoxModelFilterSetForm
 from utilities.forms.fields import (
-    ChoiceField,
     DynamicModelChoiceField,
     DynamicModelMultipleChoiceField,
     TagFilterField,

Still, none of the plugin's views render successfully. I think there may be other NetBox import issues left to resolve, and the following message in the logs leads me to suspect that there have also been some changes in one or more of the Django artifacts:

ModuleNotFoundError: No module named 'django.template.loaders'

There's also probably work to do on the plugin's tests, which I see reference device_role (deprecated in 3.6 and removed in favor of just role in 3.7).

This is where I sign off and hand this over to someone better equipped to identify and implement the remaining changes.

@jeffgdotorg
Copy link
Contributor

I had another run at this with NetBox 3.6.9 and hit the same initial problem; fielding the same hack-around got me exactly as far down the road. I surmise that the primary breakage happened in NetBox 3.6, not 3.7.

@minitriga
Copy link

@jeffgdotorg yes 3.6 broke many things for plugins. But looks like this PR might fix your issue: #175

Can you try installing the plugin from that branch and testing?

@ryanmerolle ryanmerolle mentioned this issue Mar 27, 2024
2 tasks
@ryanmerolle ryanmerolle added enhancement New feature or request and removed bug Something isn't working labels Mar 27, 2024
@ryanmerolle ryanmerolle self-assigned this Mar 27, 2024
@ryanmerolle ryanmerolle changed the title [Bug]: Not Supported for Netbox 3.7 [Feature]: Not Supported for Netbox 3.7 Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants