mirror of
https://github.com/ceph/ceph
synced 2025-04-07 10:03:50 +00:00
pybind/mgr/mgr_module: normalize defaults to str when type is missing
If the module doesn't specify a type for the option, it is probably an older module. Make sure that the default value we provide is normalized to a string, just in case the module declares something like { 'name': 'my_option', 'default': True, } where the default is *not* a string, but an user-set value coming from the config infrastructure would be a string. Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
3ad7ac259a
commit
0228bd7922
@ -323,7 +323,15 @@ class MgrModule(ceph_module.BaseMgrModule):
|
|||||||
|
|
||||||
for o in self.MODULE_OPTIONS:
|
for o in self.MODULE_OPTIONS:
|
||||||
if 'default' in o:
|
if 'default' in o:
|
||||||
self.MODULE_OPTION_DEFAULTS[o['name']] = o['default']
|
if 'type' in o:
|
||||||
|
# we'll assume the declared type matches the
|
||||||
|
# supplied default value's type.
|
||||||
|
self.MODULE_OPTION_DEFAULTS[o['name']] = o['default']
|
||||||
|
else:
|
||||||
|
# module not declaring it's type, so normalize the
|
||||||
|
# default value to be a string for consistent behavior
|
||||||
|
# with default and user-supplied option values.
|
||||||
|
self.MODULE_OPTION_DEFAULTS[o['name']] = str(o['default'])
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
unconfigure_logger(self, self.module_name)
|
unconfigure_logger(self, self.module_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user