Commit ec10fee3 authored by Jelte Jansen's avatar Jelte Jansen

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
parent 91d64d64
......@@ -82,39 +82,37 @@ CommandSession::CommandSession(std::string module_name,
config_handler_ = config_handler;
command_handler_ = command_handler;
try {
// todo: workaround, let boss wait until msgq is started
// and remove sleep here
sleep(1);
ElementPtr answer, env;
session_.establish();
session_.subscribe(module_name, "*");
session_.subscribe("Boss", "*", "meonly");
session_.subscribe("ConfigManager", "*", "meonly");
session_.subscribe("statistics", "*", "meonly");
read_data_definition(spec_file_name);
sleep(1);
// send the data specification
session_.group_sendmsg(data_definition_.getDefinition(), "ConfigManager");
// todo: workaround, let boss wait until msgq is started
// and remove sleep here
sleep(1);
ElementPtr answer, env;
session_.establish();
session_.subscribe(module_name, "*");
session_.subscribe("Boss", "*", "meonly");
session_.subscribe("ConfigManager", "*", "meonly");
session_.subscribe("statistics", "*", "meonly");
read_data_definition(spec_file_name);
sleep(1);
// send the data specification
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);
// 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);
cout << "[XX] got config: " << endl << answer->str() << endl;
// replace string_value and "0" with int_value and 0 with new cc after merge */
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;
}
cout << "[XX] got config: " << endl << answer->str() << endl;
// replace string_value and "0" with int_value and 0 with new cc after merge */
if (answer->contains("result") &&
answer->get("result")->get(0)->string_value() == "0" &&
answer->get("result")->size() > 1) {
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
else:
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":
if len(cmd) == 3:
# todo: use api (and check types?)
......@@ -162,7 +165,6 @@ class ConfigManager:
if "config_data" in spec:
self.set_config(spec["module_name"], spec["config_data"])
self.cc.group_sendmsg({ "specification_update": [ spec["module_name"], spec["config_data"] ] }, "BigTool")
print("[XX] sent spec_update")
if "commands" in spec:
self.set_commands(spec["module_name"], spec["commands"])
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 add(ElementPtr element) { throw TypeError(); };
virtual void remove(ElementPtr element) { throw TypeError(); };
virtual size_t size() { throw TypeError(); };
// for maps
virtual ElementPtr get(const std::string& name) { throw TypeError(); } ;
......@@ -236,6 +237,7 @@ namespace ISC { namespace Data {
std::string str();
std::string str_xml(size_t prefix = 0);
std::string to_wire(int omit_length = 1);
size_t size() { return l.size(); }
};
class MapElement : public Element {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment