1 from pecan import expose, request
2 from pecan.rest import RestController
4 from restful import common, module
5 from restful.decorators import auth
8 class ConfigOsd(RestController):
9 @expose(template='json')
11 def get(self, **kwargs):
13 Show OSD configuration options
15 flags = module.instance.get("osd_map")['flags']
17 # pause is a valid osd config command that sets pauserd,pausewr
18 flags = flags.replace('pauserd,pausewr', 'pause')
20 return flags.split(',')
23 @expose(template='json')
25 def patch(self, **kwargs):
27 Modify OSD configration options
33 valid_flags = set(args.keys()) & set(common.OSD_FLAGS)
34 invalid_flags = list(set(args.keys()) - valid_flags)
36 module.instance.log.warn("%s not valid to set/unset" % invalid_flags)
38 for flag in list(valid_flags):
45 'prefix': 'osd ' + mode,
49 return module.instance.submit_request([commands], **kwargs)
53 class ConfigClusterKey(RestController):
54 def __init__(self, key):
58 @expose(template='json')
60 def get(self, **kwargs):
62 Show specific configuration option
64 return module.instance.get("config").get(self.key, None)
68 class ConfigCluster(RestController):
69 @expose(template='json')
71 def get(self, **kwargs):
73 Show all cluster configuration options
75 return module.instance.get("config")
79 def _lookup(self, key, *remainder):
80 return ConfigClusterKey(key), remainder
84 class Config(RestController):
85 cluster = ConfigCluster()