2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-02 15:05:16 +00:00

[478-improve-error-message-database-backend-mysql] Better message for not built lease database type

This commit is contained in:
Francis Dupont
2019-02-28 15:44:55 +01:00
parent db5783548a
commit 6f6b59fb62

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // 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 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -58,27 +58,40 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
// Yes, check what it is. // Yes, check what it is.
#ifdef HAVE_MYSQL
if (parameters[type] == string("mysql")) { if (parameters[type] == string("mysql")) {
#ifdef HAVE_MYSQL
LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB).arg(redacted); LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB).arg(redacted);
getLeaseMgrPtr().reset(new MySqlLeaseMgr(parameters)); getLeaseMgrPtr().reset(new MySqlLeaseMgr(parameters));
return; return;
} #else
LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg("mysql");
isc_throw(InvalidType, "The Kea server has not been built with "
"support for database type: mysql");
#endif #endif
#ifdef HAVE_PGSQL }
if (parameters[type] == string("postgresql")) { if (parameters[type] == string("postgresql")) {
#ifdef HAVE_PGSQL
LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_DB).arg(redacted); LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_DB).arg(redacted);
getLeaseMgrPtr().reset(new PgSqlLeaseMgr(parameters)); getLeaseMgrPtr().reset(new PgSqlLeaseMgr(parameters));
return; return;
} #else
LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg("postgresql");
isc_throw(InvalidType, "The Kea server has not been built with "
"support for database type: postgresql");
#endif #endif
#ifdef HAVE_CQL }
if (parameters[type] == string("cql")) { if (parameters[type] == string("cql")) {
#ifdef HAVE_CQL
LOG_INFO(dhcpsrv_logger, DHCPSRV_CQL_DB).arg(redacted); LOG_INFO(dhcpsrv_logger, DHCPSRV_CQL_DB).arg(redacted);
getLeaseMgrPtr().reset(new CqlLeaseMgr(parameters)); getLeaseMgrPtr().reset(new CqlLeaseMgr(parameters));
return; return;
} #else
LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg("cql");
isc_throw(InvalidType, "The Kea server has not been built with "
"support for database type: cql");
#endif #endif
}
if (parameters[type] == string("memfile")) { if (parameters[type] == string("memfile")) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_DB).arg(redacted); LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_DB).arg(redacted);
getLeaseMgrPtr().reset(new Memfile_LeaseMgr(parameters)); getLeaseMgrPtr().reset(new Memfile_LeaseMgr(parameters));
@@ -88,7 +101,7 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
// Get here on no match // Get here on no match
LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg(parameters[type]); LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_DB).arg(parameters[type]);
isc_throw(InvalidType, "Database access parameter 'type' does " isc_throw(InvalidType, "Database access parameter 'type' does "
"not specify a supported database backend:" << parameters[type]); "not specify a supported database backend: " << parameters[type]);
} }
void void