netbox-circuitmaintenance
netbox-circuitmaintenance copied to clipboard
Netbox `>=v4.2` Compatibility Broken
Plugin version v0.4.2
NetBox version v4.2.2
Describe the bug Nested Serializers have been changed in Netbox v4.2 onwards
To Reproduce
Attempt to upgrade Netbox from <v4.2 to >=v4.2 results in the following:
Applying database migrations (python3 netbox/manage.py migrate)...
Traceback (most recent call last):
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/checks/urls.py", line 136, in check_custom_error_handlers
handler = resolver.resolve_error_handler(status_code)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 732, in resolve_error_handler
callback = getattr(self.urlconf_module, "handler%s" % view_type, None)
^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/utils/functional.py", line 47, in __get__
res = instance.__dict__[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 711, in urlconf_module
return import_module(self.urlconf_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/opt/netbox-4.2.2/netbox/netbox/urls.py", line 11, in <module>
from netbox.plugins.urls import plugin_patterns, plugin_api_patterns
File "/opt/netbox-4.2.2/netbox/netbox/plugins/urls.py", line 33, in <module>
urlpatterns = import_string(f"{plugin_path}.api.urls.urlpatterns")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/utils/module_loading.py", line 30, in import_string
return cached_import(module_path, class_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/utils/module_loading.py", line 15, in cached_import
module = import_module(module_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/netbox_circuitmaintenance/api/urls.py", line 2, in <module>
from . import views
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/netbox_circuitmaintenance/api/views.py", line 4, in <module>
from .serializers import CircuitMaintenanceSerializer, CircuitMaintenanceImpactSerializer, CircuitMaintenanceNotificationsSerializer
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/netbox_circuitmaintenance/api/serializers.py", line 5, in <module>
from circuits.api.nested_serializers import NestedProviderSerializer, NestedCircuitSerializer
ModuleNotFoundError: No module named 'circuits.api.nested_serializers'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/netbox-4.2.2/netbox/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/management/base.py", line 107, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 101, in handle
self.check(databases=[database])
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/management/base.py", line 486, in check
all_issues = checks.run_checks(
^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/core/checks/urls.py", line 138, in check_custom_error_handlers
path = getattr(resolver.urlconf_module, "handler%s" % status_code)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/utils/functional.py", line 47, in __get__
res = instance.__dict__[self.name] = self.func(instance)
^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/urls/resolvers.py", line 711, in urlconf_module
return import_module(self.urlconf_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/opt/netbox-4.2.2/netbox/netbox/urls.py", line 11, in <module>
from netbox.plugins.urls import plugin_patterns, plugin_api_patterns
File "/opt/netbox-4.2.2/netbox/netbox/plugins/urls.py", line 33, in <module>
urlpatterns = import_string(f"{plugin_path}.api.urls.urlpatterns")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/utils/module_loading.py", line 30, in import_string
return cached_import(module_path, class_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/django/utils/module_loading.py", line 15, in cached_import
module = import_module(module_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/netbox_circuitmaintenance/api/urls.py", line 2, in <module>
from . import views
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/netbox_circuitmaintenance/api/views.py", line 4, in <module>
from .serializers import CircuitMaintenanceSerializer, CircuitMaintenanceImpactSerializer, CircuitMaintenanceNotificationsSerializer
File "/opt/netbox-4.2.2/venv/lib/python3.11/site-packages/netbox_circuitmaintenance/api/serializers.py", line 5, in <module>
from circuits.api.nested_serializers import NestedProviderSerializer, NestedCircuitSerializer
ModuleNotFoundError: No module named 'circuits.api.nested_serializers'
Additional context
Per comment in netbox repo code, v4.2 onwards of Netbox have removed Nested Serializers and a new Serializer(nested=true) method/function made available in it's place.
https://github.com/netbox-community/netbox/blob/d122c334fdd08f277e8ce70953ef89801decd0fc/netbox/ipam/api/nested_serializers.py#L33
Plugin needs updating to be compatible with versions of Netbox >=v4.2 - unfortunately I'm not entirely sure how to implement these changes myself or I would submit a patch/PR.
Kind regards, Jacob Bisby
Hi, There is more work required for 4.2 and onwards alongside nested serializers:
- urls / views transition to register_model_views
- needs to transition to pyproject.toml (the plugin breaks trying to use uv editable in docker 3.2.0)
I'm happy to volunteer if @jasonyates agrees
Any news as we are also running into this issue? This prevents us to upgrade Netbox 4.2.4... Is this package still maintained after 3 weeks of waiting and nothing has happened?
This has been fixed since v0.5.0 of the plugin released in June.