Commit 9e8f14a2 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

example direct module command, these do not go through the config manager but directly to modules


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-datadef@348 e5f2f494-b856-4b98-b285-d166d9295462
parent 171781db
......@@ -33,7 +33,7 @@ def prepare_module_commands(bigtool, module_name, module_commands):
desc = "same here")
for command in module_commands:
cmd = CommandInfo(name = command["command_name"],
desc = "todo2",
desc = command["command_description"],
need_inst_param = False)
for arg in command["command_args"]:
param = ParamInfo(name = arg["item_name"],
......
......@@ -100,7 +100,8 @@ class BoB:
self.c_channel_port)
c_channel_env = { "ISC_MSGQ_PORT": str(self.c_channel_port), }
try:
c_channel = ProcessInfo("msgq", "msgq", c_channel_env, True)
#c_channel = ProcessInfo("msgq", "msgq", c_channel_env, True)
c_channel = ProcessInfo("msgq", "msgq", c_channel_env)
except Exception as e:
return "Unable to start msgq; " + str(e)
self.processes[c_channel.pid] = c_channel
......
......@@ -131,10 +131,24 @@ CommandSession::getCommand(int counter) {
if (cmd != NULL) {
return std::pair<string, ElementPtr>("delzone", cmd);
}
// todo: common interface for config updates?
cmd = data->get("config_update");
if (cmd != NULL) {
return std::pair<string, ElementPtr>("config_update", cmd);
}
// todo: common interface for command handling
cmd = data->get("command");
// the format is defined partly by convention;
// { "command": [ "module", "command", args... ]
// args is defined in the .spec file
// we could do checking here as well if we want
if (cmd != NULL && cmd->get(1)->string_value() == "print_message") {
cout << "[parkinglot] " << cmd->get(2)->string_value() << endl;
ElementPtr answer = Element::create_from_string("{ \"result\": [0] }");
cout << "[XX] sending reply: " << answer << endl;
session_.reply(routing, answer);
cout << "[XX] reply sent" << endl;
}
}
return std::pair<string, ElementPtr>("unknown", ElementPtr());
......
......@@ -23,18 +23,10 @@
],
"commands": [
{
"command_name": "zone_add",
"command_name": "print_message",
"command_description": "Print the given message to stdout",
"command_args": [ {
"item_name": "zone_name",
"item_type": "string",
"item_optional": False,
"item_default": ""
} ]
},
{
"command_name": "zone_delete",
"command_args": [ {
"item_name": "zone_name",
"item_name": "message",
"item_type": "string",
"item_optional": False,
"item_default": ""
......
......@@ -315,7 +315,7 @@ class BigTool(Cmd):
if not self.cc:
return
groupName = (cmd.module == 'boss') and 'Boss' or 'ConfigManager'
groupName = cmd.module
content = [cmd.module, cmd.command]
values = cmd.params.values()
if len(values) > 0:
......@@ -323,9 +323,12 @@ class BigTool(Cmd):
msg = {"command":content}
print("begin to send the message...")
# XXTODO: remove this with new msgq
self.cc.group_subscribe(groupName)
try:
self.cc.group_sendmsg(msg, groupName, instance = 'boss')
self.cc.group_sendmsg(msg, groupName)
print("waiting for %s reply..." % groupName)
reply, env = self.cc.group_recvmsg(False)
......@@ -335,3 +338,4 @@ class BigTool(Cmd):
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