std::string server;
std::set<DaemonKey> daemons;
+ std::map<string,string> metadata; ///< persistent metadata
+
DeviceState(const std::string& n) : devid(n) {}
+
+ void set_metadata(map<string,string>&& m);
+
+ /// true of we can be safely forgotten/removed from memory
+ bool empty() const {
+ return daemons.empty() && metadata.empty();
+ }
};
typedef boost::intrusive_ptr<DeviceState> DeviceStateRef;
dout(20) << "saw key '" << key << "'" << dendl;
const std::string config_prefix = PyModule::config_prefix;
+ const std::string device_prefix = "device/";
- if (key.substr(0, config_prefix.size()) == config_prefix) {
+ if (key.substr(0, config_prefix.size()) == config_prefix ||
+ key.substr(0, device_prefix.size()) == device_prefix) {
dout(20) << "fetching '" << key << "'" << dendl;
Command get_cmd;
std::ostringstream cmd_json;
get_cmd.wait();
lock.Lock();
if (get_cmd.r == 0) { // tolerate racing config-key change
- loaded[key] = get_cmd.outbl.to_str();
+ if (key.substr(0, device_prefix.size()) == device_prefix) {
+ // device/
+ string devid = key.substr(device_prefix.size());
+ map<string,string> meta;
+ ostringstream ss;
+ string val = get_cmd.outbl.to_str();
+ int r = get_json_str_map(val, ss, &meta, false);
+ if (r < 0) {
+ derr << __func__ << " failed to parse " << val << ": " << ss.str()
+ << dendl;
+ } else {
+ daemon_state.with_device_create(
+ devid, [&meta] (DeviceState& dev) {
+ dev.set_metadata(std::move(meta));
+ });
+ }
+ } else {
+ // config/
+ loaded[key] = get_cmd.outbl.to_str();
+ }
}
}
}
dout(1) << "Upgrading module configuration for Mimic" << dendl;
// Upgrade luminous->mimic: migrate config-key configuration
// into main configuration store
- for(auto &i : old_config) {
+ for (auto &i : old_config) {
auto last_slash = i.first.rfind('/');
const std::string module_name = i.first.substr(4, i.first.substr(4).find('/'));
const std::string key = i.first.substr(last_slash + 1);