Commit 7c8b1108 authored by Stephen Morris's avatar Stephen Morris

[2472] Add getType() method and update message when backend is started

The message when the DHCPv6 database backend is started now includes
both the type and the name of the database.
parent 238254d3
...@@ -30,7 +30,7 @@ from the BIND 10 control system by the IPv6 DHCP server. ...@@ -30,7 +30,7 @@ from the BIND 10 control system by the IPv6 DHCP server.
A debug message indicating that the IPv6 DHCP server has received an A debug message indicating that the IPv6 DHCP server has received an
updated configuration from the BIND 10 configuration system. updated configuration from the BIND 10 configuration system.
% DHCP6_DB_BACKEND_STARTED Lease database started (backend type: %1) % DHCP6_DB_BACKEND_STARTED lease database started (type: %1, name: %2)
This informational message is printed every time DHCPv6 is started. This informational message is printed every time DHCPv6 is started.
It indicates what database backend type is being to store lease and It indicates what database backend type is being to store lease and
other information. other information.
...@@ -47,7 +47,7 @@ interfaces and is therefore shutting down. ...@@ -47,7 +47,7 @@ interfaces and is therefore shutting down.
A debug message issued during startup, this indicates that the IPv6 DHCP A debug message issued during startup, this indicates that the IPv6 DHCP
server is about to open sockets on the specified port. server is about to open sockets on the specified port.
% DHCP6_LEASE_ADVERT Lease %1 advertised (client duid=%2, iaid=%3) % DHCP6_LEASE_ADVERT lease %1 advertised (client duid=%2, iaid=%3)
This debug message indicates that the server successfully advertised This debug message indicates that the server successfully advertised
a lease. It is up to the client to choose one server out of othe advertised a lease. It is up to the client to choose one server out of othe advertised
and continue allocation with that server. This is a normal behavior and and continue allocation with that server. This is a normal behavior and
...@@ -154,14 +154,16 @@ the response will only contain generic configuration parameters and no ...@@ -154,14 +154,16 @@ the response will only contain generic configuration parameters and no
addresses or prefixes. addresses or prefixes.
% DHCP6_NO_SUBNET_DEF_OPT failed to find subnet for address %1 when adding default options % DHCP6_NO_SUBNET_DEF_OPT failed to find subnet for address %1 when adding default options
This warning message indicates that when attempting to add default options to a response, This warning message indicates that when attempting to add default options
the server found that it was not configured to support the subnet from which the DHCPv6 to a response, the server found that it was not configured to support
request was received. The packet has been ignored. the subnet from which the DHCPv6 request was received. The packet has
been ignored.
% DHCP6_NO_SUBNET_REQ_OPT failed to find subnet for address %1 when adding requested options % DHCP6_NO_SUBNET_REQ_OPT failed to find subnet for address %1 when adding requested options
This warning message indicates that when attempting to add requested options to a response, This warning message indicates that when attempting to add requested
the server found that it was not configured to support the subnet from which the DHCPv6 options to a response, the server found that it was not configured
request was received. The packet has been ignored. to support the subnet from which the DHCPv6 request was received.
The packet has been ignored.
% DHCP6_CONFIG_LOAD_FAIL failed to load configuration: %1 % DHCP6_CONFIG_LOAD_FAIL failed to load configuration: %1
This critical error message indicates that the initial DHCPv6 This critical error message indicates that the initial DHCPv6
......
...@@ -80,6 +80,7 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port, const char* dbconfig) ...@@ -80,6 +80,7 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port, const char* dbconfig)
// Instantiate LeaseMgr // Instantiate LeaseMgr
LeaseMgrFactory::create(dbconfig); LeaseMgrFactory::create(dbconfig);
LOG_INFO(dhcp6_logger, DHCP6_DB_BACKEND_STARTED) LOG_INFO(dhcp6_logger, DHCP6_DB_BACKEND_STARTED)
.arg(LeaseMgrFactory::instance().getType())
.arg(LeaseMgrFactory::instance().getName()); .arg(LeaseMgrFactory::instance().getName());
// Instantiate allocation engine // Instantiate allocation engine
......
...@@ -505,14 +505,26 @@ public: ...@@ -505,14 +505,26 @@ public:
/// @return true if deletion was successful, false if no such lease exists /// @return true if deletion was successful, false if no such lease exists
virtual bool deleteLease6(const isc::asiolink::IOAddress& addr) = 0; virtual bool deleteLease6(const isc::asiolink::IOAddress& addr) = 0;
/// @brief Return backend type
///
/// Returns the type of the backend (e.g. "mysql", "memfile" etc.)
///
/// @return Type of the backend.
virtual std::string getType() const = 0;
/// @brief Returns backend name. /// @brief Returns backend name.
/// ///
/// Each backend have specific name, e.g. "mysql" or "sqlite". /// If the backend is a database, this is the name of the database or the
/// file. Otherwise it is just the same as the type.
///
/// @return Name of the backend.
virtual std::string getName() const = 0; virtual std::string getName() const = 0;
/// @brief Returns description of the backend. /// @brief Returns description of the backend.
/// ///
/// This description may be multiline text that describes the backend. /// This description may be multiline text that describes the backend.
///
/// @return Description of the backend.
virtual std::string getDescription() const = 0; virtual std::string getDescription() const = 0;
/// @brief Returns backend version. /// @brief Returns backend version.
...@@ -548,7 +560,7 @@ public: ...@@ -548,7 +560,7 @@ public:
/// is currently postponed. /// is currently postponed.
/// @brief returns value of the parameter /// @brief returns value of the parameter
std::string getParameter(const std::string& name) const; virtual std::string getParameter(const std::string& name) const;
private: private:
/// @brief list of parameters passed in dbconfig /// @brief list of parameters passed in dbconfig
......
...@@ -188,15 +188,31 @@ public: ...@@ -188,15 +188,31 @@ public:
/// @return true if deletion was successful, false if no such lease exists /// @return true if deletion was successful, false if no such lease exists
bool deleteLease6(const isc::asiolink::IOAddress& addr); bool deleteLease6(const isc::asiolink::IOAddress& addr);
/// @brief Return backend type
///
/// Returns the type of the backend.
///
/// @return Type of the backend.
virtual std::string getType() const {
return (std::string("memfile"));
}
/// @brief Returns backend name. /// @brief Returns backend name.
/// ///
/// Each backend have specific name, e.g. "mysql" or "sqlite". /// As there is no variation, in this case we return the type of the
std::string getName() const { return ("memfile"); } /// backend.
///
/// @return Name of the backend.
virtual std::string getName() const {
return ("memfile");
}
/// @brief Returns description of the backend. /// @brief Returns description of the backend.
/// ///
/// This description may be multiline text that describes the backend. /// This description may be multiline text that describes the backend.
std::string getDescription() const; ///
/// @return Description of the backend.
virtual std::string getDescription() const;
/// @brief Returns backend version. /// @brief Returns backend version.
virtual std::pair<uint32_t, uint32_t> getVersion() const { virtual std::pair<uint32_t, uint32_t> getVersion() const {
......
...@@ -239,14 +239,27 @@ public: ...@@ -239,14 +239,27 @@ public:
/// failed. /// failed.
virtual bool deleteLease6(const isc::asiolink::IOAddress& addr); virtual bool deleteLease6(const isc::asiolink::IOAddress& addr);
/// @brief Return backend type
///
/// Returns the type of the backend (e.g. "mysql", "memfile" etc.)
///
/// @return Type of the backend.
virtual std::string getType() const {
return (std::string("mysql"));
}
/// @brief Returns backend name. /// @brief Returns backend name.
/// ///
/// Each backend have specific name, e.g. "mysql" or "sqlite". /// Each backend have specific name, e.g. "mysql" or "sqlite".
///
/// @return Name of the backend.
virtual std::string getName() const; virtual std::string getName() const;
/// @brief Returns description of the backend. /// @brief Returns description of the backend.
/// ///
/// This description may be multiline text that describes the backend. /// This description may be multiline text that describes the backend.
///
/// @return Description of the backend.
virtual std::string getDescription() const; virtual std::string getDescription() const;
/// @brief Returns backend version. /// @brief Returns backend version.
......
...@@ -134,7 +134,7 @@ public: ...@@ -134,7 +134,7 @@ public:
/// @param addr address of the searched lease /// @param addr address of the searched lease
/// ///
/// @return smart pointer to the lease (or NULL if a lease is not found) /// @return smart pointer to the lease (or NULL if a lease is not found)
Lease6Ptr getLease6(const isc::asiolink::IOAddress&) const { virtual Lease6Ptr getLease6(const isc::asiolink::IOAddress&) const {
return (Lease6Ptr()); return (Lease6Ptr());
} }
...@@ -144,7 +144,7 @@ public: ...@@ -144,7 +144,7 @@ public:
/// @param iaid IA identifier /// @param iaid IA identifier
/// ///
/// @return collection of IPv6 leases /// @return collection of IPv6 leases
Lease6Collection getLease6(const DUID&, uint32_t) const { virtual Lease6Collection getLease6(const DUID&, uint32_t) const {
return (Lease6Collection()); return (Lease6Collection());
} }
...@@ -155,7 +155,7 @@ public: ...@@ -155,7 +155,7 @@ public:
/// @param subnet_id identifier of the subnet the lease must belong to /// @param subnet_id identifier of the subnet the lease must belong to
/// ///
/// @return smart pointer to the lease (or NULL if a lease is not found) /// @return smart pointer to the lease (or NULL if a lease is not found)
Lease6Ptr getLease6(const DUID&, uint32_t, SubnetID) const { virtual Lease6Ptr getLease6(const DUID&, uint32_t, SubnetID) const {
return (Lease6Ptr()); return (Lease6Ptr());
} }
...@@ -164,21 +164,21 @@ public: ...@@ -164,21 +164,21 @@ public:
/// @param lease4 The lease to be updated. /// @param lease4 The lease to be updated.
/// ///
/// If no such lease is present, an exception will be thrown. /// If no such lease is present, an exception will be thrown.
void updateLease4(const Lease4Ptr&) {} virtual void updateLease4(const Lease4Ptr&) {}
/// @brief Updates IPv4 lease. /// @brief Updates IPv4 lease.
/// ///
/// @param lease4 The lease to be updated. /// @param lease4 The lease to be updated.
/// ///
/// If no such lease is present, an exception will be thrown. /// If no such lease is present, an exception will be thrown.
void updateLease6(const Lease6Ptr&) {} virtual void updateLease6(const Lease6Ptr&) {}
/// @brief Deletes a lease. /// @brief Deletes a lease.
/// ///
/// @param addr IPv4 address of the lease to be deleted. /// @param addr IPv4 address of the lease to be deleted.
/// ///
/// @return true if deletion was successful, false if no such lease exists /// @return true if deletion was successful, false if no such lease exists
bool deleteLease4(const isc::asiolink::IOAddress&) { virtual bool deleteLease4(const isc::asiolink::IOAddress&) {
return (false); return (false);
} }
...@@ -187,35 +187,49 @@ public: ...@@ -187,35 +187,49 @@ public:
/// @param addr IPv4 address of the lease to be deleted. /// @param addr IPv4 address of the lease to be deleted.
/// ///
/// @return true if deletion was successful, false if no such lease exists /// @return true if deletion was successful, false if no such lease exists
bool deleteLease6(const isc::asiolink::IOAddress&) { virtual bool deleteLease6(const isc::asiolink::IOAddress&) {
return (false); return (false);
} }
/// @brief Returns backend type.
///
/// Returns the type of the backend (e.g. "mysql", "memfile" etc.)
///
/// @return Type of the backend.
virtual std::string getType() const {
return (std::string("concrete"));
}
/// @brief Returns backend name. /// @brief Returns backend name.
/// ///
/// Each backend have specific name, e.g. "mysql" or "sqlite". /// If the backend is a database, this is the name of the database or the
std::string getName() const { /// file. Otherwise it is just the same as the type.
///
/// @return Name of the backend.
virtual std::string getName() const {
return (std::string("concrete")); return (std::string("concrete"));
} }
/// @brief Returns description of the backend. /// @brief Returns description of the backend.
/// ///
/// This description may be multiline text that describes the backend. /// This description may be multiline text that describes the backend.
std::string getDescription() const { ///
/// @return Description of the backend.
virtual std::string getDescription() const {
return (std::string("This is a dummy concrete backend implementation.")); return (std::string("This is a dummy concrete backend implementation."));
} }
/// @brief Returns backend version. /// @brief Returns backend version.
std::pair<uint32_t, uint32_t> getVersion() const { virtual std::pair<uint32_t, uint32_t> getVersion() const {
return (make_pair(uint32_t(0), uint32_t(0))); return (make_pair(uint32_t(0), uint32_t(0)));
} }
/// @brief Commit transactions /// @brief Commit transactions
void commit() { virtual void commit() {
} }
/// @brief Rollback transactions /// @brief Rollback transactions
void rollback() { virtual void rollback() {
} }
}; };
......
...@@ -45,6 +45,14 @@ TEST_F(MemfileLeaseMgrTest, constructor) { ...@@ -45,6 +45,14 @@ TEST_F(MemfileLeaseMgrTest, constructor) {
ASSERT_NO_THROW(lease_mgr.reset(new Memfile_LeaseMgr(pmap))); ASSERT_NO_THROW(lease_mgr.reset(new Memfile_LeaseMgr(pmap)));
} }
TEST_F(MemfileLeaseMgrTest, GetTypeAndName) {
const LeaseMgr::ParameterMap pmap; // Empty parameter map
boost::scoped_ptr<Memfile_LeaseMgr> lease_mgr(new Memfile_LeaseMgr(pmap));
EXPECT_EQ(std::string("memfile"), lease_mgr->getType());
EXPECT_EQ(std::string("memfile"), lease_mgr->getName());
}
// There's no point in calling any other methods in LeaseMgr, as they // There's no point in calling any other methods in LeaseMgr, as they
// are purely virtual, so we would only call Memfile_LeaseMgr methods. // are purely virtual, so we would only call Memfile_LeaseMgr methods.
// Those methods are just stubs that does not return anything. // Those methods are just stubs that does not return anything.
......
...@@ -470,6 +470,10 @@ TEST(MySqlOpenTest, OpenDatabase) { ...@@ -470,6 +470,10 @@ TEST(MySqlOpenTest, OpenDatabase) {
destroySchema(); destroySchema();
} }
TEST_F(MySqlLeaseMgrTest, GetType) {
EXPECT_EQ(std::string("mysql"), lmptr_->getType());
}
// @brief Check conversion functions // @brief Check conversion functions
TEST_F(MySqlLeaseMgrTest, CheckTimeConversion) { TEST_F(MySqlLeaseMgrTest, CheckTimeConversion) {
const time_t cltt = time(NULL); const time_t cltt = time(NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment