Commit 233c7295 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[1843] initial addition of 'execute' command set

parent f93cd951
......@@ -62,6 +62,7 @@ except ImportError:
CSV_FILE_NAME = 'default_user.csv'
usage: <module name> <command name> [param1 = value1 [, param2 = value2]]
Type Tab character to get the hint of module/command/parameters.
......@@ -393,8 +394,9 @@ class BindCmdInterpreter(Cmd):
param_nr += 1
# Convert parameter value according parameter spec file.
# Ignore check for commands belongs to module 'config'
if cmd.module != CONFIG_MODULE_NAME:
# Ignore check for commands belongs to module 'config' or 'execute
if cmd.module != CONFIG_MODULE_NAME and\
cmd.module != EXECUTE_MODULE_NAME:
for param_name in cmd.params:
param_spec = command_info.get_param_with_name(param_name).param_spec
......@@ -418,6 +420,9 @@ class BindCmdInterpreter(Cmd):
print("Error: " + str(dape))
except KeyError as ke:
print("Error: missing " + str(ke))
elif cmd.module == EXECUTE_MODULE_NAME:
# TODO: catch errors
......@@ -728,6 +733,12 @@ class BindCmdInterpreter(Cmd):
self.location = new_location
def apply_execute_cmd(self, command):
'''Handles the 'execute' command, which executes a number of
(preset) statements. Currently only 'file' commands are supported,
e.g. 'execute file <file>'.'''
def apply_cmd(self, cmd):
'''Handles a general module command'''
url = '/' + cmd.module + '/' + cmd.command
......@@ -103,6 +103,15 @@ def prepare_config_commands(tool):
module = ModuleInfo(name=EXECUTE_MODULE_NAME,
desc="Execute a given set of commands")
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.")
def check_port(option, opt_str, value, parser):
if (value < 0) or (value > 65535):
raise OptionValueError('%s requires a port number (0-65535)' % opt_str)
......@@ -63,3 +63,12 @@ Feature: control with bindctl
bind10 module StatsHttpd should not be running
bind10 module Stats should not be running
bind10 module Resolver should not be running
Scenario: Executing scripts
# This test tests the 'execute' command, which reads and executes
# bindctl commands from a file
Given I have bind10 running with configuration bindctl_commands.config
And wait for bind10 stderr message BIND10_STARTED_CC
And wait for bind10 stderr message CMDCTL_STARTED
When I send bind10 the command execute file data/commands/empty
last bindctl output should not contain Error
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment