Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
233c7295
Commit
233c7295
authored
Apr 18, 2012
by
Jelte Jansen
Browse files
[1843] initial addition of 'execute' command set
parent
f93cd951
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/bindctl/bindcmd.py
View file @
233c7295
...
...
@@ -62,6 +62,7 @@ except ImportError:
CSV_FILE_NAME
=
'default_user.csv'
CONFIG_MODULE_NAME
=
'config'
EXECUTE_MODULE_NAME
=
'execute'
CONST_BINDCTL_HELP
=
"""
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
try
:
...
...
@@ -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
self
.
apply_execute_cmd
(
cmd
)
else
:
self
.
apply_cmd
(
cmd
)
...
...
@@ -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>'.'''
pass
def
apply_cmd
(
self
,
cmd
):
'''Handles a general module command'''
url
=
'/'
+
cmd
.
module
+
'/'
+
cmd
.
command
...
...
src/bin/bindctl/bindctl_main.py.in
View file @
233c7295
...
...
@@ -103,6 +103,15 @@ def prepare_config_commands(tool):
tool.add_module_info(module)
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.")
cmd.add_param(param)
module.add_command(cmd)
tool.add_module_info(module)
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)
...
...
tests/lettuce/features/bindctl_commands.feature
View file @
233c7295
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment