mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 18:38:25 +00:00
9bb6b19832
* Allow configuration of the SSL/TLS operating mode when connecting to a mysql database * Support SSL/TLS DB connections in the dispatcher service as well * Apply black formatting standards to Python files * Suppress pylint errors as redis module is not installed when linting * More pylint fixes * Correct typo in logging output * Refactor SSL/TLS changes into DBConfig class instead of ServiceConfig * Define DB config variables as class vars instead of instance vars * Break circular import
24 lines
683 B
Python
24 lines
683 B
Python
class DBConfig:
|
|
"""
|
|
Bare minimal config class for LibreNMS.DB class usage
|
|
"""
|
|
|
|
# Start with defaults and override
|
|
db_host = "localhost"
|
|
db_port = 0
|
|
db_socket = None
|
|
db_user = "librenms"
|
|
db_pass = ""
|
|
db_name = "librenms"
|
|
db_sslmode = "disabled"
|
|
db_ssl_ca = "/etc/ssl/certs/ca-certificates.crt"
|
|
|
|
def populate(self, _config):
|
|
for key, val in _config.items():
|
|
if key == "db_port":
|
|
# Special case: port number
|
|
self.db_port = int(val)
|
|
elif key.startswith("db_"):
|
|
# Prevent prototype pollution by enforcing prefix
|
|
setattr(DBConfig, key, val)
|