|
@@ -1,4 +1,5 @@
|
|
|
from django.apps import apps
|
|
from django.apps import apps
|
|
|
|
|
+from django.core.cache import cache
|
|
|
from django.core.checks import Error, Tags, Warning, register
|
|
from django.core.checks import Error, Tags, Warning, register
|
|
|
from django.db import connection
|
|
from django.db import connection
|
|
|
from django.db.models import Index, UniqueConstraint
|
|
from django.db.models import Index, UniqueConstraint
|
|
@@ -6,6 +7,7 @@ from django.db.models import Index, UniqueConstraint
|
|
|
__all__ = (
|
|
__all__ = (
|
|
|
'check_duplicate_indexes',
|
|
'check_duplicate_indexes',
|
|
|
'check_postgresql_version',
|
|
'check_postgresql_version',
|
|
|
|
|
+ 'check_redis_version',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -67,3 +69,27 @@ def check_postgresql_version(app_configs, **kwargs):
|
|
|
except Exception:
|
|
except Exception:
|
|
|
pass
|
|
pass
|
|
|
return warnings
|
|
return warnings
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@register(Tags.caches)
|
|
|
|
|
+def check_redis_version(app_configs, **kwargs):
|
|
|
|
|
+ """
|
|
|
|
|
+ Warn if the Redis version is less than 6.0, as support for Redis older than 6.0
|
|
|
|
|
+ will be removed in NetBox v4.7.
|
|
|
|
|
+ """
|
|
|
|
|
+ warnings = []
|
|
|
|
|
+ try:
|
|
|
|
|
+ client = cache.client.get_client()
|
|
|
|
|
+ redis_version = tuple(int(x) for x in client.info()['redis_version'].split('.'))
|
|
|
|
|
+ if redis_version < (6, 0):
|
|
|
|
|
+ warnings.append(
|
|
|
|
|
+ Warning(
|
|
|
|
|
+ f'Support for Redis {".".join(str(x) for x in redis_version)} is deprecated and will be '
|
|
|
|
|
+ f'removed in NetBox v4.7.',
|
|
|
|
|
+ hint='Please upgrade to Redis 6.0 or later.',
|
|
|
|
|
+ id='netbox.W002',
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ pass
|
|
|
|
|
+ return warnings
|