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
Sebastian Schrader
Kea
Commits
357a7ea3
Commit
357a7ea3
authored
Mar 08, 2017
by
Tomek Mrugalski
🛰
Browse files
[5137] version is now reported properly.
parent
ca2ff7fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/shell/Makefile.am
View file @
357a7ea3
...
...
@@ -40,7 +40,9 @@ endif
# this is done here since configure.ac AC_OUTPUT doesn't expand exec_prefix
kea-shell
:
kea-shell.py
$(SED)
"s|@@PYTHONPATH@@|@pyexecdir@|"
kea-shell.py
>
$@
rm
-f
kea-shell.tmp
$(SED)
"s|@@PYTHONPATH@@|@pyexecdir@|"
kea-shell.py
>
kea-shell.tmp
$(SED)
"s|REPORTED_VERSION|@PACKAGE_VERSION@|"
kea-shell.tmp
>
$@
chmod
a+x
$@
install-data-local
:
...
...
src/bin/shell/kea-shell.py
View file @
357a7ea3
#!/usr/bin/python
# This is going to be replaced with the actual version (see kea-shell target
# in Makefile.am)
VERSION
=
"REPORTED_VERSION"
# First, let's import the right kea_connector.
# We have two versions: one for python 2.x and another for python 3.x.
# Sadly, there's no unified way to handle http connections. The recommended
...
...
@@ -29,22 +33,27 @@ from kea_conn import CARequest, CAResponse
# the help and sanity checking input parameters.
parser
=
argparse
.
ArgumentParser
(
description
=
'Connects to Kea Control Agent.'
)
parser
.
add_argument
(
'--host'
,
type
=
str
,
nargs
=
1
,
default
=
'127.0.0.1'
,
parser
.
add_argument
(
'--host'
,
type
=
str
,
default
=
'127.0.0.1'
,
help
=
'hostname of the CA to connect to'
)
parser
.
add_argument
(
'--port'
,
type
=
int
,
nargs
=
1
,
default
=
8000
,
parser
.
add_argument
(
'--port'
,
type
=
int
,
default
=
8000
,
help
=
'TCP port of the CA to connect to'
)
parser
.
add_argument
(
'--timeout'
,
type
=
int
,
nargs
=
1
,
default
=
'10'
,
parser
.
add_argument
(
'--timeout'
,
type
=
int
,
default
=
'10'
,
help
=
'Timeout (in seconds) when attempting to connect to CA'
)
parser
.
add_argument
(
'command'
,
type
=
str
,
nargs
=
"?"
,
default
=
'list-commands'
,
help
=
'command to be executed. If not specified, "list-commands" is used'
)
parser
.
add_argument
(
'-v'
,
action
=
"store_true"
,
help
=
"Prints version"
)
cmd_args
=
parser
.
parse_args
()
if
(
cmd_args
.
v
):
print
(
VERSION
)
exit
(
0
)
# Ok, now time to put the parameters parsed into the structure to be used by the
# connection.
params
=
CARequest
()
params
.
command
=
cmd_args
.
command
params
.
http_host
=
cmd_args
.
host
[
0
]
params
.
http_port
=
cmd_args
.
port
[
0
]
params
.
http_host
=
cmd_args
.
host
params
.
http_port
=
cmd_args
.
port
params
.
timeout
=
cmd_args
.
timeout
params
.
generateBody
()
...
...
src/bin/shell/tests/shell_process_tests.sh.in
View file @
357a7ea3
...
...
@@ -35,6 +35,9 @@ CONFIG="{
}
}"
# In these tests we need to use two binaries: Control Agent and Kea shell.
# Using bin and bin_path would be confusing, so we omit defining bin and bin_path
# on purpose.
ca_bin="kea-ctrl-agent"
ca_bin_path=@abs_top_builddir@/src/bin/agent
...
...
@@ -146,7 +149,30 @@ shell_command_test() {
test_finish 0
}
shell_command_test "shell.list-commands" "list-commands" "[ { \"arguments\": [ \"list-commands\" ], \"result\": 0 } ]" ""
shell_command_test "shell.bogus" "give-me-a-beer" "[ { \"result\": 1, \"text\": \"'give-me-a-beer' command not supported.\" } ]" ""
# This test verifies that the binary is reporting its version properly.
version_test() {
test_name=${1} # Test name
# Log the start of the test and print test name.
test_start ${test_name}
# Remove dangling Kea instances and remove log files.
cleanup
REPORTED_VERSION="`${shell_bin_path}/${shell_bin} -v`"
if test "${REPORTED_VERSION}" == "${EXPECTED_VERSION}"; then
test_finish 0
else
printf "ERROR: Expected version ${EXPECTED_VERSION}, got ${REPORTED_VERSION}\n"
test_finish 1
fi
}
version_test "shell.version"
shell_command_test "shell.list-commands" "list-commands" \
"[ { \"arguments\": [ \"list-commands\" ], \"result\": 0 } ]" ""
shell_command_test "shell.bogus" "give-me-a-beer" \
"[ { \"result\": 1, \"text\": \"'give-me-a-beer' command not supported.\" } ]" ""
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