}
return (0, json.dumps(s, indent=4), '')
elif command['prefix'] == 'balancer mode':
- self.set_config('mode', command['mode'])
+ self.set_module_option('mode', command['mode'])
return (0, '', '')
elif command['prefix'] == 'balancer on':
if not self.active:
- self.set_config('active', '1')
+ self.set_module_option('active', '1')
self.active = True
self.event.set()
return (0, '', '')
elif command['prefix'] == 'balancer off':
if self.active:
- self.set_config('active', '')
+ self.set_module_option('active', '')
self.active = False
self.event.set()
return (0, '', '')
if res[0] != -errno.ENOSYS:
return res
elif cmd['prefix'] == 'dashboard set-jwt-token-ttl':
- self.set_config('jwt_token_ttl', str(cmd['seconds']))
+ self.set_module_option('jwt_token_ttl', str(cmd['seconds']))
return 0, 'JWT token TTL updated', ''
elif cmd['prefix'] == 'dashboard get-jwt-token-ttl':
ttl = self.get_module_option('jwt_token_ttl', JwtManager.JWT_TOKEN_TTL)
def __setattr__(cls, attr, value):
if not attr.startswith('_') and hasattr(Options, attr):
- mgr.set_config(attr, str(value))
+ mgr.set_module_option(attr, str(value))
else:
setattr(SettingsMeta, attr, value)
def __delattr__(self, attr):
if not attr.startswith('_') and hasattr(Options, attr):
- mgr.set_config(attr, None)
+ mgr.set_module_option(attr, None)
# pylint: disable=no-init
return (-errno.EINVAL, '',
"Unknown configuration option '{0}'".format(cmd['key']))
- self.set_config(cmd['key'], cmd['value'])
+ self.set_module_option(cmd['key'], cmd['value'])
self._event.set();
return 0, "Configuration option '{0}' updated".format(cmd['key']), ''
elif cmd['prefix'] == 'device check-health':
return self.check_health()
elif cmd['prefix'] == 'device monitoring on':
- self.set_config('enable_monitoring', 'true')
+ self.set_module_option('enable_monitoring', 'true')
self.event.set()
return 0, '', ''
elif cmd['prefix'] == 'device monitoring off':
- self.set_config('enable_monitoring', 'false')
+ self.set_module_option('enable_monitoring', 'false')
self.set_health_checks({}) # avoid stuck health alerts
return 0, '', ''
elif cmd['prefix'] == 'device predict-life-expectancy':
self.log.debug('Setting in-memory config option %s to: %s', option,
value)
- self.set_config(option, value)
+ self.set_module_option(option, value)
self.config[option] = value
return True
def _set_ssl_target_name(self, cmd):
str_ssl_target = cmd.get('ssl_target_name', '')
try:
- self.set_config('diskprediction_ssl_target_name_override', str_ssl_target)
+ self.set_module_option('diskprediction_ssl_target_name_override', str_ssl_target)
return (0,
'success to config ssl target name', 0)
except Exception as e:
def _set_ssl_default_authority(self, cmd):
str_ssl_authority = cmd.get('ssl_authority', '')
try:
- self.set_config('diskprediction_default_authority', str_ssl_authority)
+ self.set_module_option('diskprediction_default_authority', str_ssl_authority)
return 0, 'success to config ssl default authority', 0
except Exception as e:
return -errno.EINVAL, '', str(e)
'diskprediction_cert_context', trusted_certs)
for _agent in self._agents:
_agent.event.set()
- self.set_config('diskprediction_server', cmd['server'])
- self.set_config('diskprediction_user', cmd['user'])
- self.set_config('diskprediction_password', encode_string(cmd['password']))
+ self.set_module_option('diskprediction_server', cmd['server'])
+ self.set_module_option('diskprediction_user', cmd['user'])
+ self.set_module_option('diskprediction_password', encode_string(cmd['password']))
if cmd.get('port'):
- self.set_config('diskprediction_port', cmd['port'])
+ self.set_module_option('diskprediction_port', cmd['port'])
return 0, 'succeed to config cloud mode connection', ''
else:
return -errno.EINVAL, '', 'certification file not existed'
self.log.debug('Setting configuration option %s to %s', key, value)
self.set_config_option(key, value)
- self.set_config(key, value)
+ self.set_module_option(key, value)
return 0, 'Configuration option {0} updated'.format(key), ''
elif cmd['prefix'] == 'influx send':
self.send_to_influx()
self._validate_module_option(key)
return self._get_localized(key, default, self._get_module_option)
- def _set_config(self, key, val):
+ def _set_module_option(self, key, val):
return self._ceph_set_config(key, val)
- def set_config(self, key, val):
+ def set_module_option(self, key, val):
"""
Set the value of a persistent configuration setting
:param str val:
"""
self._validate_module_option(key)
- return self._set_config(key, val)
+ return self._set_module_option(key, val)
- def set_localized_config(self, key, val):
+ def set_localized_module_option(self, key, val):
"""
Set localized configuration for this ceph-mgr instance
:param str key:
:return: str
"""
self._validate_module_option(key)
- return self._set_localized(key, val, self._set_config)
+ return self._set_localized(key, val, self._set_module_option)
def set_store(self, key, val):
"""
module_name = cmd['module']
if module_name == "":
- self.set_config("orchestrator", None)
+ self.set_module_option("orchestrator", None)
return HandleCommandResult()
for module in mgr_map['available_modules']:
return HandleCommandResult(-errno.EINVAL,
rs="'{0}' is not an orchestrator module".format(module_name))
- self.set_config("orchestrator", module_name)
+ self.set_module_option("orchestrator", module_name)
return HandleCommandResult()
# This is not a strong test (can't tell if values really
# persisted), it's just for the python interface bit.
- self.set_config("testkey", "testvalue")
+ self.set_module_option("testkey", "testvalue")
assert self.get_module_option("testkey") == "testvalue"
- self.set_localized_config("testkey", "testvalue")
+ self.set_localized_module_option("testkey", "testvalue")
assert self.get_localized_module_option("testkey") == "testvalue"
def _self_test_store(self):
self.log.debug('Setting configuration option %s to %s', key, value)
self.set_config_option(key, value)
- self.set_config(key, value)
+ self.set_module_option(key, value)
return 0, 'Configuration option {0} updated'.format(key), ''
elif cmd['prefix'] == 'telegraf send':
self.send_to_telegraf()
self.log.debug('Setting configuration option %s to %s', key, value)
self.set_config_option(key, value)
- self.set_config(key, value)
+ self.set_module_option(key, value)
return 0, 'Configuration option {0} updated'.format(key), ''
elif command['prefix'] == 'telemetry send':
self.last_report = self.compile_report()
self.log.debug('Setting configuration option %s to %s', key, value)
if self.set_config_option(key, value):
- self.set_config(key, value)
+ self.set_module_option(key, value)
return 0, 'Configuration option {0} updated'.format(key), ''
return 1,\