mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 08:25:17 -06:00
Introduce get_installed_plugins() utility
This commit is contained in:
parent
2236b86c35
commit
3597f79235
19
netbox/extras/plugins/utils.py
Normal file
19
netbox/extras/plugins/utils.py
Normal file
@ -0,0 +1,19 @@
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
|
||||
__all__ = (
|
||||
'get_installed_plugins',
|
||||
)
|
||||
|
||||
|
||||
def get_installed_plugins():
|
||||
"""
|
||||
Return a dictionary mapping the names of installed plugins to their versions.
|
||||
"""
|
||||
plugins = {}
|
||||
for plugin_name in settings.PLUGINS:
|
||||
plugin_name = plugin_name.rsplit('.', 1)[-1]
|
||||
plugin_config = apps.get_app_config(plugin_name)
|
||||
plugins[plugin_name] = getattr(plugin_config, 'version', None)
|
||||
|
||||
return dict(sorted(plugins.items()))
|
@ -11,6 +11,7 @@ from rest_framework.reverse import reverse
|
||||
from rest_framework.views import APIView
|
||||
from rq.worker import Worker
|
||||
|
||||
from extras.plugins.utils import get_installed_plugins
|
||||
from netbox.api.authentication import IsAuthenticatedOrLoginNotRequired
|
||||
|
||||
|
||||
@ -61,19 +62,11 @@ class StatusView(APIView):
|
||||
installed_apps[app_config.name] = version
|
||||
installed_apps = {k: v for k, v in sorted(installed_apps.items())}
|
||||
|
||||
# Gather installed plugins
|
||||
plugins = {}
|
||||
for plugin_name in settings.PLUGINS:
|
||||
plugin_name = plugin_name.rsplit('.', 1)[-1]
|
||||
plugin_config = apps.get_app_config(plugin_name)
|
||||
plugins[plugin_name] = getattr(plugin_config, 'version', None)
|
||||
plugins = {k: v for k, v in sorted(plugins.items())}
|
||||
|
||||
return Response({
|
||||
'django-version': DJANGO_VERSION,
|
||||
'installed-apps': installed_apps,
|
||||
'netbox-version': settings.VERSION,
|
||||
'plugins': plugins,
|
||||
'plugins': get_installed_plugins(),
|
||||
'python-version': platform.python_version(),
|
||||
'rq-workers-running': Worker.count(get_connection('default')),
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user