summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/restful/api/config.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/pybind/mgr/restful/api/config.py
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pybind/mgr/restful/api/config.py')
-rw-r--r--src/pybind/mgr/restful/api/config.py86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/pybind/mgr/restful/api/config.py b/src/pybind/mgr/restful/api/config.py
new file mode 100644
index 00000000..565896c8
--- /dev/null
+++ b/src/pybind/mgr/restful/api/config.py
@@ -0,0 +1,86 @@
+from pecan import expose, request
+from pecan.rest import RestController
+
+from restful import common, context
+from restful.decorators import auth
+
+
+class ConfigOsd(RestController):
+ @expose(template='json')
+ @auth
+ def get(self, **kwargs):
+ """
+ Show OSD configuration options
+ """
+ flags = context.instance.get("osd_map")['flags']
+
+ # pause is a valid osd config command that sets pauserd,pausewr
+ flags = flags.replace('pauserd,pausewr', 'pause')
+
+ return flags.split(',')
+
+
+ @expose(template='json')
+ @auth
+ def patch(self, **kwargs):
+ """
+ Modify OSD configuration options
+ """
+ args = request.json
+
+ commands = []
+
+ valid_flags = set(args.keys()) & set(common.OSD_FLAGS)
+ invalid_flags = list(set(args.keys()) - valid_flags)
+ if invalid_flags:
+ context.instance.log.warn("%s not valid to set/unset", invalid_flags)
+
+ for flag in list(valid_flags):
+ if args[flag]:
+ mode = 'set'
+ else:
+ mode = 'unset'
+
+ commands.append({
+ 'prefix': 'osd ' + mode,
+ 'key': flag,
+ })
+
+ return context.instance.submit_request([commands], **kwargs)
+
+
+
+class ConfigClusterKey(RestController):
+ def __init__(self, key):
+ self.key = key
+
+
+ @expose(template='json')
+ @auth
+ def get(self, **kwargs):
+ """
+ Show specific configuration option
+ """
+ return context.instance.get("config").get(self.key, None)
+
+
+
+class ConfigCluster(RestController):
+ @expose(template='json')
+ @auth
+ def get(self, **kwargs):
+ """
+ Show all cluster configuration options
+ """
+ return context.instance.get("config")
+
+
+ @expose()
+ def _lookup(self, key, *remainder):
+ return ConfigClusterKey(key), remainder
+
+
+
+class Config(RestController):
+ cluster = ConfigCluster()
+ osd = ConfigOsd()