From 725f3259b9c3bc2552776d5d3ec6f2064d9689e8 Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Mon, 14 Jun 2021 17:47:26 +0200 Subject: [#1928] Client classes added to CB API The CB API exposes a couple new API calls to support getting, adding and deleting client classes in DHCPv4. --- src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc | 35 +++++++++++++++++++++ src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.h | 51 ++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) (limited to 'src/hooks/dhcp') diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index c74bcbbe97..9dafd1043b 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -3222,6 +3222,23 @@ MySqlConfigBackendDHCPv4::getModifiedGlobalParameters4(const db::ServerSelector& return (parameters); } +ClientClassDefPtr +MySqlConfigBackendDHCPv4::getClientClientClass4(const db::ServerSelector& selector, + const std::string& name) const { + isc_throw(NotImplemented, "getClientClass4 is not implemented"); +} + +ClientClassDictionary +MySqlConfigBackendDHCPv4::getAllClientClasses4(const db::ServerSelector& selector) const { + isc_throw(NotImplemented, "getAllClientClasses4 is not implemented"); +} + +ClientClassDictionary +MySqlConfigBackendDHCPv4::getModifiedClientClasses4(const db::ServerSelector& selector, + const boost::posix_time::ptime& modification_time) const { + isc_throw(NotImplemented, "getModifiedClientClasses4 is not implemented"); +} + AuditEntryCollection MySqlConfigBackendDHCPv4::getRecentAuditEntries(const db::ServerSelector& server_selector, const boost::posix_time::ptime& modification_time, @@ -3326,6 +3343,13 @@ MySqlConfigBackendDHCPv4::createUpdateGlobalParameter4(const ServerSelector& ser impl_->createUpdateGlobalParameter4(server_selector, value); } +void +MySqlConfigBackendDHCPv4::createUpdateClientClass4(const db::ServerSelector& server_selector, + const ClientClassDefPtr& client_class) { + isc_throw(NotImplemented, "createUpdateClientClass4 is not implemented"); +} + + void MySqlConfigBackendDHCPv4::createUpdateServer4(const ServerPtr& server) { LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_CREATE_UPDATE_SERVER4) @@ -3546,6 +3570,17 @@ MySqlConfigBackendDHCPv4::deleteAllGlobalParameters4(const ServerSelector& serve return (result); } +uint64_t +MySqlConfigBackendDHCPv4::deleteClientClass4(const db::ServerSelector& server_selector, + const std::string& name) { + isc_throw(NotImplemented, "deleteClientClass4 is not implemented"); +} + +uint64_t +MySqlConfigBackendDHCPv4::deleteAllClientClasses4(const db::ServerSelector& server_selector) { + isc_throw(NotImplemented, "deleteAllClientClasses4 is not implemented"); +} + uint64_t MySqlConfigBackendDHCPv4::deleteServer4(const ServerTag& server_tag) { LOG_DEBUG(mysql_cb_logger, DBGLVL_TRACE_BASIC, MYSQL_CB_DELETE_SERVER4) diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.h b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.h index ba483ed906..26355c9a04 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.h +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -225,6 +226,30 @@ public: getModifiedGlobalParameters4(const db::ServerSelector& server_selector, const boost::posix_time::ptime& modification_time) const; + /// @brief Retrieves a client class by name. + /// + /// @param server_selector Server selector. + /// @param name Client class name. + /// @return Pointer to the retrieved client class. + virtual ClientClassDefPtr + getClientClientClass4(const db::ServerSelector& selector, const std::string& name) const; + + /// @brief Retrieves all client classes. + /// + /// @param selector Server selector. + /// @return Collection of client classes. + virtual ClientClassDictionary + getAllClientClasses4(const db::ServerSelector& selector) const; + + /// @brief Retrieves client classes modified after specified time. + /// + /// @param selector Server selector. + /// @param modification_time Modification time. + /// @return Collection of client classes. + virtual ClientClassDictionary + getModifiedClientClasses4(const db::ServerSelector& selector, + const boost::posix_time::ptime& modification_time) const; + /// @brief Retrieves the most recent audit entries. /// /// @param selector Server selector. @@ -340,6 +365,14 @@ public: createUpdateGlobalParameter4(const db::ServerSelector& server_selector, const data::StampedValuePtr& value); + /// @brief Creates or updates DHCPv4 client class. + /// + /// @param server_selector Server selector. + /// @param client_class Client class to be added or updated. + virtual void + createUpdateClientClass4(const db::ServerSelector& server_selector, + const ClientClassDefPtr& client_class); + /// @brief Creates or updates a server. /// /// @param server Instance of the server to be stored. @@ -495,6 +528,22 @@ public: virtual uint64_t deleteAllGlobalParameters4(const db::ServerSelector& server_selector); + /// @brief Deletes DHCPv4 client class. + /// + /// @param server_selector Server selector. + /// @param name Name of the class to be deleted. + /// @return Number of deleted client classes. + virtual uint64_t + deleteClientClass4(const db::ServerSelector& server_selector, + const std::string& name); + + /// @brief Deletes all client classes. + /// + /// @param server_selector Server selector. + /// @return Number of deleted client classes. + virtual uint64_t + deleteAllClientClasses4(const db::ServerSelector& server_selector); + /// @brief Deletes a server from the backend. /// /// @param server_tag Tag of the server to be deleted. -- cgit v1.2.3