return (0);
}
+/// @brief ha-continue command handler implementation.
+int continue_command(CalloutHandle& handle) {
+ try {
+ impl->continueHandler(handle);
+
+ } catch (const std::exception& ex) {
+ LOG_ERROR(ha_logger, HA_CONTINUE_HANDLER_FAILED)
+ .arg(ex.what());
+ }
+
+ return (0);
+}
+
/// @brief This function is called when the library is loaded.
///
/// @param handle library handle
handle.registerCommandCallout("ha-heartbeat", heartbeat_command);
handle.registerCommandCallout("ha-sync", sync_command);
handle.registerCommandCallout("ha-scopes", scopes_command);
+ handle.registerCommandCallout("ha-continue", continue_command);
} catch (const std::exception& ex) {
LOG_ERROR(ha_logger, HA_CONFIGURATION_FAILED)
callout_handle.setArgument("response", response);
}
+void
+HAImpl::continueHandler(hooks::CalloutHandle& callout_handle) {
+ ConstElementPtr response = service_->processContinue();
+ callout_handle.setArgument("response", response);
+}
+
+
} // end of namespace isc::ha
} // end of namespace isc
/// @param callout_handle Callout handle provided to the callout.
void scopesHandler(hooks::CalloutHandle& callout_handle);
+ /// @brief Implements handler for the ha-continue command.
+ ///
+ /// @param callout_handle Callout handle provided to the callout.
+ void continueHandler(hooks::CalloutHandle& callout_handle);
+
protected:
/// @brief Holds parsed configuration.
which the server has transitioned. The sole argument specifies the state
into which the server has transitioned.
+% HA_CONTINUE_HANDLER_FAILED ha-continue command failed: %1
+This error message is issued to indicate that the ha-continue command handler
+failed while processing the command. The argument provides the reason for
+failure.
+
% HA_DEINIT_OK unloading High Availability hooks library successful
This informational message indicates that the High Availability hooks library
has been unloaded successfully.
}
+// Tests ha-continue command handler.
+TEST_F(HAImplTest, continueHandler) {
+ HAImpl ha_impl;
+ ASSERT_NO_THROW(ha_impl.configure(createValidJsonConfiguration()));
+
+ // Starting the service is required prior to running any callouts.
+ NetworkStatePtr network_state(new NetworkState(NetworkState::DHCPv4));
+ ASSERT_NO_THROW(ha_impl.startService(io_service_, network_state,
+ HAServerType::DHCPv4));
+
+ ConstElementPtr command = Element::fromJSON("{ \"command\": \"ha-continue\" }");
+
+ CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
+ callout_handle->setArgument("command", command);
+
+ ASSERT_NO_THROW(ha_impl.continueHandler(*callout_handle));
+
+ ConstElementPtr response;
+ callout_handle->getArgument("response", response);
+ ASSERT_TRUE(response);
+
+ checkAnswer(response, CONTROL_RESULT_SUCCESS, "HA state machine is not paused.");
+}
+
}