Skip to content

Commit

Permalink
[change] Removed support for deprecated settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Aug 1, 2024
1 parent f523b89 commit 16a396a
Showing 1 changed file with 25 additions and 42 deletions.
67 changes: 25 additions & 42 deletions openwisp_controller/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,19 @@
logger = logging.getLogger(__name__)


def get_settings_value(option, default):
if option == 'CONFIG_BACKEND_FIELD_SHOWN' and hasattr(
settings, 'OPENWISP_CONTROLLER_BACKEND_DEVICE_LIST'
):
logger.warn(
'OPENWISP_CONTROLLER_BACKEND_DEVICE_LIST is deprecated and will be '
'removed in the future, please use '
'OPENWISP_CONTROLLER_CONFIG_BACKEND_FIELD_SHOWN instead.'
)
return getattr(settings, 'OPENWISP_CONTROLLER_BACKEND_DEVICE_LIST', default)
if hasattr(settings, f'NETJSONCONFIG_{option}'):
logger.warn(
f'NETJSONCONFIG_{option} setting is deprecated. It will be removed '
f'in the future, please use OPENWISP_CONTROLLER_{option} instead.'
)
return getattr(settings, f'NETJSONCONFIG_{option}')
def get_setting(option, default):
return getattr(settings, f'OPENWISP_CONTROLLER_{option}', default)


BACKENDS = get_settings_value(
BACKENDS = get_setting(
'BACKENDS',
(
('netjsonconfig.OpenWrt', 'OpenWRT'),
('netjsonconfig.OpenWisp', 'OpenWISP Firmware 1.x'),
),
)

VPN_BACKENDS = get_settings_value(
VPN_BACKENDS = get_setting(
'VPN_BACKENDS',
(
('openwisp_controller.vpn_backends.OpenVpn', 'OpenVPN'),
Expand All @@ -42,21 +27,21 @@ def get_settings_value(option, default):
('openwisp_controller.vpn_backends.ZeroTier', 'ZeroTier'),
),
)
DEFAULT_BACKEND = get_settings_value('DEFAULT_BACKEND', BACKENDS[0][0])
DEFAULT_VPN_BACKEND = get_settings_value('DEFAULT_VPN_BACKEND', VPN_BACKENDS[0][0])
REGISTRATION_ENABLED = get_settings_value('REGISTRATION_ENABLED', True)
CONSISTENT_REGISTRATION = get_settings_value('CONSISTENT_REGISTRATION', True)
REGISTRATION_SELF_CREATION = get_settings_value('REGISTRATION_SELF_CREATION', True)
DEFAULT_BACKEND = get_setting('DEFAULT_BACKEND', BACKENDS[0][0])
DEFAULT_VPN_BACKEND = get_setting('DEFAULT_VPN_BACKEND', VPN_BACKENDS[0][0])
REGISTRATION_ENABLED = get_setting('REGISTRATION_ENABLED', True)
CONSISTENT_REGISTRATION = get_setting('CONSISTENT_REGISTRATION', True)
REGISTRATION_SELF_CREATION = get_setting('REGISTRATION_SELF_CREATION', True)

CONTEXT = get_settings_value('CONTEXT', {})
CONTEXT = get_setting('CONTEXT', {})
assert isinstance(CONTEXT, dict), 'OPENWISP_CONTROLLER_CONTEXT must be a dictionary'
DEFAULT_AUTO_CERT = get_settings_value('DEFAULT_AUTO_CERT', True)
CERT_PATH = get_settings_value('CERT_PATH', '/etc/x509')
COMMON_NAME_FORMAT = get_settings_value('COMMON_NAME_FORMAT', '{mac_address}-{name}')
MANAGEMENT_IP_DEVICE_LIST = get_settings_value('MANAGEMENT_IP_DEVICE_LIST', True)
CONFIG_BACKEND_FIELD_SHOWN = get_settings_value('CONFIG_BACKEND_FIELD_SHOWN', True)
DEFAULT_AUTO_CERT = get_setting('DEFAULT_AUTO_CERT', True)
CERT_PATH = get_setting('CERT_PATH', '/etc/x509')
COMMON_NAME_FORMAT = get_setting('COMMON_NAME_FORMAT', '{mac_address}-{name}')
MANAGEMENT_IP_DEVICE_LIST = get_setting('MANAGEMENT_IP_DEVICE_LIST', True)
CONFIG_BACKEND_FIELD_SHOWN = get_setting('CONFIG_BACKEND_FIELD_SHOWN', True)

HARDWARE_ID_ENABLED = get_settings_value('HARDWARE_ID_ENABLED', False)
HARDWARE_ID_ENABLED = get_setting('HARDWARE_ID_ENABLED', False)
HARDWARE_ID_OPTIONS = {
'blank': not HARDWARE_ID_ENABLED,
'null': True,
Expand All @@ -65,22 +50,20 @@ def get_settings_value(option, default):
'verbose_name': _('Serial number'),
'help_text': _('Serial number of this device'),
}
HARDWARE_ID_OPTIONS.update(get_settings_value('HARDWARE_ID_OPTIONS', {}))
HARDWARE_ID_AS_NAME = get_settings_value('HARDWARE_ID_AS_NAME', True)
DEVICE_VERBOSE_NAME = get_settings_value(
'DEVICE_VERBOSE_NAME', (_('Device'), _('Devices'))
)
DEVICE_NAME_UNIQUE = get_settings_value('DEVICE_NAME_UNIQUE', True)
DEVICE_GROUP_SCHEMA = get_settings_value(
HARDWARE_ID_OPTIONS.update(get_setting('HARDWARE_ID_OPTIONS', {}))
HARDWARE_ID_AS_NAME = get_setting('HARDWARE_ID_AS_NAME', True)
DEVICE_VERBOSE_NAME = get_setting('DEVICE_VERBOSE_NAME', (_('Device'), _('Devices')))
DEVICE_NAME_UNIQUE = get_setting('DEVICE_NAME_UNIQUE', True)
DEVICE_GROUP_SCHEMA = get_setting(
'DEVICE_GROUP_SCHEMA', {'type': 'object', 'properties': {}}
)
SHARED_MANAGEMENT_IP_ADDRESS_SPACE = get_settings_value(
SHARED_MANAGEMENT_IP_ADDRESS_SPACE = get_setting(
'SHARED_MANAGEMENT_IP_ADDRESS_SPACE', True
)
DSA_OS_MAPPING = get_settings_value('DSA_OS_MAPPING', {})
DSA_DEFAULT_FALLBACK = get_settings_value('DSA_DEFAULT_FALLBACK', True)
GROUP_PIE_CHART = get_settings_value('GROUP_PIE_CHART', False)
API_TASK_RETRY_OPTIONS = get_settings_value(
DSA_OS_MAPPING = get_setting('DSA_OS_MAPPING', {})
DSA_DEFAULT_FALLBACK = get_setting('DSA_DEFAULT_FALLBACK', True)
GROUP_PIE_CHART = get_setting('GROUP_PIE_CHART', False)
API_TASK_RETRY_OPTIONS = get_setting(
'API_TASK_RETRY_OPTIONS',
dict(max_retries=5, retry_backoff=True, retry_backoff_max=600, retry_jitter=True),
)

0 comments on commit 16a396a

Please sign in to comment.