[svn] commit: r352 - in /branches/jelte-datadef/src: bin/bigtool/run_bigtool.py lib/bigtool/bigtool.py lib/bind-cfgd/python/bind-cfgd.py lib/cc/python/ISC/CC/data.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Dec 4 16:34:56 UTC 2009
Author: jelte
Date: Fri Dec 4 16:34:56 2009
New Revision: 352
Log:
move prepare_module_commands to bigtool class
bigtool now listens to 'specification_update' and 'commands_update' commands for data_spec and module commands of modules that were not running yet at the time bigtool was started. no command for removal yet
Modified:
branches/jelte-datadef/src/bin/bigtool/run_bigtool.py
branches/jelte-datadef/src/lib/bigtool/bigtool.py
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 16:34:56 2009
@@ -13,26 +13,9 @@
bigtool.add_module_info(boss_module)
-def prepare_module_commands(bigtool, module_name, module_commands):
- module = ModuleInfo(name = module_name,
- desc = "same here")
- for command in module_commands:
- cmd = CommandInfo(name = command["command_name"],
- desc = command["command_description"],
- need_inst_param = False)
- for arg in command["command_args"]:
- param = ParamInfo(name = arg["item_name"],
- type = arg["item_type"],
- optional = bool(arg["item_optional"]))
- if ("item_default" in arg):
- param.default = arg["item_default"]
- cmd.add_param(param)
- module.add_command(cmd)
- bigtool.add_module_info(module)
-
def prepare_commands(bigtool, command_spec):
for module_name in command_spec.keys():
- prepare_module_commands(bigtool, module_name, command_spec[module_name])
+ bigtool.prepare_module_commands(module_name, command_spec[module_name])
def prepare_config_commands(bigtool):
module = ModuleInfo(name = "config", desc = "Configuration commands")
@@ -84,7 +67,7 @@
if __name__ == '__main__':
try:
cc = ISC.CC.Session()
- cc.group_subscribe("BigTool", "*", "meonly")
+ cc.group_subscribe("BigTool", "*")
cc.group_subscribe("ConfigManager", "*", "meonly")
cc.group_subscribe("Boss", "*", "meonly")
Modified: branches/jelte-datadef/src/lib/bigtool/bigtool.py
==============================================================================
--- branches/jelte-datadef/src/lib/bigtool/bigtool.py (original)
+++ branches/jelte-datadef/src/lib/bigtool/bigtool.py Fri Dec 4 16:34:56 2009
@@ -2,8 +2,7 @@
import readline
from cmd import Cmd
from exception import *
-from moduleinfo import ModuleInfo
-from moduleinfo import ParamInfo
+from moduleinfo import *
from command import BigToolCmd
from xml.dom import minidom
import ISC
@@ -130,6 +129,8 @@
def onecmd(self, line):
+ # check if there's anything on the cc first
+ self.check_cc_messages()
if line == 'EOF' or line.lower() == "quit":
return True
@@ -218,8 +219,35 @@
return []
+ def prepare_module_commands(self, module_name, module_commands):
+ module = ModuleInfo(name = module_name,
+ desc = "same here")
+ for command in module_commands:
+ cmd = CommandInfo(name = command["command_name"],
+ desc = command["command_description"],
+ need_inst_param = False)
+ for arg in command["command_args"]:
+ param = ParamInfo(name = arg["item_name"],
+ type = arg["item_type"],
+ optional = bool(arg["item_optional"]))
+ if ("item_default" in arg):
+ param.default = arg["item_default"]
+ cmd.add_param(param)
+ module.add_command(cmd)
+ self.add_module_info(module)
+
+ def check_cc_messages(self):
+ (message, env) = self.cc.group_recvmsg(True)
+ while message:
+ if 'commands_update' in message:
+ self.prepare_module_commands(message['commands_update'][0], message['commands_update'][1])
+ elif 'specification_update' in message:
+ self.config_data.config.specification[message['specification_update'][0]] = message['specification_update'][1]
+ (message, env) = self.cc.group_recvmsg(True)
def _parse_cmd(self, line):
+ # check if there's anything on the cc first
+ self.check_cc_messages()
try:
cmd = BigToolCmd(line)
self.validate_cmd(cmd)
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 16:34:56 2009
@@ -73,17 +73,6 @@
def remove_commands(self, module_name):
del self.commands[module_name]
-
- def add_zone(self, zone_name):
- self.config.add_zone(zone_name, "todo")
- self.write_config()
- print("sending update zone add")
- self.cc.group_sendmsg({"zone_added": zone_name }, "ParkingLot")
-
- def remove_zone(self, zone_name):
- self.config.remove_zone(zone_name)
- print("sending update zone del")
- self.cc.group_sendmsg({"zone_deleted": zone_name }, "ParkingLot")
def read_config(self):
print("Reading config")
@@ -164,8 +153,11 @@
spec = msg["data_specification"]
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")
answer["result"] = [ 0 ]
else:
print("unknown message: " + str(msg))
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 16:34:56 2009
@@ -163,7 +163,7 @@
class UIConfigData():
def __init__(self, name, cc):
self.module_name = name
- data_spec = self.get_data_specification(cc)
+ data_spec = sel f.get_data_specification(cc)
self.config = ConfigData(data_spec)
self.get_config_data(cc)
self.config_changes = {}
More information about the bind10-changes
mailing list