10#include <asiolink/io_address.h>
11#include <dhcp/hwaddr.h>
13#include "kch_config.h"
17struct AdminDBClientPrivate;
53 isc::asiolink::IOAddress
ipv4;
54 isc::dhcp::HWAddr
mac;
87 std::string_view port,
88 std::string_view user,
89 std::string_view password,
90 std::string_view database,
91 size_t last_processed_host_update_id = 0);
164 const std::string& ipv4,
size_t incremental_update_id,
165 size_t subnet_id = 0)
168 .ipv4 = isc::asiolink::IOAddress(ipv4),
169 .mac = isc::dhcp::HWAddr::fromText(mac),
170 .subnet_id = subnet_id,
171 .incremental_update_id = incremental_update_id};
176 if (type_str ==
"assign") {
179 if (type_str ==
"unassign") {
182 throw std::invalid_argument(
183 "ahri::AdminDBClient: Type string doesn't match any "
184 "ahri::AdminDBClient::HostUpdate::Type");
188 std::unique_ptr<AdminDBClientPrivate> p_impl;
Client for interaction with a single AdminDB server.
AdminDBClient & operator=(const AdminDBClient &)=delete
TEST_VIRTUAL std::vector< HostUpdate > fetch_pending_host_updates()
Fetch all not-yet-processed host updates.
static constexpr const size_t UNDEFINED_SUBNET_ID
Subnet ID for an entry where the subnet ID is NULL.
static constexpr const size_t BELOW_LOWEST_INCREMENTAL_UPDATE_ID
TEST_VIRTUAL size_t fetch_latest_available_update_id()
Fetch the maximum available incremental update identifier.
AdminDBClient & operator=(AdminDBClient &&)=delete
AdminDBClient(const AdminDBClient &)=delete
std::function< void()> dhcp_update_callback_t
static constexpr const std::chrono::seconds NOTIFICATION_RECEIVER_TIMEOUT
static HostUpdate::Type host_update_type_from_string(std::string_view type_str)
static HostUpdate make_host_update(HostUpdate::Type type, const std::string &mac, const std::string &ipv4, size_t incremental_update_id, size_t subnet_id=0)
Construct a host update from the inputs.
AdminDBClient(AdminDBClient &&)=delete
TEST_VIRTUAL std::vector< HostUpdate > fetch_all_host_reservations()
Fetch a complete set of all host reservations from the AdminDB server.
static constexpr const std::chrono::milliseconds NOTIFICATION_RECEIVER_SLEEP
static constexpr const std::chrono::days DEFAULT_PRUNE_BEFORE
TEST_VIRTUAL void handle_notifications(const dhcp_update_callback_t &cb)
Handle notifications for the DHCP server by invoking the given function.
TEST_VIRTUAL void prune_old_host_updates(std::chrono::days prune_before=DEFAULT_PRUNE_BEFORE)
Prune old host updates from the AdminDB host update table.
static constexpr const char * NOTIFICATION_CHANNEL_NAME
TEST_VIRTUAL ~AdminDBClient()
AdminDBClient(std::string_view host, std::string_view port, std::string_view user, std::string_view password, std::string_view database, size_t last_processed_host_update_id=0)
Create the client and connect to the AdminDB server with the given connection settings.
size_t incremental_update_id
An incremental update identifier.
Type type
Whether the given host reservation shall be added or removed.
isc::asiolink::IOAddress ipv4