summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2024-04-23 18:57:05 +0200
committerAndrei Pavel <andrei@isc.org>2024-04-24 14:23:48 +0200
commit677f8a8f0e4659b3a1ad2e4b1db8e6c0c6b6ee00 (patch)
treec3e4d90051f4a4b567de05f9cce669c2e7bc3a67 /src
parent[#3254] show premium source in extended version (diff)
downloadkea-677f8a8f0e4659b3a1ad2e4b1db8e6c0c6b6ee00.tar.xz
kea-677f8a8f0e4659b3a1ad2e4b1db8e6c0c6b6ee00.zip
[#3254] consistent version output across executables
- replace VERSION with PACKAGE_VERSION in src/bin/admin to avoid overlap with VERSION used in src/share/database. - add -V to kea-admin - add -V to kea-shell - add -V to keactrl - add -V to perfdhcp - removed getVersionAddendum from d2 and added the openssl version to the output of other process versions since it's not only used by d2 - make all -V outputs consistent. Some are showing only core version and are missing premium version which is fine since they are the executables that don't have something to do with premium directly anyway.
Diffstat (limited to 'src')
-rw-r--r--src/bin/admin/kea-admin.in14
-rw-r--r--src/bin/d2/d2_controller.cc9
-rw-r--r--src/bin/d2/d2_controller.h4
-rw-r--r--src/bin/dhcp4/dhcp4_srv.cc2
-rw-r--r--src/bin/dhcp6/dhcp6_srv.cc2
-rw-r--r--src/bin/keactrl/keactrl.in14
-rw-r--r--src/bin/lfc/lfc_controller.cc2
-rw-r--r--src/bin/perfdhcp/command_options.cc19
-rw-r--r--src/bin/perfdhcp/command_options.h5
-rw-r--r--src/bin/shell/kea-shell.in6
-rw-r--r--src/lib/process/cfgrpt/tests/config_report_unittests.cc3
-rw-r--r--src/lib/process/d_controller.cc4
-rw-r--r--src/lib/process/d_controller.h2
-rw-r--r--src/lib/process/tests/d_controller_unittests.cc1
14 files changed, 52 insertions, 35 deletions
diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in
index 12bcd5a39a..283e446c47 100644
--- a/src/bin/admin/kea-admin.in
+++ b/src/bin/admin/kea-admin.in
@@ -32,7 +32,8 @@ exec_prefix="@exec_prefix@"
export exec_prefix
BASENAME=$(basename ${0})
SCRIPTS_DIR_DEFAULT="@datarootdir@/@PACKAGE@/scripts"
-VERSION="@PACKAGE_VERSION@"
+PACKAGE_VERSION="@PACKAGE_VERSION@"
+EXTENDED_VERSION="@EXTENDED_VERSION@"
assume_yes=0
@@ -99,7 +100,7 @@ PARAMETERS: Parameters are optional in general, but may be required
-i or --input to specify the name of file from which leases will be uploaded
-o or --output to specify the name of file to which leases will be dumped
-y or --yes - assume yes on overwriting temporary files
-' "${BASENAME}" "${VERSION}" "${BASENAME}" "${SCRIPTS_DIR_DEFAULT}"
+' "${BASENAME}" "${PACKAGE_VERSION}" "${BASENAME}" "${SCRIPTS_DIR_DEFAULT}"
}
### Logging functions ###
@@ -819,8 +820,13 @@ if test "${command}" = "--help" ; then
fi
# Check if this is a simple question about version.
-if test "${command}" = "-v" || test "${command}" = "--version" ; then
- echo "${VERSION}"
+if test "${command}" = "-v" || test "${command}" = "--version"; then
+ echo "${PACKAGE_VERSION}"
+ exit 0
+fi
+
+if test "${command}" = "-V"; then
+ echo "${EXTENDED_VERSION}"
exit 0
fi
diff --git a/src/bin/d2/d2_controller.cc b/src/bin/d2/d2_controller.cc
index 0d0d816791..448a6ddb20 100644
--- a/src/bin/d2/d2_controller.cc
+++ b/src/bin/d2/d2_controller.cc
@@ -144,14 +144,5 @@ D2Controller::parseFile(const std::string& file_name) {
D2Controller::~D2Controller() {
}
-std::string
-D2Controller::getVersionAddendum() {
- std::stringstream stream;
- // Currently the only dependency D2 adds to base is cryptolink
- stream << isc::cryptolink::CryptoLink::getVersion() << std::endl;
- return (stream.str());
-
-}
-
} // end namespace isc::d2
} // end namespace isc
diff --git a/src/bin/d2/d2_controller.h b/src/bin/d2/d2_controller.h
index 6f61735828..ffd1210e30 100644
--- a/src/bin/d2/d2_controller.h
+++ b/src/bin/d2/d2_controller.h
@@ -53,10 +53,6 @@ public:
/// @note Does not throw.
void deregisterCommands();
-protected:
- /// @brief Returns version info specific to D2
- virtual std::string getVersionAddendum();
-
private:
/// @brief Creates an instance of the DHCP-DDNS specific application
/// process. This method is invoked during the process initialization
diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc
index f504f4cbfc..1a63a305b5 100644
--- a/src/bin/dhcp4/dhcp4_srv.cc
+++ b/src/bin/dhcp4/dhcp4_srv.cc
@@ -4832,7 +4832,7 @@ Dhcpv4Srv::getVersion(bool extended) {
tmp << VERSION;
if (extended) {
- tmp << endl << EXTENDED_VERSION << endl;
+ tmp << " (" << EXTENDED_VERSION << ")" << endl;
tmp << "premium: " << PREMIUM_EXTENDED_VERSION << endl;
tmp << "linked with:" << endl;
tmp << "- " << Logger::getVersion() << endl;
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index bef647b151..fe8e34e63a 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -4653,7 +4653,7 @@ Dhcpv6Srv::getVersion(bool extended) {
tmp << VERSION;
if (extended) {
- tmp << endl << EXTENDED_VERSION << endl;
+ tmp << " (" << EXTENDED_VERSION << ")" << endl;
tmp << "premium: " << PREMIUM_EXTENDED_VERSION << endl;
tmp << "linked with:" << endl;
tmp << "- " << Logger::getVersion() << endl;
diff --git a/src/bin/keactrl/keactrl.in b/src/bin/keactrl/keactrl.in
index 22a3f9af4a..cccfdac303 100644
--- a/src/bin/keactrl/keactrl.in
+++ b/src/bin/keactrl/keactrl.in
@@ -21,7 +21,8 @@
# used.
set -eu
-VERSION="@PACKAGE_VERSION@"
+PACKAGE_VERSION="@PACKAGE_VERSION@"
+EXTENDED_VERSION="@EXTENDED_VERSION@"
# Set the have_netconf flag to know if netconf is available.
if test '@HAVE_NETCONF@' = 'yes'; then
@@ -338,8 +339,13 @@ if [ -z "${command}" ]; then
fi
# Check if this is a simple question about version.
-if test "${command}" = "-v" || test "${command}" = "--version" ; then
- echo "${VERSION}"
+if test "${command}" = "-v" || test "${command}" = "--version"; then
+ echo "${PACKAGE_VERSION}"
+ exit 0
+fi
+
+if test "${command}" = "-V"; then
+ echo "${EXTENDED_VERSION}"
exit 0
fi
@@ -576,7 +582,7 @@ ${args}" 1
exit 0 ;;
version)
- echo "keactrl: ${VERSION}"
+ echo "keactrl: ${PACKAGE_VERSION}"
run_conditional "dhcp4" "print_version kea-dhcp4 ${dhcp4_srv}" 0
run_conditional "dhcp6" "print_version kea-dhcp6 ${dhcp6_srv}" 0
run_conditional "dhcp_ddns" "print_version kea-dhcp-ddns ${dhcp_ddns_srv}" 0
diff --git a/src/bin/lfc/lfc_controller.cc b/src/bin/lfc/lfc_controller.cc
index d73e8baec4..4aa06514b5 100644
--- a/src/bin/lfc/lfc_controller.cc
+++ b/src/bin/lfc/lfc_controller.cc
@@ -329,7 +329,7 @@ LFCController::getVersion(const bool extended) const{
db_version = Memfile_LeaseMgr::getDBVersion(Memfile_LeaseMgr::V6);
}
- version_stream << std::endl << EXTENDED_VERSION;
+ version_stream << " (" << EXTENDED_VERSION << ")";
if (!db_version.empty()) {
db_version = "backend: " + db_version;
version_stream << std::endl << db_version;
diff --git a/src/bin/perfdhcp/command_options.cc b/src/bin/perfdhcp/command_options.cc
index 068065156b..85d58a2d1b 100644
--- a/src/bin/perfdhcp/command_options.cc
+++ b/src/bin/perfdhcp/command_options.cc
@@ -5,6 +5,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <config.h>
+#include <kea_version.h>
#include <perfdhcp/command_options.h>
@@ -207,7 +208,7 @@ CommandOptions::parse(int argc, char** const argv, bool print_cmd_line) {
// Reset values of class members
reset();
- // Informs if program has been run with 'h' or 'v' option.
+ // Informs if program has been run with 'h', 'v' or 'V' option.
bool help_or_version_mode = initialize(argc, argv, print_cmd_line);
if (!help_or_version_mode) {
validate();
@@ -245,7 +246,7 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
// In this section we collect argument values from command line
// they will be tuned and validated elsewhere
while((opt = getopt_long(argc, argv,
- "huv46A:r:t:R:b:n:p:d:D:l:P:a:L:N:M:s:iBc1"
+ "huvV46A:r:t:R:b:n:p:d:D:l:P:a:L:N:M:s:iBc1"
"J:T:X:O:o:E:S:I:x:W:w:e:f:F:g:C:y:Y:",
long_options, &opt_long_index)) != -1) {
stream << " -";
@@ -562,6 +563,10 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) {
version();
return (true);
+ case 'V':
+ extendedVersion();
+ return (true);
+
case 'w':
wrapped_ = nonEmptyString("command for wrapped mode:"
" -w<command> must be specified");
@@ -1365,7 +1370,8 @@ Options:
-u: Enable checking address uniqueness. Lease valid lifetime should not be
shorter than test duration and clients should not request address more than
once without releasing it first.
--v: Report the version number of this program.
+-v: Display the Kea version.
+-V: Display the extended Kea version.
-W<time>: Specifies exit-wait-time parameter, that makes perfdhcp wait
for <time> us after an exit condition has been met to receive all
packets without sending any new packets. Expressed in microseconds.
@@ -1442,7 +1448,12 @@ The exit status is:
void
CommandOptions::version() const {
- std::cout << "VERSION: " << VERSION << std::endl;
+ std::cout << VERSION << std::endl;
+}
+
+void
+CommandOptions::extendedVersion() const {
+ cout << VERSION << " (" << EXTENDED_VERSION << ")" << endl;
}
diff --git a/src/bin/perfdhcp/command_options.h b/src/bin/perfdhcp/command_options.h
index d47f6a1d96..f9840b12ba 100644
--- a/src/bin/perfdhcp/command_options.h
+++ b/src/bin/perfdhcp/command_options.h
@@ -445,10 +445,11 @@ public:
static void usage();
/// \brief Print program version.
- ///
- /// Prints perfdhcp version.
void version() const;
+ /// @brief Print extended program version.
+ void extendedVersion() const;
+
private:
/// \brief Initializes class members based on the command line.
///
diff --git a/src/bin/shell/kea-shell.in b/src/bin/shell/kea-shell.in
index 30988619d7..f4e8292423 100644
--- a/src/bin/shell/kea-shell.in
+++ b/src/bin/shell/kea-shell.in
@@ -29,6 +29,7 @@ from kea_conn import CARequest # CAResponse
VERSION = "@PACKAGE_VERSION@"
+EXTENDED_VERSION = "@EXTENDED_VERSION@"
def timeout_handler(signum, frame):
@@ -81,12 +82,17 @@ def shell_body():
help='command to be executed. If not specified, '
'"list-commands" is used')
parser.add_argument('-v', action="store_true", help="Prints version")
+ parser.add_argument('-V', action="store_true", help="Prints extended version")
cmd_args = parser.parse_args()
if cmd_args.v:
print(VERSION)
sys.exit(0)
+ if cmd_args.V:
+ print(EXTENDED_VERSION)
+ sys.exit(0)
+
# Ok, now it's time to put the parameters parsed into the structure to be
# used by the connection.
params = CARequest()
diff --git a/src/lib/process/cfgrpt/tests/config_report_unittests.cc b/src/lib/process/cfgrpt/tests/config_report_unittests.cc
index b5e8f5b0e8..d6b4b2d03f 100644
--- a/src/lib/process/cfgrpt/tests/config_report_unittests.cc
+++ b/src/lib/process/cfgrpt/tests/config_report_unittests.cc
@@ -23,5 +23,6 @@ TEST(ConfigReportTest, getConfigReport) {
// Verify that it is not empty and does contain the
// extended version number
ASSERT_FALSE(cfgReport.empty());
- EXPECT_NE(std::string::npos, cfgReport.find(EXTENDED_VERSION, 0));
+ EXPECT_NE(std::string::npos, cfgReport.find(VERSION));
+ EXPECT_NE(std::string::npos, cfgReport.find(EXTENDED_VERSION));
}
diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc
index 0bfc353f9d..b5f7e14184 100644
--- a/src/lib/process/d_controller.cc
+++ b/src/lib/process/d_controller.cc
@@ -863,11 +863,11 @@ DControllerBase::getVersion(bool extended) {
tmp << VERSION;
if (extended) {
- tmp << std::endl << EXTENDED_VERSION << std::endl;
+ tmp << " (" << EXTENDED_VERSION << ")" << std::endl;
tmp << "premium: " << PREMIUM_EXTENDED_VERSION << std::endl;
tmp << "linked with:" << std::endl;
tmp << "- " << isc::log::Logger::getVersion() << std::endl;
- tmp << getVersionAddendum();
+ tmp << "- " << isc::cryptolink::CryptoLink::getVersion();
}
return (tmp.str());
diff --git a/src/lib/process/d_controller.h b/src/lib/process/d_controller.h
index 0bbefda958..91b777b786 100644
--- a/src/lib/process/d_controller.h
+++ b/src/lib/process/d_controller.h
@@ -608,7 +608,7 @@ protected:
/// version text returned when DControllerBase::getVersion(true) is
/// invoked.
/// @return a string containing additional version info
- virtual std::string getVersionAddendum() { return (""); }
+ virtual std::string getVersionAddendum() { return (std::string()); }
/// @brief Deals with other (i.e. not application name) global objects.
///
diff --git a/src/lib/process/tests/d_controller_unittests.cc b/src/lib/process/tests/d_controller_unittests.cc
index e52cbab9db..31989de9e5 100644
--- a/src/lib/process/tests/d_controller_unittests.cc
+++ b/src/lib/process/tests/d_controller_unittests.cc
@@ -446,7 +446,6 @@ TEST_F(DStubControllerTest, getVersion) {
text = controller_->getVersion(true);
EXPECT_NE(std::string::npos, text.find(VERSION));
EXPECT_NE(std::string::npos, text.find(EXTENDED_VERSION));
- EXPECT_NE(std::string::npos, text.find(controller_->getVersionAddendum()));
}
// Tests that the SIGTERM triggers a normal shutdown.