[svn] commit: r397 - in /branches/jelte-datadef/src: bin/parkinglot/ccsession.cc lib/bind-cfgd/python/bind-cfgd.py lib/cc/cpp/data.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Dec 22 09:38:48 UTC 2009
Author: jelte
Date: Tue Dec 22 09:38:48 2009
New Revision: 397
Log:
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
Modified:
branches/jelte-datadef/src/bin/parkinglot/ccsession.cc
branches/jelte-datadef/src/lib/bind-cfgd/python/bind-cfgd.py
branches/jelte-datadef/src/lib/cc/cpp/data.h
Modified: branches/jelte-datadef/src/bin/parkinglot/ccsession.cc
==============================================================================
--- branches/jelte-datadef/src/bin/parkinglot/ccsession.cc (original)
+++ branches/jelte-datadef/src/bin/parkinglot/ccsession.cc Tue Dec 22 09:38:48 2009
@@ -82,39 +82,37 @@
config_handler_ = config_handler;
command_handler_ = command_handler;
- try {
- // todo: workaround, let boss wait until msgq is started
- // and remove sleep here
- sleep(1);
+ // todo: workaround, let boss wait until msgq is started
+ // and remove sleep here
+ sleep(1);
- ElementPtr answer, env;
+ 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_.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");
}
}
Modified: branches/jelte-datadef/src/lib/bind-cfgd/python/bind-cfgd.py
==============================================================================
--- branches/jelte-datadef/src/lib/bind-cfgd/python/bind-cfgd.py (original)
+++ branches/jelte-datadef/src/lib/bind-cfgd/python/bind-cfgd.py Tue Dec 22 09:38:48 2009
@@ -108,7 +108,10 @@
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 @@
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")
Modified: branches/jelte-datadef/src/lib/cc/cpp/data.h
==============================================================================
--- branches/jelte-datadef/src/lib/cc/cpp/data.h (original)
+++ branches/jelte-datadef/src/lib/cc/cpp/data.h Tue Dec 22 09:38:48 2009
@@ -99,6 +99,7 @@
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 @@
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 {
More information about the bind10-changes
mailing list