|
@@ -16,25 +16,77 @@
|
|
|
# This file provides a built-in set of 'execute' commands, for common
|
|
|
# functions, such as adding an initial auth server
|
|
|
# These sets must have an associated CommandInfo defined in
|
|
|
-# bindctl_main.py.in, in prepare_execute_commands
|
|
|
-
|
|
|
-init_auth_server = [
|
|
|
-'!echo adding Authoritative server component',
|
|
|
-'config add /Boss/components b10-auth',
|
|
|
-'config set /Boss/components/b10-auth/kind needed',
|
|
|
-'config set /Boss/components/b10-auth/special auth',
|
|
|
-'!echo adding Xfrin component',
|
|
|
-'config add /Boss/components b10-xfrin',
|
|
|
-'config set /Boss/components/b10-xfrin/address Xfrin',
|
|
|
-'config set /Boss/components/b10-xfrin/kind dispensable',
|
|
|
-'!echo adding Xfrout component',
|
|
|
-'config add /Boss/components b10-xfrout',
|
|
|
-'config set /Boss/components/b10-xfrout/address Xfrout',
|
|
|
-'config set /Boss/components/b10-xfrout/kind dispensable',
|
|
|
-'!echo adding Zone Manager component',
|
|
|
-'config add /Boss/components b10-zonemgr',
|
|
|
-'config set /Boss/components/b10-zonemgr/address Zonemgr',
|
|
|
-'config set /Boss/components/b10-zonemgr/kind dispensable',
|
|
|
-'!echo Components added. Please enter "config commit" to finalize initial'+
|
|
|
-' setup and run the components.'
|
|
|
-]
|
|
|
+# bindctl_main.py.in, in prepare_execute_commands, and
|
|
|
+# a handler in
|
|
|
+
|
|
|
+from bindctl.moduleinfo import *
|
|
|
+# The name of the 'virtual' command set execution module in bindctl
|
|
|
+EXECUTE_MODULE_NAME = 'execute'
|
|
|
+
|
|
|
+# This is a map of command names to lists
|
|
|
+command_sets = {
|
|
|
+ 'init_authoritative_server': {
|
|
|
+ 'description':
|
|
|
+ 'Configure and run a basic Authoritative server, with default '+
|
|
|
+ 'SQLite3 backend, and xfrin and xfrout functionality',
|
|
|
+ 'commands':
|
|
|
+ [
|
|
|
+ '!echo adding Authoritative server component',
|
|
|
+ 'config add /Boss/components b10-auth',
|
|
|
+ 'config set /Boss/components/b10-auth/kind needed',
|
|
|
+ 'config set /Boss/components/b10-auth/special auth',
|
|
|
+ '!echo adding Xfrin component',
|
|
|
+ 'config add /Boss/components b10-xfrin',
|
|
|
+ 'config set /Boss/components/b10-xfrin/address Xfrin',
|
|
|
+ 'config set /Boss/components/b10-xfrin/kind dispensable',
|
|
|
+ '!echo adding Xfrout component',
|
|
|
+ 'config add /Boss/components b10-xfrout',
|
|
|
+ 'config set /Boss/components/b10-xfrout/address Xfrout',
|
|
|
+ 'config set /Boss/components/b10-xfrout/kind dispensable',
|
|
|
+ '!echo adding Zone Manager component',
|
|
|
+ 'config add /Boss/components b10-zonemgr',
|
|
|
+ 'config set /Boss/components/b10-zonemgr/address Zonemgr',
|
|
|
+ 'config set /Boss/components/b10-zonemgr/kind dispensable',
|
|
|
+ '!echo Components added. Please enter "config commit" to finalize'+
|
|
|
+ 'initial setup and run the components.'
|
|
|
+ ]
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+def has_command_set(name):
|
|
|
+ return name in command_sets
|
|
|
+
|
|
|
+def get_commands(name):
|
|
|
+ return command_sets[name]['commands']
|
|
|
+
|
|
|
+def get_description(name):
|
|
|
+ return command_sets[name]['description']
|
|
|
+
|
|
|
+# For each
|
|
|
+def prepare_execute_commands(tool):
|
|
|
+ """This function is called by bindctl_main, and sets up the commands
|
|
|
+ defined here for use in bindctl."""
|
|
|
+ # common parameter
|
|
|
+ param_show = ParamInfo(name="show", type="string", optional=True,
|
|
|
+ desc="Show the list of commands without executing them")
|
|
|
+
|
|
|
+ # The command module
|
|
|
+ module = ModuleInfo(name=EXECUTE_MODULE_NAME,
|
|
|
+ desc="Execute a given set of commands")
|
|
|
+
|
|
|
+ # Command to execute a file
|
|
|
+ cmd = CommandInfo(name="file", desc="Read commands from file")
|
|
|
+ param = ParamInfo(name="filename", type="string", optional=False,
|
|
|
+ desc="File to read the set of commands from.")
|
|
|
+ cmd.add_param(param)
|
|
|
+ cmd.add_param(param_show)
|
|
|
+ module.add_command(cmd)
|
|
|
+
|
|
|
+ # and loop through all command sets defined above
|
|
|
+ for name in command_sets:
|
|
|
+ cmd = CommandInfo(name=name, desc=get_description(name))
|
|
|
+ cmd.add_param(param_show)
|
|
|
+ module.add_command(cmd)
|
|
|
+
|
|
|
+ tool.add_module_info(module)
|
|
|
+
|