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

plugin not working under netbox v3.2 #46

Closed
matejv opened this issue Apr 12, 2022 · 4 comments · Fixed by #50
Closed

plugin not working under netbox v3.2 #46

matejv opened this issue Apr 12, 2022 · 4 comments · Fixed by #50

Comments

@matejv
Copy link

matejv commented Apr 12, 2022

I tried to install this plugin under netbox v3.2 that was released a few days ago. Unfortunately the plugin fails with:

netbox-worker_1        | Traceback (most recent call last):
netbox-worker_1        |   File "/opt/netbox/netbox/manage.py", line 10, in <module>
netbox-worker_1        |     execute_from_command_line(sys.argv)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
netbox-worker_1        |     utility.execute()
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
netbox-worker_1        |     self.fetch_command(subcommand).run_from_argv(self.argv)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
netbox-worker_1        |     self.execute(*args, **cmd_options)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 455, in execute
netbox-worker_1        |     self.check()
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 487, in check
netbox-worker_1        |     all_issues = checks.run_checks(
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
netbox-worker_1        |     new_errors = check(app_configs=app_configs, databases=databases)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/checks/urls.py", line 14, in check_url_config
netbox-worker_1        |     return check_resolver(resolver)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/checks/urls.py", line 24, in check_resolver
netbox-worker_1        |     return check_method()
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/urls/resolvers.py", line 480, in check
netbox-worker_1        |     for pattern in self.url_patterns:
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/utils/functional.py", line 49, in __get__
netbox-worker_1        |     res = instance.__dict__[self.name] = self.func(instance)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/urls/resolvers.py", line 696, in url_patterns
netbox-worker_1        |     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/utils/functional.py", line 49, in __get__
netbox-worker_1        |     res = instance.__dict__[self.name] = self.func(instance)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/django/urls/resolvers.py", line 689, in urlconf_module
netbox-worker_1        |     return import_module(self.urlconf_name)
netbox-worker_1        |   File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
netbox-worker_1        |     return _bootstrap._gcd_import(name[level:], package, level)
netbox-worker_1        |   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
netbox-worker_1        |   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
netbox-worker_1        |   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
netbox-worker_1        |   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
netbox-worker_1        |   File "<frozen importlib._bootstrap_external>", line 855, in exec_module
netbox-worker_1        |   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
netbox-worker_1        |   File "/opt/netbox/netbox/netbox/urls.py", line 9, in <module>
netbox-worker_1        |     from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
netbox-worker_1        |   File "/opt/netbox/netbox/extras/plugins/urls.py", line 35, in <module>
netbox-worker_1        |     urlpatterns = import_object(f"{plugin_path}.api.urls.urlpatterns")
netbox-worker_1        |   File "/opt/netbox/netbox/extras/plugins/utils.py", line 31, in import_object
netbox-worker_1        |     spec.loader.exec_module(module)
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/netbox_prometheus_sd/api/urls.py", line 2, in <module>
netbox-worker_1        |     from .views import VirtualMachineViewSet, DeviceViewSet, IPAddressViewSet
netbox-worker_1        |   File "/opt/netbox/venv/lib/python3.9/site-packages/netbox_prometheus_sd/api/views.py", line 4, in <module>
netbox-worker_1        |     from extras.api.views import CustomFieldModelViewSet
netbox-worker_1        | ImportError: cannot import name 'CustomFieldModelViewSet' from 'extras.api.views' (/opt/netbox/netbox/extras/api/views.py)

It seems some changes are needed to make it compatible with newer netbox.

There seems to be a ticket with changes that were made to the plugin framework.

@FlxPeters
Copy link
Owner

Netbox 3.2 is on my roadmap. I will fix this soon because we also will migrate and have a demand on this.

@candlerb
Copy link
Contributor

candlerb commented Sep 14, 2022

If this now works with 3.2 (and/or 3.3), can the README be updated? Also example/Dockerfile ?

@FlxPeters
Copy link
Owner

Sure! Can you submit a PR? Otherwise I will fix it in the next days.

@candlerb
Copy link
Contributor

I think it's easier if I let you word it the way you like.

I found in .github/workflows/ci.yml:

        netbox-version:
          - v2.11.11
          - v3.0.12
          - v3.1.8
          - v3.2.2
          - master

so presumably those are all tested (and v3.3.2 could be added)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants