[svn] commit: r948 - /trunk/src/lib/config/python/isc/config/ccsession.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Feb 24 14:44:51 UTC 2010
Author: jelte
Date: Wed Feb 24 14:44:51 2010
New Revision: 948
Log:
function to create and 'parse' ccsession commands, and a list of fixed (non-module) command names
Modified:
trunk/src/lib/config/python/isc/config/ccsession.py
Modified: trunk/src/lib/config/python/isc/config/ccsession.py
==============================================================================
--- trunk/src/lib/config/python/isc/config/ccsession.py (original)
+++ trunk/src/lib/config/python/isc/config/ccsession.py Wed Feb 24 14:44:51 2010
@@ -73,6 +73,37 @@
return { 'result': [ rcode, arg ] }
else:
return { 'result': [ rcode ] }
+
+# 'fixed' commands
+"""Fixed names for command and configuration messages"""
+COMMAND_COMMANDS_UPDATE = "commands_update"
+COMMAND_SPECIFICATION_UPDATE = "specification_update"
+
+COMMAND_GET_COMMANDS_SPEC = "get_commands_spec"
+COMMAND_GET_CONFIG = "get_config"
+COMMAND_SET_CONFIG = "set_config"
+COMMAND_GET_MODULE_SPEC = "get_module_spec"
+
+def parse_command(msg):
+ """Parses what may be a command message. If it looks like one,
+ the function returns (command, value) where command is a
+ string. If it is not, this function returns None, None"""
+ if type(msg) == dict and len(msg.items()) == 1:
+ cmd, value = msg.popitem()
+ if type(cmd) == str:
+ return cmd, value
+ return None, None
+
+def create_command(command_name, params = None):
+ """Creates a module command message with the given command name (as
+ specified in the module's specification, and an optional params
+ object"""
+ # TODO: validate_command with spec
+ cmd = [ command_name ]
+ if params:
+ cmd.append(params)
+ msg = { 'command': cmd }
+ return msg
class ModuleCCSession(ConfigData):
"""This class maintains a connection to the command channel, as
More information about the bind10-changes
mailing list