}
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();
+ args->set("server-name", Element::create(server_name));
args->set("cancel", Element::create(cancel));
auto command = config::createCommand("ha-maintenance-notify", args);
insertService(command, server_type);
/// @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
/// is being cancelled (true) or requested (false).
/// @param server_type type of the DHCP server, i.e. v4 or v6.
/// @return Pointer to the JSON representation of the command.
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.
///
scopes_vector.push_back(scope->stringValue());
}
- service = getHAServiceByServerName("ha-sync", args);
+ service = getHAServiceByServerName("ha-scopes", args);
} catch (const std::exception& ex) {
// There was an error while parsing command arguments. Return an error status
return;
}
- ConstElementPtr response = services_->get()->processHAReset();
+ ConstElementPtr response = service->processHAReset();
callout_handle.setArgument("response", response);
}
(HttpRequest::Method::HTTP_POST, "/", HttpVersion::HTTP_11(),
HostHttpHeader(remote_config->getUrl().getStrippedHostname()));
remote_config->addBasicAuthHttpHeader(request);
- request->setBodyAsJson(CommandCreator::createMaintenanceNotify(false, server_type_));
+ request->setBodyAsJson(CommandCreator::createMaintenanceNotify(config_->getThisServerName(),
+ false, server_type_));
request->finalize();
// Response object should also be created because the HTTP client needs
(HttpRequest::Method::HTTP_POST, "/", HttpVersion::HTTP_11(),
HostHttpHeader(remote_config->getUrl().getStrippedHostname()));
remote_config->addBasicAuthHttpHeader(request);
- request->setBodyAsJson(CommandCreator::createMaintenanceNotify(true, server_type_));
+ request->setBodyAsJson(CommandCreator::createMaintenanceNotify(config_->getThisServerName(),
+ true, server_type_));
request->finalize();
// Response object should also be created because the HTTP client needs
// This test verifies that the ha-maintenance-notify command is correct
// while being sent to the DHCPv4 server.
TEST(CommandCreatorTest, createMaintenanceNotify4) {
- ConstElementPtr command = CommandCreator::createMaintenanceNotify(true, HAServerType::DHCPv4);
+ ConstElementPtr command = CommandCreator::createMaintenanceNotify("server1", true, HAServerType::DHCPv4);
ConstElementPtr arguments;
ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-maintenance-notify", "dhcp4",
arguments));
// This test verifies that the ha-maintenance-notify command is correct
// while being sent to the DHCPv6 server.
TEST(CommandCreatorTest, createMaintenanceNotify6) {
- ConstElementPtr command = CommandCreator::createMaintenanceNotify(false, HAServerType::DHCPv6);
+ ConstElementPtr command = CommandCreator::createMaintenanceNotify("server1", false, HAServerType::DHCPv6);
ConstElementPtr arguments;
ASSERT_NO_FATAL_FAILURE(testCommandBasics(command, "ha-maintenance-notify", "dhcp6",
arguments));