mirror of
https://github.com/ceph/ceph
synced 2025-02-21 01:47:25 +00:00
Merge pull request #16749 from tchaikov/wip-restful-delete-key
mgr: handle "module.set_config(.., None)" correctly Reviewed-by: John Spray <john.spray@redhat.com>
This commit is contained in:
commit
342607f4d5
@ -10,8 +10,13 @@ tasks:
|
||||
mon.a:
|
||||
- ceph restful create-key admin
|
||||
- ceph restful create-self-signed-cert
|
||||
- ceph.restart: [mgr.x]
|
||||
- ceph restful restart
|
||||
- workunit:
|
||||
clients:
|
||||
client.a:
|
||||
- rest/test-restful.sh
|
||||
- exec:
|
||||
mon.a:
|
||||
- ceph restful delete-key admin
|
||||
- ceph restful list-keys | jq ".admin" | grep null
|
||||
|
||||
|
@ -577,7 +577,7 @@ PyObject *PyModules::get_config_prefix(const std::string &handle,
|
||||
}
|
||||
|
||||
void PyModules::set_config(const std::string &handle,
|
||||
const std::string &key, const std::string &val)
|
||||
const std::string &key, const boost::optional<std::string>& val)
|
||||
{
|
||||
const std::string global_key = config_prefix + handle + "/" + key;
|
||||
|
||||
@ -586,18 +586,25 @@ void PyModules::set_config(const std::string &handle,
|
||||
PyThreadState *tstate = PyEval_SaveThread();
|
||||
Mutex::Locker l(lock);
|
||||
PyEval_RestoreThread(tstate);
|
||||
config_cache[global_key] = val;
|
||||
if (val) {
|
||||
config_cache[global_key] = *val;
|
||||
} else {
|
||||
config_cache.erase(global_key);
|
||||
}
|
||||
|
||||
std::ostringstream cmd_json;
|
||||
|
||||
JSONFormatter jf;
|
||||
jf.open_object_section("cmd");
|
||||
jf.dump_string("prefix", "config-key set");
|
||||
jf.dump_string("key", global_key);
|
||||
jf.dump_string("val", val);
|
||||
if (val) {
|
||||
jf.dump_string("prefix", "config-key set");
|
||||
jf.dump_string("key", global_key);
|
||||
jf.dump_string("val", *val);
|
||||
} else {
|
||||
jf.dump_string("prefix", "config-key del");
|
||||
jf.dump_string("key", global_key);
|
||||
}
|
||||
jf.close_section();
|
||||
jf.flush(cmd_json);
|
||||
|
||||
set_cmd.run(&monc, cmd_json.str());
|
||||
}
|
||||
set_cmd.wait();
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
PyObject *get_config_prefix(const std::string &handle,
|
||||
const std::string &prefix) const;
|
||||
void set_config(const std::string &handle,
|
||||
const std::string &key, const std::string &val);
|
||||
const std::string &key, const boost::optional<std::string> &val);
|
||||
|
||||
void set_health_checks(const std::string& handle,
|
||||
health_check_map_t&& checks);
|
||||
|
@ -359,11 +359,14 @@ ceph_config_set(PyObject *self, PyObject *args)
|
||||
char *handle = nullptr;
|
||||
char *key = nullptr;
|
||||
char *value = nullptr;
|
||||
if (!PyArg_ParseTuple(args, "sss:ceph_config_set", &handle, &key, &value)) {
|
||||
if (!PyArg_ParseTuple(args, "ssz:ceph_config_set", &handle, &key, &value)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
global_handle->set_config(handle, key, value);
|
||||
boost::optional<string> val;
|
||||
if (value) {
|
||||
val = value;
|
||||
}
|
||||
global_handle->set_config(handle, key, val);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user