[svn] commit: r213 - in /branches/f2f200910/src: bin/bigtool/run_bigtool bin/bigtool/run_bigtool.py lib/bigtool/bigtool.py lib/bigtool/run_unittest
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Oct 30 00:45:09 UTC 2009
Author: zhanglikun
Date: Fri Oct 30 00:45:09 2009
New Revision: 213
Log:
1. Remove some unused path for BigTool.
2. Fix bug: can't parse the commands which don't have paramters correctly.
Modified:
branches/f2f200910/src/bin/bigtool/run_bigtool
branches/f2f200910/src/bin/bigtool/run_bigtool.py
branches/f2f200910/src/lib/bigtool/bigtool.py
branches/f2f200910/src/lib/bigtool/run_unittest
Modified: branches/f2f200910/src/bin/bigtool/run_bigtool
==============================================================================
--- branches/f2f200910/src/bin/bigtool/run_bigtool (original)
+++ branches/f2f200910/src/bin/bigtool/run_bigtool Fri Oct 30 00:45:09 2009
@@ -1,9 +1,9 @@
#! /bin/sh
-PYTHON_EXEC=/usr/bin/python3
+PYTHON_EXEC=python3
BIGTOOL_PATH=.
-PYTHONPATH=../../lib/cc/python:../../lib/cc/python/ISC:../../lib/cc/python/ISC/CC:../../lib/cc/python/ISC/Util:../../lib/bigtool/
+PYTHONPATH=../../lib/cc/python:../../lib/bigtool/
export PYTHONPATH
cd ${BIGTOOL_PATH}
Modified: branches/f2f200910/src/bin/bigtool/run_bigtool.py
==============================================================================
--- branches/f2f200910/src/bin/bigtool/run_bigtool.py (original)
+++ branches/f2f200910/src/bin/bigtool/run_bigtool.py Fri Oct 30 00:45:09 2009
@@ -1,26 +1,43 @@
from moduleinfo import *
from bigtool import *
+import ISC
def _prepare_fake_data(bigtool):
add_cmd = CommandInfo(name = "add", desc = "add one zone")
remove_cmd = CommandInfo(name = 'remove', desc = 'remove one zone')
- list_cmd = CommandInfo(name = 'list', desc = 'list all zones', need_inst_param = False)
+ list_cmd = CommandInfo(name = 'list', desc = 'list all zones',
+ need_inst_param = False)
zone_module = ModuleInfo(name = "zone",
inst_name = "zone_name",
inst_type = STRING_TYPE,
inst_desc = "the name of one zone",
desc = "manage all the zones")
-
zone_module.add_command(add_cmd)
zone_module.add_command(remove_cmd)
zone_module.add_command(list_cmd)
+
+ shutdown_cmd = CommandInfo(name = 'shutdown', desc = "stop bind10",
+ need_inst_param = False)
+ boss_module = ModuleInfo(name = "boss", desc = "boss of bind10")
+ boss_module.add_command(shutdown_cmd)
+
bigtool.add_module_info(zone_module)
+ bigtool.add_module_info(boss_module)
if __name__ == '__main__':
- tool = BigTool()
- _prepare_fake_data(tool)
- tool.cmdloop()
+ try:
+ cc = ISC.CC.Session()
+ cc.group_subscribe("BigTool")
+ cc.group_subscribe("ConfigManager")
+ tool = BigTool(cc)
+ _prepare_fake_data(tool)
+ tool.cmdloop()
+ except ISC.CC.SessionError:
+ print("Failed to create cchannel session, "
+ "is the command channel daemon running?")
+
+
Modified: branches/f2f200910/src/lib/bigtool/bigtool.py
==============================================================================
--- branches/f2f200910/src/lib/bigtool/bigtool.py (original)
+++ branches/f2f200910/src/lib/bigtool/bigtool.py Fri Oct 30 00:45:09 2009
@@ -27,19 +27,14 @@
class BigTool(Cmd):
"""simple bigtool example."""
- def __init__(self):
+ def __init__(self, session = None):
Cmd.__init__(self)
self.prompt = '> '
self.ruler = '-'
self.modules = OrderedDict()
self.add_module_info(ModuleInfo("help", desc = "Get help for bigtool"))
- try:
- self.cc = ISC.CC.Session()
- self.cc.group_subscribe("BigTool")
- self.cc.group_subscribe("ConfigManager")
- except ISC.CC.SessionError:
- print("Failed to create cchannel session")
- exit()
+ self.cc = session
+
def validate_cmd(self, cmd):
if not cmd.module in self.modules:
@@ -226,15 +221,23 @@
def apply_cmd(self, cmd):
+ if not self.cc:
+ return
+
try:
- msg ={"command": [cmd.module, cmd.command, list(cmd.params.values())[0]]}
- print("begin to send the message...")
+ content = [cmd.module, cmd.command]
+ values = cmd.params.values()
+ if len(values) > 0:
+ content.append(list(values)[0])
+
+ msg = {"command":content}
+ print("begin to send the message...")
- self.cc.group_sendmsg(msg, "ConfigManager")
- print("waiting for configure manager reply...")
-
- reply, env = self.cc.group_recvmsg(False)
- print("received reply:", reply)
+ self.cc.group_sendmsg(msg, "ConfigManager")
+ print("waiting for configure manager reply...")
+
+ reply, env = self.cc.group_recvmsg(False)
+ print("received reply:", reply)
except ISC.CC.SessionError:
print("Error commucation with configure manager")
Modified: branches/f2f200910/src/lib/bigtool/run_unittest
==============================================================================
--- branches/f2f200910/src/lib/bigtool/run_unittest (original)
+++ branches/f2f200910/src/lib/bigtool/run_unittest Fri Oct 30 00:45:09 2009
@@ -1,9 +1,9 @@
#! /bin/sh
-PYTHON_EXEC=/usr/bin/python3
+PYTHON_EXEC=python3
BIGTOOL_PATH=.
-PYTHONPATH=../../lib/cc/python:../../lib/cc/python/ISC:../../lib/cc/python/ISC/CC:../../lib/cc/python/ISC/Util:../../lib/bigtool/
+PYTHONPATH=../../lib/cc/python:../../lib/bigtool/
export PYTHONPATH
cd ${BIGTOOL_PATH}
More information about the bind10-changes
mailing list