]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/services/settings.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / services / settings.py
CommitLineData
1e59de90
TL
1# -*- coding: utf-8 -*-
2from contextlib import contextmanager
3
4import cherrypy
5
6
7class SettingsService:
8 @contextmanager
9 # pylint: disable=no-self-argument
10 def attribute_handler(name):
11 """
12 :type name: str|dict[str, str]
13 :rtype: str|dict[str, str]
14 """
15 if isinstance(name, dict):
16 result = {
17 _to_native(key): value
18 for key, value in name.items()
19 }
20 else:
21 result = _to_native(name)
22
23 try:
24 yield result
25 except AttributeError: # pragma: no cover - handling is too obvious
26 raise cherrypy.NotFound(result) # pragma: no cover - handling is too obvious
27
28
29def _to_native(setting):
30 return setting.upper().replace('-', '_')