From: John Mulligan Date: Wed, 25 Feb 2026 00:22:10 +0000 (-0500) Subject: mgr/smb: add a simple validation function for log level dict X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5648f573e6c2e86c1773c78a77c59fa02ba9628c;p=ceph.git mgr/smb: add a simple validation function for log level dict Add a simple validation function for log level dict. Values in this dict are expected to vary and will support some amount of "guessing" so we don't do much with the values. Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/smb/validation.py b/src/pybind/mgr/smb/validation.py index 02fab2a642a..18166205375 100644 --- a/src/pybind/mgr/smb/validation.py +++ b/src/pybind/mgr/smb/validation.py @@ -141,3 +141,27 @@ def check_custom_ports(ports: Optional[Dict[str, int]]) -> None: 'port numbers must be unique:' f' {port} used for {", ".join(sorted(using_port))}' ) + + +def check_debug_level(debug_level: Optional[dict[str, str]]) -> None: + """Check the types of the debug_level parameter. + NOTE: this is intentionally fairly loose with regards to values in order + to retain state and lazily translate values as needed. + """ + if debug_level is None: + return + if not isinstance(debug_level, dict): + raise ValueError(f'invalid debug_level type: {type(debug_level)}') + _keys = {'samba', 'ctdb'} + for key, value in debug_level.items(): + if not isinstance(key, str): + raise ValueError(f'invalid type in debug_level: {type(key)}') + if not isinstance(value, str): + raise ValueError(f'invalid type in debug_level: {type(value)}') + if key not in _keys: + raise ValueError(f'invalid key in debug_level: {key!r}') + if not ( + value.isdigit() + or value.upper() in ceph.smb.constants.DEBUG_LEVEL_TERMS + ): + raise ValueError(f'invalid value in debug_level: {value!r}')