]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4216] Addressed review comments
authorThomas Markwalder <tmark@isc.org>
Fri, 11 Dec 2015 12:00:18 +0000 (07:00 -0500)
committerThomas Markwalder <tmark@isc.org>
Fri, 11 Dec 2015 12:00:18 +0000 (07:00 -0500)
src/lib/dhcpsrv/host_data_source_factory.cc
    HostDataSourceFactory::create(const std::string& dbaccess)
        - Removed logging from exception throwing conditions
        - Minor clean up of the method itself

src/lib/dhcpsrv/dhcpsrv_messages.mes
    Removed obsoleted error messages:
        DHCPSRV_HOSTDB_NOTYPE
        DHCPSRV_UNKNOWN_HOST_DB

src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/host_data_source_factory.cc

index 1f84728add8f60be18ffbfefebd21097b9dc7ac5..96d51b73f15950a602c7d40b37ee3d9edd6fd2e4 100644 (file)
@@ -238,12 +238,6 @@ hook point sets the skip flag. It means that the server was told that
 no lease6 should be assigned. The server will not put that lease in its
 database and the client will get a NoAddrsAvail for that IA_NA option.
 
-% DHCPSRV_HOSTDB_NOTYPE 'type' parameter is missing from hosts database configuration: %1
-This is an error message, logged when an attempt has been made to access
-the configured hosts database, but no 'type' keyword has been included in
-the access string.  The access string (less any passwords) is included
-in the message.
-
 % DHCPSRV_INVALID_ACCESS invalid database access string: %1
 This is logged when an attempt has been made to parse a database access string
 and the attempt ended in error.  The access string in question - which
@@ -796,7 +790,3 @@ indicate an error in the source code, please submit a bug report.
 % DHCPSRV_UNKNOWN_DB unknown database type: %1
 The database access string specified a database type (given in the
 message) that is unknown to the software.  This is a configuration error.
-
-% DHCPSRV_UNKNOWN_HOST_DB unknown hosts database type: %1
-The hosts database access string specified a database type (given in the
-message) that is unknown to the software.  This is a configuration error.
index 518455421316296dfa21374e19b15dd19c23376e..524ee4c8e4232e11d98d71a74b8f487dd69fb597 100644 (file)
@@ -47,45 +47,38 @@ HostDataSourceFactory::getHostDataSourcePtr() {
 
 void
 HostDataSourceFactory::create(const std::string& dbaccess) {
-    const std::string type = "type";
-
     // Parse the access string and create a redacted string for logging.
     DatabaseConnection::ParameterMap parameters =
             DatabaseConnection::parse(dbaccess);
-    std::string redacted =
-            DatabaseConnection::redactedAccessString(parameters);
 
-    // Is "type" present?
-    if (parameters.find(type) == parameters.end()) {
-        LOG_ERROR(dhcpsrv_logger, DHCPSRV_HOSTDB_NOTYPE).arg(dbaccess);
+    // Get the databaase type and open the corresponding database
+    DatabaseConnection::ParameterMap::iterator it = parameters.find("type");
+    if (it == parameters.end()) {
         isc_throw(InvalidParameter, "Host database configuration does not "
                   "contain the 'type' keyword");
     }
 
+    std::string db_type = it->second;
 
-    // Yes, check what it is.
 #ifdef HAVE_MYSQL
-    if (parameters[type] == string("mysql")) {
-        LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_HOST_DB).arg(redacted);
+    if (db_type == "mysql") {
+        LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_HOST_DB)
+            .arg(DatabaseConnection::redactedAccessString(parameters));
         getHostDataSourcePtr().reset(new MySqlHostDataSource(parameters));
         return;
     }
 #endif
 
 #ifdef HAVE_PGSQL
-    if (parameters[type] == string("postgresql")) {
-        LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_HOST_DB).arg(redacted);
-        isc_throw(NotImplemented, "Sorry, Postgres backend for host reservations "
+    if (db_type == "postgresql") {
+        isc_throw(NotImplemented, "Sorry, PostgreSQL backend for host reservations "
                   "is not implemented yet.");
-        // Set pgsql data source here, when it will be implemented.
-        return;
     }
 #endif
 
     // Get here on no match.
-    LOG_ERROR(dhcpsrv_logger, DHCPSRV_UNKNOWN_HOST_DB).arg(parameters[type]);
-    isc_throw(InvalidType, "Database access parameter 'type' does "
-              "not specify a supported database backend");
+    isc_throw(InvalidType, "Hosts database access parameter 'type': " <<
+                           db_type << " is invalid");
 }
 
 void