[svn] commit: r566 - /branches/parkinglot/src/lib/config/python/isc/config/CCSession.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jan 27 19:11:20 UTC 2010
Author: jelte
Date: Wed Jan 27 19:11:19 2010
New Revision: 566
Log:
documentation and cleanup of CCSession.py
Modified:
branches/parkinglot/src/lib/config/python/isc/config/CCSession.py
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 19:11:19 2010
@@ -30,18 +30,16 @@
config_handler, command_handler):
self._module_name = module_name
#self._spec_file_name = spec_file_name
- self._config_handler = config_handler
- self._command_handler = command_handler
+ self.setConfigHandler(config_handler)
+ self.setCommandHandler(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)
+
+ self.__sendSpec()
+ self.__getFullConfig()
#do we need getSocket()?
@@ -60,5 +58,30 @@
self._session.group_reply(env, answer)
+ def setConfigHandler(self, config_handler):
+ """Set the config handler for this module. The handler is a
+ function that takes the full configuration and handles it.
+ It should return either { "result": [ 0 ] } or
+ { "result": [ <error_number>, "error message" ] }"""
+ self._config_handler = config_handler
+ # should we run this right now since we've changed the handler?
+
+ def setCommandHandler(self, command_handler):
+ """Set the command handler for this module. The handler is a
+ function that takes a command as defined in the .spec file
+ and return either { "result": [ 0, (result) ] } or
+ { "result": [ <error_number>. "error message" ] }"""
+ self._command_handler = command_handler
+
+ def __sendSpec(self):
+ """Sends the data specification to the configuration manager"""
+ self._session.group_sendmsg(self._data_definition.getDefinition(), "ConfigManager")
+ answer, env = self._session.group_recvmsg(False)
+
+ def __getFullConfig(self):
+ """Asks the configuration manager for the current configuration, and call the config handler if set"""
+ self._session.group_sendmsg({ "command": [ "get_config", { "module_name": self._module_name } ] }, "ConfigManager")
+ answer, env = self._session.group_recvmsg(False)
+ if self._config_handler:
+ self._config_handler(answer["result"])
-
More information about the bind10-changes
mailing list