mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[#3106] ha-maintenance-notify includes server name
This commit is contained in:
@@ -247,8 +247,11 @@ CommandCreator::createLease6GetPage(const Lease6Ptr& last_lease6,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConstElementPtr
|
ConstElementPtr
|
||||||
CommandCreator::createMaintenanceNotify(const bool cancel, const HAServerType& server_type) {
|
CommandCreator::createMaintenanceNotify(const std::string& server_name,
|
||||||
|
const bool cancel,
|
||||||
|
const HAServerType& server_type) {
|
||||||
auto args = Element::createMap();
|
auto args = Element::createMap();
|
||||||
|
args->set("server-name", Element::create(server_name));
|
||||||
args->set("cancel", Element::create(cancel));
|
args->set("cancel", Element::create(cancel));
|
||||||
auto command = config::createCommand("ha-maintenance-notify", args);
|
auto command = config::createCommand("ha-maintenance-notify", args);
|
||||||
insertService(command, server_type);
|
insertService(command, server_type);
|
||||||
|
@@ -171,12 +171,16 @@ public:
|
|||||||
|
|
||||||
/// @brief Creates ha-maintenance-notify command.
|
/// @brief Creates ha-maintenance-notify command.
|
||||||
///
|
///
|
||||||
|
/// @param server_name name of the server sending the command allowing
|
||||||
|
/// for associating the command with the relationship.
|
||||||
/// @param cancel boolean value indicating if the maintenance
|
/// @param cancel boolean value indicating if the maintenance
|
||||||
/// is being cancelled (true) or requested (false).
|
/// is being cancelled (true) or requested (false).
|
||||||
/// @param server_type type of the DHCP server, i.e. v4 or v6.
|
/// @param server_type type of the DHCP server, i.e. v4 or v6.
|
||||||
/// @return Pointer to the JSON representation of the command.
|
/// @return Pointer to the JSON representation of the command.
|
||||||
static data::ConstElementPtr
|
static data::ConstElementPtr
|
||||||
createMaintenanceNotify(const bool cancel, const HAServerType& server_type);
|
createMaintenanceNotify(const std::string& server_name,
|
||||||
|
const bool cancel,
|
||||||
|
const HAServerType& server_type);
|
||||||
|
|
||||||
/// @brief Creates ha-sync-complete-notify command.
|
/// @brief Creates ha-sync-complete-notify command.
|
||||||
///
|
///
|
||||||
|
@@ -468,7 +468,7 @@ HAImpl::scopesHandler(hooks::CalloutHandle& callout_handle) {
|
|||||||
scopes_vector.push_back(scope->stringValue());
|
scopes_vector.push_back(scope->stringValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
service = getHAServiceByServerName("ha-sync", args);
|
service = getHAServiceByServerName("ha-scopes", args);
|
||||||
|
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
// There was an error while parsing command arguments. Return an error status
|
// There was an error while parsing command arguments. Return an error status
|
||||||
@@ -588,7 +588,7 @@ HAImpl::haResetHandler(hooks::CalloutHandle& callout_handle) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstElementPtr response = services_->get()->processHAReset();
|
ConstElementPtr response = service->processHAReset();
|
||||||
callout_handle.setArgument("response", response);
|
callout_handle.setArgument("response", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2696,7 +2696,8 @@ HAService::processMaintenanceStart() {
|
|||||||
(HttpRequest::Method::HTTP_POST, "/", HttpVersion::HTTP_11(),
|
(HttpRequest::Method::HTTP_POST, "/", HttpVersion::HTTP_11(),
|
||||||
HostHttpHeader(remote_config->getUrl().getStrippedHostname()));
|
HostHttpHeader(remote_config->getUrl().getStrippedHostname()));
|
||||||
remote_config->addBasicAuthHttpHeader(request);
|
remote_config->addBasicAuthHttpHeader(request);
|
||||||
request->setBodyAsJson(CommandCreator::createMaintenanceNotify(false, server_type_));
|
request->setBodyAsJson(CommandCreator::createMaintenanceNotify(config_->getThisServerName(),
|
||||||
|
false, server_type_));
|
||||||
request->finalize();
|
request->finalize();
|
||||||
|
|
||||||
// Response object should also be created because the HTTP client needs
|
// Response object should also be created because the HTTP client needs
|
||||||
@@ -2822,7 +2823,8 @@ HAService::processMaintenanceCancel() {
|
|||||||
(HttpRequest::Method::HTTP_POST, "/", HttpVersion::HTTP_11(),
|
(HttpRequest::Method::HTTP_POST, "/", HttpVersion::HTTP_11(),
|
||||||
HostHttpHeader(remote_config->getUrl().getStrippedHostname()));
|
HostHttpHeader(remote_config->getUrl().getStrippedHostname()));
|
||||||
remote_config->addBasicAuthHttpHeader(request);
|
remote_config->addBasicAuthHttpHeader(request);
|
||||||
request->setBodyAsJson(CommandCreator::createMaintenanceNotify(true, server_type_));
|
request->setBodyAsJson(CommandCreator::createMaintenanceNotify(config_->getThisServerName(),
|
||||||
|
true, server_type_));
|
||||||
request->finalize();
|
request->finalize();
|
||||||
|
|
||||||
// Response object should also be created because the HTTP client needs
|
// Response object should also be created because the HTTP client needs
|
||||||
|
@@ -507,7 +507,7 @@ TEST(CommandCreatorTest, createLease6GetPageZeroLimit) {
|
|||||||
// This test verifies that the ha-maintenance-notify command is correct
|
// This test verifies that the ha-maintenance-notify command is correct
|
||||||
// while being sent to the DHCPv4 server.
|
// while being sent to the DHCPv4 server.
|
||||||
TEST(CommandCreatorTest, createMaintenanceNotify4) {
|
TEST(CommandCreatorTest, createMaintenanceNotify4) {
|
||||||
ConstElementPtr command = CommandCreator::createMaintenanceNotify(true, HAServerType::DHCPv4);
|
ConstElementPtr command = CommandCreator::createMaintenanceNotify("server1", true, HAServerType::DHCPv4);
|
||||||
ConstElementPtr arguments;
|
ConstElementPtr arguments;
|
||||||
ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-maintenance-notify", "dhcp4",
|
ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-maintenance-notify", "dhcp4",
|
||||||
arguments));
|
arguments));
|
||||||
@@ -521,7 +521,7 @@ TEST(CommandCreatorTest, createMaintenanceNotify4) {
|
|||||||
// This test verifies that the ha-maintenance-notify command is correct
|
// This test verifies that the ha-maintenance-notify command is correct
|
||||||
// while being sent to the DHCPv6 server.
|
// while being sent to the DHCPv6 server.
|
||||||
TEST(CommandCreatorTest, createMaintenanceNotify6) {
|
TEST(CommandCreatorTest, createMaintenanceNotify6) {
|
||||||
ConstElementPtr command = CommandCreator::createMaintenanceNotify(false, HAServerType::DHCPv6);
|
ConstElementPtr command = CommandCreator::createMaintenanceNotify("server1", false, HAServerType::DHCPv6);
|
||||||
ConstElementPtr arguments;
|
ConstElementPtr arguments;
|
||||||
ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-maintenance-notify", "dhcp6",
|
ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-maintenance-notify", "dhcp6",
|
||||||
arguments));
|
arguments));
|
||||||
|
Reference in New Issue
Block a user