[svn] commit: r347 - in /branches/jelte-datadef/src: bin/bigtool/ bin/parkinglot/ lib/bind-cfgd/python/ lib/cc/python/ISC/CC/
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 4 09:23:37 UTC 2009
Author: jelte
Date: Fri Dec 4 09:23:37 2009
New Revision: 347
Log:
let parkinglot receive config_update command and serve the zones from there
Modified:
branches/jelte-datadef/src/bin/bigtool/run_bigtool.py
branches/jelte-datadef/src/bin/parkinglot/ccsession.cc
branches/jelte-datadef/src/bin/parkinglot/ccsession.h
branches/jelte-datadef/src/bin/parkinglot/main.cc
branches/jelte-datadef/src/bin/parkinglot/parkinglot.cc
branches/jelte-datadef/src/bin/parkinglot/parkinglot.h
branches/jelte-datadef/src/bin/parkinglot/zoneset.h
branches/jelte-datadef/src/lib/bind-cfgd/python/bind-cfgd.py
branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py
Modified: branches/jelte-datadef/src/bin/bigtool/run_bigtool.py
==============================================================================
--- branches/jelte-datadef/src/bin/bigtool/run_bigtool.py (original)
+++ branches/jelte-datadef/src/bin/bigtool/run_bigtool.py Fri Dec 4 09:23:37 2009
@@ -106,7 +106,7 @@
tool = BigTool(cc)
cc.group_sendmsg({ "command": ["get_commands"] }, "ConfigManager")
command_spec, env = cc.group_recvmsg(False)
- prepare_commands(tool, command_spec["result"])
+ prepare_commands(tool, command_spec["result"][1])
prepare_config_commands(tool)
_prepare_fake_data(tool)
tool.cmdloop()
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 Fri Dec 4 09:23:37 2009
@@ -81,7 +81,7 @@
// and remove sleep here
sleep(1);
session_.establish();
- session_.subscribe("ParkingLot", "*", "meonly");
+ session_.subscribe("ParkingLot", "*");
session_.subscribe("Boss", "*", "meonly");
session_.subscribe("ConfigManager", "*", "meonly");
session_.subscribe("statistics", "*", "meonly");
@@ -102,11 +102,11 @@
return (session_.getSocket());
}
-std::pair<std::string, std::string>
+std::pair<std::string, ElementPtr>
CommandSession::getCommand(int counter) {
ElementPtr cmd, routing, data, ep;
string s;
-
+ cout << "[XX] PARKINGLOT GOT MESSAGE" << endl;
session_.group_recvmsg(routing, data, false);
string channel = routing->get("group")->string_value();
@@ -123,16 +123,21 @@
session_.group_sendmsg(resp, "statistics");
}
} else {
+ cout << "[parkinglot] saw message: " << data << endl;
cmd = data->get("zone_added");
if (cmd != NULL)
- return std::pair<string, string>("addzone", cmd->string_value());
+ return std::pair<string, ElementPtr>("addzone", cmd);
cmd = data->get("zone_deleted");
if (cmd != NULL) {
- return std::pair<string, string>("delzone", cmd->string_value());
+ return std::pair<string, ElementPtr>("delzone", cmd);
+ }
+ cmd = data->get("config_update");
+ if (cmd != NULL) {
+ return std::pair<string, ElementPtr>("config_update", cmd);
}
}
- return std::pair<string, string>("unknown", "");
+ return std::pair<string, ElementPtr>("unknown", ElementPtr());
}
// should be replaced by the general config-getter in cc setup
@@ -144,6 +149,7 @@
session_.group_sendmsg(cmd, "ConfigManager");
session_.group_recvmsg(env, result, false);
BOOST_FOREACH(ElementPtr zone_name, result->get("result")->list_value()) {
+ cout << "[XX] add zone: " << zone_name->string_value() << endl;
zone_names.push_back(zone_name->string_value());
}
return zone_names;
Modified: branches/jelte-datadef/src/bin/parkinglot/ccsession.h
==============================================================================
--- branches/jelte-datadef/src/bin/parkinglot/ccsession.h (original)
+++ branches/jelte-datadef/src/bin/parkinglot/ccsession.h Fri Dec 4 09:23:37 2009
@@ -27,7 +27,7 @@
public:
CommandSession();
int getSocket();
- std::pair<std::string, std::string> getCommand(int counter);
+ std::pair<std::string, ISC::Data::ElementPtr> getCommand(int counter);
std::vector<std::string> getZones();
private:
void read_data_definition(const std::string& filename);
Modified: branches/jelte-datadef/src/bin/parkinglot/main.cc
==============================================================================
--- branches/jelte-datadef/src/bin/parkinglot/main.cc (original)
+++ branches/jelte-datadef/src/bin/parkinglot/main.cc Fri Dec 4 09:23:37 2009
@@ -31,6 +31,7 @@
#include <dns/message.h>
#include <cc/cpp/session.h>
+#include <cc/cpp/data.h>
#include "zoneset.h"
#include "parkinglot.h"
@@ -100,7 +101,7 @@
}
if (FD_ISSET(ss, &fds)) {
- pair<string,string> cmd = cs.getCommand(counter);
+ pair<string, ISC::Data::ElementPtr> cmd = cs.getCommand(counter);
plot.command(cmd);
}
}
Modified: branches/jelte-datadef/src/bin/parkinglot/parkinglot.cc
==============================================================================
--- branches/jelte-datadef/src/bin/parkinglot/parkinglot.cc (original)
+++ branches/jelte-datadef/src/bin/parkinglot/parkinglot.cc Fri Dec 4 09:23:37 2009
@@ -28,14 +28,19 @@
#include <dns/rrset.h>
#include <dns/message.h>
+#include <cc/cpp/data.h>
+
#include "common.h"
#include "parkinglot.h"
+
+#include <boost/foreach.hpp>
using namespace std;
using namespace isc::dns;
using namespace isc::dns::Rdata::IN;
using namespace isc::dns::Rdata::Generic;
+using namespace ISC::Data;
ParkingLot::ParkingLot(int port) {
ns1 = Rdata::RdataPtr(new NS("ns1.parking.example"));
@@ -184,13 +189,23 @@
}
void
-ParkingLot::command(pair<string,string> cmd) {
+ParkingLot::command(pair<string,ElementPtr> cmd) {
if (cmd.first == "addzone")
- serve(cmd.second);
+ serve(cmd.second->string_value());
else if (cmd.first == "delzone")
- zones.forget(cmd.second);
+ zones.forget(cmd.second->string_value());
else if (cmd.first == "shutdown")
exit(0);
+ else if (cmd.first == "config_update") {
+ // what to do with port settings?
+ ElementPtr zonelist_el = (cmd.second)->get("zones");
+ // We could walk through both lists and remove and serve
+ // accordingly, or simply clear all and add everything
+ zones.clear_zones();
+ BOOST_FOREACH(ElementPtr zone, zonelist_el->list_value()) {
+ zones.serve(zone->string_value());
+ }
+ }
}
void
Modified: branches/jelte-datadef/src/bin/parkinglot/parkinglot.h
==============================================================================
--- branches/jelte-datadef/src/bin/parkinglot/parkinglot.h (original)
+++ branches/jelte-datadef/src/bin/parkinglot/parkinglot.h Fri Dec 4 09:23:37 2009
@@ -18,6 +18,7 @@
#define __PARKINGLOT_H 1
#include "zoneset.h"
+#include <cc/cpp/data.h>
class ParkingLot {
public:
@@ -25,7 +26,7 @@
virtual ~ParkingLot() {}
int getSocket() { return (sock); }
void processMessage();
- void command(std::pair<std::string,std::string>);
+ void command(std::pair<std::string,ISC::Data::ElementPtr>);
void serve(std::string zone_name);
private:
Modified: branches/jelte-datadef/src/bin/parkinglot/zoneset.h
==============================================================================
--- branches/jelte-datadef/src/bin/parkinglot/zoneset.h (original)
+++ branches/jelte-datadef/src/bin/parkinglot/zoneset.h Fri Dec 4 09:23:37 2009
@@ -29,6 +29,9 @@
std::cout << "no longer serving: " << s << std::endl;
this->erase(s);
}
+ void clear_zones() {
+ this->clear();
+ }
bool contains(std::string s) {
return (this->find(s) != this->end());
}
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 Fri Dec 4 09:23:37 2009
@@ -86,7 +86,7 @@
cmd = msg["command"]
try:
if cmd[0] == "get_commands":
- answer["result"] = self.commands
+ answer["result"] = [ 0, self.commands ]
elif cmd[0] == "get_data_spec":
if len(cmd) > 1 and cmd[1] != "":
try:
@@ -107,10 +107,6 @@
conf_part = self.config.data
answer["result"] = [ 0, conf_part ]
elif cmd[0] == "set_config":
- print("[XX] cmd len: " + str(len(cmd)))
- print("[XX] cmd 0: " + str(cmd[0]))
- print("[XX] cmd 1: " + str(cmd[1]))
- print("[XX] cmd 2: " + str(cmd[2]))
if len(cmd) == 3:
# todo: use api (and check types?)
if cmd[1] != "":
@@ -121,10 +117,16 @@
conf_part = self.config.data
conf_part.update(cmd[2])
# send out changed info
+ print("[XX][bind-cfgd] send update of part: " + cmd[1])
+ self.cc.group_sendmsg({ "config_update": conf_part }, cmd[1])
answer["result"] = [ 0 ]
elif len(cmd) == 2:
self.config.data.update(cmd[1])
# send out changed info
+ print("[XX][bind-cfgd] send update of all")
+ for module in self.config.data:
+ print("[XX][bind-cfgd] send update of part: " + module)
+ self.cc.group_sendmsg({ "config_update": self.config.data[module] }, module)
answer["result"] = [ 0 ]
else:
answer["result"] = [ 1, "Wrong number of arguments" ]
@@ -145,6 +147,7 @@
except IndexError as ie:
print("missing argument")
answer["result"] = [ 1, "Missing argument in command: " + str(ie) ]
+ raise ie
elif "data_specification" in msg:
# todo: validate? (no direct access to spec as
spec = msg["data_specification"]
Modified: branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py
==============================================================================
--- branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py (original)
+++ branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py Fri Dec 4 09:23:37 2009
@@ -187,7 +187,10 @@
"""Sends the changes configuration values to the config manager.
If the command succeeds, the changes are re-requested and
the changed list is reset"""
- cc.group_sendmsg({ "command": [ "set_config", self.module_name, self.config_changes ]}, "ConfigManager")
+ if self.module_name and self.module_name != "":
+ cc.group_sendmsg({ "command": [ "set_config", self.module_name, self.config_changes ]}, "ConfigManager")
+ else:
+ cc.group_sendmsg({ "command": [ "set_config", self.config_changes ]}, "ConfigManager")
answer, env = cc.group_recvmsg(False)
if 'result' in answer and type(answer['result']) == list:
# TODO: with the new cc implementation, replace "0" by 0
More information about the bind10-changes
mailing list