Browse Source

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
Jelte Jansen 15 years ago
parent
commit
9e8f14a28b

+ 1 - 1
src/bin/bigtool/run_bigtool.py

@@ -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"],

+ 2 - 1
src/bin/bind10/bind10.py

@@ -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

+ 14 - 0
src/bin/parkinglot/ccsession.cc

@@ -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());

+ 3 - 11
src/bin/parkinglot/parkinglot.spec

@@ -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": ""

+ 6 - 2
src/lib/bigtool/bigtool.py

@@ -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):
 
 
 
+