From: Razvan Becheriu Date: Wed, 8 May 2024 13:29:12 +0000 (+0300) Subject: [#2960] clean up processCommand X-Git-Tag: Kea-2.6.0~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=121496604ef93a5cce5363f4e5e1e50acc35bce6;p=thirdparty%2Fkea.git [#2960] clean up processCommand --- diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index d3e4960e3f..deda6c1c06 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -860,41 +860,6 @@ ControlledDhcpv4Srv::processCommand(const string& command, } else if (command == "config-set") { return (srv->commandConfigSetHandler(command, args)); - } else if (command == "config-get") { - return (srv->commandConfigGetHandler(command, args)); - - } else if (command == "config-hash-get") { - return (srv->commandConfigHashGetHandler(command, args)); - - } else if (command == "config-test") { - return (srv->commandConfigTestHandler(command, args)); - - } else if (command == "dhcp-disable") { - return (srv->commandDhcpDisableHandler(command, args)); - - } else if (command == "dhcp-enable") { - return (srv->commandDhcpEnableHandler(command, args)); - - } else if (command == "version-get") { - return (srv->commandVersionGetHandler(command, args)); - - } else if (command == "build-report") { - return (srv->commandBuildReportHandler(command, args)); - - } else if (command == "leases-reclaim") { - return (srv->commandLeasesReclaimHandler(command, args)); - - } else if (command == "config-write") { - return (srv->commandConfigWriteHandler(command, args)); - - } else if (command == "server-tag-get") { - return (srv->commandServerTagGetHandler(command, args)); - - } else if (command == "config-backend-pull") { - return (srv->commandConfigBackendPullHandler(command, args)); - - } else if (command == "status-get") { - return (srv->commandStatusGetHandler(command, args)); } return (isc::config::createAnswer(CONTROL_RESULT_ERROR, "Unrecognized command:" diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.h b/src/bin/dhcp4/ctrl_dhcp4_srv.h index bcac18c494..ab4fe16841 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.h +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.h @@ -74,25 +74,10 @@ public: /// @brief Command processor /// - /// This method is uniform for all config backends. It processes received - /// command (as a string + JSON arguments). Internally, it's just a - /// wrapper that calls process*Command() methods and catches exceptions - /// in them. - /// /// Currently supported commands are: /// - shutdown /// - config-reload /// - config-set - /// - config-get - /// - config-hash-get - /// - config-test - /// - dhcp-disable - /// - dhcp-enable - /// - version-get - /// - build-report - /// - leases-reclaim - /// - config-write - /// ... /// /// @note It never throws. /// diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index db1fc55a44..c636be1238 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -312,9 +312,8 @@ public: EXPECT_EQ(cb_control->getDatabaseCurrentConfigFetchCalls(), 0); EXPECT_EQ(cb_control->getDatabaseStagingConfigFetchCalls(), 1); - ConstElementPtr result = - ControlledDhcpv4Srv::processCommand("config-backend-pull", - ConstElementPtr()); + ConstElementPtr list_cmds = createCommand("config-backend-pull"); + ConstElementPtr result = CommandMgr::instance().processCommand(list_cmds); EXPECT_EQ(cb_control->getDatabaseTotalConfigFetchCalls(), 2); std::string expected; diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index c30dadfa50..d5b8fb6e63 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -865,41 +865,6 @@ ControlledDhcpv6Srv::processCommand(const string& command, } else if (command == "config-set") { return (srv->commandConfigSetHandler(command, args)); - } else if (command == "config-get") { - return (srv->commandConfigGetHandler(command, args)); - - } else if (command == "config-hash-get") { - return (srv->commandConfigHashGetHandler(command, args)); - - } else if (command == "config-test") { - return (srv->commandConfigTestHandler(command, args)); - - } else if (command == "dhcp-disable") { - return (srv->commandDhcpDisableHandler(command, args)); - - } else if (command == "dhcp-enable") { - return (srv->commandDhcpEnableHandler(command, args)); - - } else if (command == "version-get") { - return (srv->commandVersionGetHandler(command, args)); - - } else if (command == "build-report") { - return (srv->commandBuildReportHandler(command, args)); - - } else if (command == "leases-reclaim") { - return (srv->commandLeasesReclaimHandler(command, args)); - - } else if (command == "config-write") { - return (srv->commandConfigWriteHandler(command, args)); - - } else if (command == "server-tag-get") { - return (srv->commandServerTagGetHandler(command, args)); - - } else if (command == "config-backend-pull") { - return (srv->commandConfigBackendPullHandler(command, args)); - - } else if (command == "status-get") { - return (srv->commandStatusGetHandler(command, args)); } return (isc::config::createAnswer(CONTROL_RESULT_ERROR, "Unrecognized command:" diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.h b/src/bin/dhcp6/ctrl_dhcp6_srv.h index c1093be641..ba6822d03a 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.h +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.h @@ -74,25 +74,10 @@ public: /// @brief Command processor /// - /// This method is uniform for all config backends. It processes received - /// command (as a string + JSON arguments). Internally, it's just a - /// wrapper that calls process*Command() methods and catches exceptions - /// in them. - /// /// Currently supported commands are: /// - shutdown /// - config-reload /// - config-set - /// - config-get - /// - config-hash-get - /// - config-test - /// - dhcp-disable - /// - dhcp-enable - /// - version-get - /// - build-report - /// - leases-reclaim - /// - config-write - /// ... /// /// @note It never throws. /// diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index b3afbd4f77..9ec596040e 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -297,9 +297,8 @@ public: EXPECT_EQ(cb_control->getDatabaseCurrentConfigFetchCalls(), 0); EXPECT_EQ(cb_control->getDatabaseStagingConfigFetchCalls(), 1); - ConstElementPtr result = - ControlledDhcpv6Srv::processCommand("config-backend-pull", - ConstElementPtr()); + ConstElementPtr list_cmds = createCommand("config-backend-pull"); + ConstElementPtr result = CommandMgr::instance().processCommand(list_cmds); EXPECT_EQ(cb_control->getDatabaseTotalConfigFetchCalls(), 2); std::string expected;