mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
don't send config if it is None
removed catch-all in ccsession (i want to get the original exception) check result size after get_config in parkinglot git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-datadef@397 e5f2f494-b856-4b98-b285-d166d9295462
This commit is contained in:
@@ -82,39 +82,37 @@ CommandSession::CommandSession(std::string module_name,
|
|||||||
config_handler_ = config_handler;
|
config_handler_ = config_handler;
|
||||||
command_handler_ = command_handler;
|
command_handler_ = command_handler;
|
||||||
|
|
||||||
try {
|
// todo: workaround, let boss wait until msgq is started
|
||||||
// todo: workaround, let boss wait until msgq is started
|
// and remove sleep here
|
||||||
// and remove sleep here
|
sleep(1);
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
ElementPtr answer, env;
|
ElementPtr answer, env;
|
||||||
|
|
||||||
session_.establish();
|
session_.establish();
|
||||||
session_.subscribe(module_name, "*");
|
session_.subscribe(module_name, "*");
|
||||||
session_.subscribe("Boss", "*", "meonly");
|
session_.subscribe("Boss", "*", "meonly");
|
||||||
session_.subscribe("ConfigManager", "*", "meonly");
|
session_.subscribe("ConfigManager", "*", "meonly");
|
||||||
session_.subscribe("statistics", "*", "meonly");
|
session_.subscribe("statistics", "*", "meonly");
|
||||||
read_data_definition(spec_file_name);
|
read_data_definition(spec_file_name);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
// send the data specification
|
// send the data specification
|
||||||
session_.group_sendmsg(data_definition_.getDefinition(), "ConfigManager");
|
session_.group_sendmsg(data_definition_.getDefinition(), "ConfigManager");
|
||||||
|
session_.group_recvmsg(env, answer, false);
|
||||||
|
|
||||||
|
// get any stored configuration from the manager
|
||||||
|
if (config_handler_) {
|
||||||
|
ElementPtr cmd = Element::create_from_string("{ \"command\": [ \"get_config\", \"" + module_name + "\" ] }");
|
||||||
|
session_.group_sendmsg(cmd, "ConfigManager");
|
||||||
session_.group_recvmsg(env, answer, false);
|
session_.group_recvmsg(env, answer, false);
|
||||||
|
cout << "[XX] got config: " << endl << answer->str() << endl;
|
||||||
// get any stored configuration from the manager
|
// replace string_value and "0" with int_value and 0 with new cc after merge */
|
||||||
if (config_handler_) {
|
if (answer->contains("result") &&
|
||||||
ElementPtr cmd = Element::create_from_string("{ \"command\": [ \"get_config\", \"" + module_name + "\" ] }");
|
answer->get("result")->get(0)->string_value() == "0" &&
|
||||||
session_.group_sendmsg(cmd, "ConfigManager");
|
answer->get("result")->size() > 1) {
|
||||||
session_.group_recvmsg(env, answer, false);
|
config_handler(answer->get("result")->get(1));
|
||||||
cout << "[XX] got config: " << endl << answer->str() << endl;
|
} else {
|
||||||
// replace string_value and "0" with int_value and 0 with new cc after merge */
|
cout << "[XX] no result in answer" << endl;
|
||||||
if (answer->contains("result") && answer->get("result")->get(0)->string_value() == "0") {
|
|
||||||
config_handler(answer->get("result")->get(1));
|
|
||||||
} else {
|
|
||||||
cout << "[XX] no result in answer" << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (...) {
|
|
||||||
throw std::runtime_error("SessionManager: failed to open sessions");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,7 +108,10 @@ class ConfigManager:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
conf_part = self.config.data
|
conf_part = self.config.data
|
||||||
answer["result"] = [ 0, conf_part ]
|
if conf_part:
|
||||||
|
answer["result"] = [ 0, conf_part ]
|
||||||
|
else:
|
||||||
|
answer["result"] = [ 0 ]
|
||||||
elif cmd[0] == "set_config":
|
elif cmd[0] == "set_config":
|
||||||
if len(cmd) == 3:
|
if len(cmd) == 3:
|
||||||
# todo: use api (and check types?)
|
# todo: use api (and check types?)
|
||||||
@@ -162,7 +165,6 @@ class ConfigManager:
|
|||||||
if "config_data" in spec:
|
if "config_data" in spec:
|
||||||
self.set_config(spec["module_name"], spec["config_data"])
|
self.set_config(spec["module_name"], spec["config_data"])
|
||||||
self.cc.group_sendmsg({ "specification_update": [ spec["module_name"], spec["config_data"] ] }, "BigTool")
|
self.cc.group_sendmsg({ "specification_update": [ spec["module_name"], spec["config_data"] ] }, "BigTool")
|
||||||
print("[XX] sent spec_update")
|
|
||||||
if "commands" in spec:
|
if "commands" in spec:
|
||||||
self.set_commands(spec["module_name"], spec["commands"])
|
self.set_commands(spec["module_name"], spec["commands"])
|
||||||
self.cc.group_sendmsg({ "commands_update": [ spec["module_name"], spec["commands"] ] }, "BigTool")
|
self.cc.group_sendmsg({ "commands_update": [ spec["module_name"], spec["commands"] ] }, "BigTool")
|
||||||
|
@@ -99,6 +99,7 @@ namespace ISC { namespace Data {
|
|||||||
virtual void set(const int i, ElementPtr element) { throw TypeError(); };
|
virtual void set(const int i, ElementPtr element) { throw TypeError(); };
|
||||||
virtual void add(ElementPtr element) { throw TypeError(); };
|
virtual void add(ElementPtr element) { throw TypeError(); };
|
||||||
virtual void remove(ElementPtr element) { throw TypeError(); };
|
virtual void remove(ElementPtr element) { throw TypeError(); };
|
||||||
|
virtual size_t size() { throw TypeError(); };
|
||||||
|
|
||||||
// for maps
|
// for maps
|
||||||
virtual ElementPtr get(const std::string& name) { throw TypeError(); } ;
|
virtual ElementPtr get(const std::string& name) { throw TypeError(); } ;
|
||||||
@@ -236,6 +237,7 @@ namespace ISC { namespace Data {
|
|||||||
std::string str();
|
std::string str();
|
||||||
std::string str_xml(size_t prefix = 0);
|
std::string str_xml(size_t prefix = 0);
|
||||||
std::string to_wire(int omit_length = 1);
|
std::string to_wire(int omit_length = 1);
|
||||||
|
size_t size() { return l.size(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapElement : public Element {
|
class MapElement : public Element {
|
||||||
|
Reference in New Issue
Block a user