Browse Source

[4216] Eliminated reuse of log message IDs in hosts database related logging

src/lib/dhcpsrv/dhcpsrv_messages.mes
    Added hosts database specific messages

src/lib/dhcpsrv/host_data_source_factory.cc
src/lib/dhcpsrv/mysql_host_data_source.cc
    Updated log statements with hosts database messages
Thomas Markwalder 9 years ago
parent
commit
2c413e04e0

+ 26 - 0
src/lib/dhcpsrv/dhcpsrv_messages.mes

@@ -238,6 +238,12 @@ 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
 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.
 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
 % DHCPSRV_INVALID_ACCESS invalid database access string: %1
 This is logged when an attempt has been made to parse a database access string
 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
 and the attempt ended in error.  The access string in question - which
@@ -532,6 +538,16 @@ and hardware address.
 A debug message issued when the server is about to obtain schema version
 A debug message issued when the server is about to obtain schema version
 information from the MySQL database.
 information from the MySQL database.
 
 
+% DHCPSRV_MYSQL_HOST_DB opening MySQL hosts database: %1
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a MySQL hosts database.  The parameters of the
+connection including database name and username needed to access it
+(but not the password if any) are logged.
+
+% DHCPSRV_MYSQL_HOST_DB_GET_VERSION obtaining schema version information
+A debug message issued when the server is about to obtain schema version
+information from the MySQL hosts database.
+
 % DHCPSRV_MYSQL_ROLLBACK rolling back MySQL database
 % DHCPSRV_MYSQL_ROLLBACK rolling back MySQL database
 The code has issued a rollback call.  All outstanding transaction will
 The code has issued a rollback call.  All outstanding transaction will
 be rolled back and not committed to the database.
 be rolled back and not committed to the database.
@@ -658,6 +674,12 @@ and hardware address.
 A debug message issued when the server is about to obtain schema version
 A debug message issued when the server is about to obtain schema version
 information from the PostgreSQL database.
 information from the PostgreSQL database.
 
 
+% DHCPSRV_PGSQL_HOST_DB opening PostgreSQL hosts database: %1
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a PostgreSQL hosts database.  The parameters of the
+connection including database name and username needed to access it
+(but not the password if any) are logged.
+
 % DHCPSRV_PGSQL_ROLLBACK rolling back PostgreSQL database
 % DHCPSRV_PGSQL_ROLLBACK rolling back PostgreSQL database
 The code has issued a rollback call.  All outstanding transaction will
 The code has issued a rollback call.  All outstanding transaction will
 be rolled back and not committed to the database.
 be rolled back and not committed to the database.
@@ -774,3 +796,7 @@ indicate an error in the source code, please submit a bug report.
 % DHCPSRV_UNKNOWN_DB unknown database type: %1
 % DHCPSRV_UNKNOWN_DB unknown database type: %1
 The database access string specified a database type (given in the
 The database access string specified a database type (given in the
 message) that is unknown to the software.  This is a configuration error.
 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.

+ 5 - 5
src/lib/dhcpsrv/host_data_source_factory.cc

@@ -57,8 +57,8 @@ HostDataSourceFactory::create(const std::string& dbaccess) {
 
 
     // Is "type" present?
     // Is "type" present?
     if (parameters.find(type) == parameters.end()) {
     if (parameters.find(type) == parameters.end()) {
-        LOG_ERROR(dhcpsrv_logger, DHCPSRV_NOTYPE_DB).arg(dbaccess);
-        isc_throw(InvalidParameter, "Database configuration parameters do not "
+        LOG_ERROR(dhcpsrv_logger, DHCPSRV_HOSTDB_NOTYPE).arg(dbaccess);
+        isc_throw(InvalidParameter, "Host database configuration does not "
                   "contain the 'type' keyword");
                   "contain the 'type' keyword");
     }
     }
 
 
@@ -66,7 +66,7 @@ HostDataSourceFactory::create(const std::string& dbaccess) {
     // Yes, check what it is.
     // Yes, check what it is.
 #ifdef HAVE_MYSQL
 #ifdef HAVE_MYSQL
     if (parameters[type] == string("mysql")) {
     if (parameters[type] == string("mysql")) {
-        LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_DB).arg(redacted);
+        LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_HOST_DB).arg(redacted);
         getHostDataSourcePtr().reset(new MySqlHostDataSource(parameters));
         getHostDataSourcePtr().reset(new MySqlHostDataSource(parameters));
         return;
         return;
     }
     }
@@ -74,7 +74,7 @@ HostDataSourceFactory::create(const std::string& dbaccess) {
 
 
 #ifdef HAVE_PGSQL
 #ifdef HAVE_PGSQL
     if (parameters[type] == string("postgresql")) {
     if (parameters[type] == string("postgresql")) {
-        LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_DB).arg(redacted);
+        LOG_INFO(dhcpsrv_logger, DHCPSRV_PGSQL_HOST_DB).arg(redacted);
         isc_throw(NotImplemented, "Sorry, Postgres backend for host reservations "
         isc_throw(NotImplemented, "Sorry, Postgres backend for host reservations "
                   "is not implemented yet.");
                   "is not implemented yet.");
         // Set pgsql data source here, when it will be implemented.
         // Set pgsql data source here, when it will be implemented.
@@ -83,7 +83,7 @@ HostDataSourceFactory::create(const std::string& dbaccess) {
 #endif
 #endif
 
 
     // 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_HOST_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");
               "not specify a supported database backend");
 }
 }

+ 1 - 1
src/lib/dhcpsrv/mysql_host_data_source.cc

@@ -976,7 +976,7 @@ std::pair<uint32_t, uint32_t> MySqlHostDataSource::getVersion() const {
     const StatementIndex stindex = GET_VERSION;
     const StatementIndex stindex = GET_VERSION;
 
 
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
-              DHCPSRV_MYSQL_GET_VERSION);
+              DHCPSRV_MYSQL_HOST_DB_GET_VERSION);
 
 
     uint32_t major;      // Major version number
     uint32_t major;      // Major version number
     uint32_t minor;      // Minor version number
     uint32_t minor;      // Minor version number