From e21e31762799684938b855dc0c4e917c03beec13 Mon Sep 17 00:00:00 2001 From: Mika Busch Date: Fri, 7 Feb 2025 17:21:39 +0000 Subject: [PATCH] Check that Disk/Ram base units are 1000 or 1024 --- netbox/netbox/settings.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 875d06dc8..f48865f52 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -177,7 +177,11 @@ STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {}) TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC') TRANSLATION_ENABLED = getattr(configuration, 'TRANSLATION_ENABLED', True) DISK_BASE_UNIT = getattr(configuration, 'DISK_BASE_UNIT', 1000) +if DISK_BASE_UNIT not in [1000, 1024]: + raise ImproperlyConfigured(f"DISK_BASE_UNIT must be 1000 or 1024 (found {DISK_BASE_UNIT})") RAM_BASE_UNIT = getattr(configuration, 'MEMORY_UNIT_DIVISOR', 1000) +if RAM_BASE_UNIT not in [1000, 1024]: + raise ImproperlyConfigured(f"RAM_BASE_UNIT must be 1000 or 1024 (found {RAM_BASE_UNIT})") # Load any dynamic configuration parameters which have been hard-coded in the configuration file for param in CONFIG_PARAMS: