[svn] commit: r555 - in /branches/parkinglot/src/lib/config/python: bind-cfgd.py isc/__init__.py isc/config/CCSession.py isc/config/DataDefinition.py isc/config/__init__.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jan 27 01:27:34 UTC 2010
Author: jelte
Date: Wed Jan 27 01:27:34 2010
New Revision: 555
Log:
more python client side API stuff for configuration
Added:
branches/parkinglot/src/lib/config/python/isc/config/DataDefinition.py
Modified:
branches/parkinglot/src/lib/config/python/bind-cfgd.py
branches/parkinglot/src/lib/config/python/isc/__init__.py
branches/parkinglot/src/lib/config/python/isc/config/CCSession.py
branches/parkinglot/src/lib/config/python/isc/config/__init__.py
Modified: branches/parkinglot/src/lib/config/python/bind-cfgd.py
==============================================================================
--- branches/parkinglot/src/lib/config/python/bind-cfgd.py (original)
+++ branches/parkinglot/src/lib/config/python/bind-cfgd.py Wed Jan 27 01:27:34 2010
@@ -104,6 +104,8 @@
elif cmd[0] == "get_config":
# we may not have any configuration here
conf_part = None
+ print("[XX] bind-cfgd got command:")
+ print(cmd)
if len(cmd) > 1:
try:
conf_part = data.find(self.config.data, cmd[1]['module_name'])
Modified: branches/parkinglot/src/lib/config/python/isc/__init__.py
==============================================================================
--- branches/parkinglot/src/lib/config/python/isc/__init__.py (original)
+++ branches/parkinglot/src/lib/config/python/isc/__init__.py Wed Jan 27 01:27:34 2010
@@ -1,0 +1,1 @@
+import isc.config
Modified: branches/parkinglot/src/lib/config/python/isc/config/CCSession.py
==============================================================================
--- branches/parkinglot/src/lib/config/python/isc/config/CCSession.py (original)
+++ branches/parkinglot/src/lib/config/python/isc/config/CCSession.py Wed Jan 27 01:27:34 2010
@@ -23,16 +23,42 @@
# made there as well
from ISC.CC import Session
+import isc
class CCSession:
- def __init__(self, module_name, spec_file_name):
+ def __init__(self, module_name, spec_file_name,
+ config_handler, command_handler):
self._module_name = module_name
- self._spec_file_name = spec_file_name
+ #self._spec_file_name = spec_file_name
+ self._config_handler = config_handler
+ self._command_handler = command_handler
+ self._data_definition = isc.config.DataDefinition(spec_file_name)
self._session = Session()
+ self._session.group_subscribe(module_name, "*")
+ self._session.group_sendmsg(self._data_definition.getDefinition(), "ConfigManager")
+ answer, env = self._session.group_recvmsg(False)
+ self._session.group_sendmsg({ "command": [ "get_config", { "module_name": module_name } ] }, "ConfigManager")
+ answer, env = self._session.group_recvmsg(False)
+ if self._config_handler:
+ self._config_handler(answer["result"])
+ print(answer)
+
#do we need getSocket()?
- def check_command():
- pass
+ def checkCommand():
+ """Check whether there is a command on the channel.
+ Call the command callback function if so"""
+ msg, env = self._session.group_recvmsg(False)
+ answer = None
+ if msg:
+ if "config_update" in msg and self._config_handler:
+ self._config_handler(msg["config_update"])
+ answer = { "result": [ 0 ] }
+ if "command" in msg and self._command_handler:
+ answer = self._command_handler(msg["command"])
+ if answer:
+ self._session.group_reply(env, answer)
+
Modified: branches/parkinglot/src/lib/config/python/isc/config/__init__.py
==============================================================================
--- branches/parkinglot/src/lib/config/python/isc/config/__init__.py (original)
+++ branches/parkinglot/src/lib/config/python/isc/config/__init__.py Wed Jan 27 01:27:34 2010
@@ -1,0 +1,2 @@
+from isc.config.CCSession import *
+from isc.config.DataDefinition import *
More information about the bind10-changes
mailing list