diff options
author | Jelte Jansen <jelte@isc.org> | 2011-06-27 18:49:06 +0200 |
---|---|---|
committer | Jelte Jansen <jelte@isc.org> | 2011-06-27 18:49:06 +0200 |
commit | 91bab51181c8ebc89e0ee2e735cc6e851eb6b93d (patch) | |
tree | 66f6724a38c4108f28a5f3fc36cd9c08abf1502e | |
parent | [trac759] add (empty) messages file (diff) | |
download | kea-91bab51181c8ebc89e0ee2e735cc6e851eb6b93d.tar.xz kea-91bab51181c8ebc89e0ee2e735cc6e851eb6b93d.zip |
[trac759] replace prints with logger messages
-rwxr-xr-x | src/bin/cfgmgr/b10-cfgmgr.py.in | 8 | ||||
-rw-r--r-- | src/lib/python/isc/config/cfgmgr.py | 12 | ||||
-rw-r--r-- | src/lib/python/isc/config/cfgmgr_messages.mes | 33 |
3 files changed, 41 insertions, 12 deletions
diff --git a/src/bin/cfgmgr/b10-cfgmgr.py.in b/src/bin/cfgmgr/b10-cfgmgr.py.in index ffb27f4324..831e5ae26a 100755 --- a/src/bin/cfgmgr/b10-cfgmgr.py.in +++ b/src/bin/cfgmgr/b10-cfgmgr.py.in @@ -28,6 +28,7 @@ import os.path import isc.log isc.log.init("b10-cfgmgr") from isc.config.cfgmgr import ConfigManager, ConfigManagerDataReadError, logger +from isc.config.cfgmgr_messages import * isc.util.process.rename() @@ -93,13 +94,12 @@ def main(): cm.notify_boss() cm.run() except SessionError as se: - print("[b10-cfgmgr] Error creating config manager, " - "is the command channel daemon running?") + logger.error(CFGMGR_CC_SESSION_ERROR, str(se)) return 1 except KeyboardInterrupt as kie: - print("[b10-cfgmgr] Interrupted, exiting") + logger.info(CFGMGR_STOPPED_BY_KEYBOARD) except ConfigManagerDataReadError as cmdre: - print("[b10-cfgmgr] " + str(cmdre)) + logger.error(CFGMGR_DATA_READ_ERROR, str(cmdre)) return 2 return 0 diff --git a/src/lib/python/isc/config/cfgmgr.py b/src/lib/python/isc/config/cfgmgr.py index d54dbc2b82..251a60fb32 100644 --- a/src/lib/python/isc/config/cfgmgr.py +++ b/src/lib/python/isc/config/cfgmgr.py @@ -32,6 +32,7 @@ from isc.config import ccsession, config_data, module_spec from isc.util.file import path_search import bind10_config import isc.log +from isc.config.cfgmgr_messages import * logger = isc.log.Logger("cfgmgr") @@ -94,7 +95,7 @@ class ConfigManagerData: elif file_config['version'] == 1: # only format change, no other changes necessary file_config['version'] = 2 - print("[b10-cfgmgr] Updating configuration database version from 1 to 2") + logger.info(CFGMGR_AUTOMATIC_CONFIG_DATABASE_UPDATE, 1, 2) config.data = file_config else: if config_data.BIND10_CONFIG_DATA_VERSION > file_config['version']: @@ -136,12 +137,9 @@ class ConfigManagerData: else: os.rename(filename, self.db_filename) except IOError as ioe: - # TODO: log this (level critical) - print("[b10-cfgmgr] Unable to write configuration file; configuration not stored: " + str(ioe)) - # TODO: debug option to keep file? + logger.error(CFGMGR_IOERROR_WHILE_WRITING_CONFIGURATION, str(ioe)) except OSError as ose: - # TODO: log this (level critical) - print("[b10-cfgmgr] Unable to write configuration file; configuration not stored: " + str(ose)) + logger.error(CFGMGR_OSERROR_WHILE_WRITING_CONFIGURATION, str(ose)) try: if filename and os.path.exists(filename): os.remove(filename) @@ -463,8 +461,6 @@ class ConfigManager: elif cmd == ccsession.COMMAND_SET_CONFIG: answer = self._handle_set_config(arg) elif cmd == ccsession.COMMAND_SHUTDOWN: - # TODO: logging - #print("[b10-cfgmgr] Received shutdown command") self.running = False answer = ccsession.create_answer(0) elif cmd == ccsession.COMMAND_MODULE_SPEC: diff --git a/src/lib/python/isc/config/cfgmgr_messages.mes b/src/lib/python/isc/config/cfgmgr_messages.mes index 6356559bbb..9355e4d976 100644 --- a/src/lib/python/isc/config/cfgmgr_messages.mes +++ b/src/lib/python/isc/config/cfgmgr_messages.mes @@ -15,3 +15,36 @@ # No namespace declaration - these constants go in the global namespace # of the xfrin messages python module. +% CFGMGR_AUTOMATIC_CONFIG_DATABASE_UPDATE Updating configuration database from version %1 to %2 +An older version of the configuration database has been found, from which +there was an automatic upgrade path to the current version. These changes +are now applied, and no action from the administrator is necessary. + +% CFGMGR_CC_SESSION_ERROR Error connecting to command channel: %1 +The configuration manager daemon was unable to connect to the messaging +system. The most likely cause is that msgq is not running. + +% CFGMGR_DATA_READ_ERROR error reading configuration database from disk: %1 +There was a problem reading the persistent configuration data as stored +on disk. The file may be corrupted, or it is of a version from where +there is no automatic upgrade path. The file needs to be repaired or +removed. The configuration manager daemon will now shut down. + +% CFGMGR_IOERROR_WHILE_WRITING_CONFIGURATION Unable to write configuration file; configuration not stored: %1 +There was an IO error from the system while the configuration manager +was trying to write the configuration database to disk. The specific +error is given. The most likely cause is that the directory where +the file is stored does not exist, or is not writable. The updated +configuration is not stored. + +% CFGMGR_OSERROR_WHILE_WRITING_CONFIGURATION Unable to write configuration file; configuration not stored: %1 +There was an OS error from the system while the configuration manager +was trying to write the configuration database to disk. The specific +error is given. The most likely cause is that the system does not have +write access to the configuration database file. The updated +configuration is not stored. + +% CFGMGR_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down +There was a keyboard interrupt signal to stop the cfgmgr daemon. The +daemon will now shut down. + |