Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
91bab511
Commit
91bab511
authored
Jun 27, 2011
by
Jelte Jansen
Browse files
[trac759] replace prints with logger messages
parent
55c3df5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/bin/cfgmgr/b10-cfgmgr.py.in
View file @
91bab511
...
...
@@ -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
...
...
src/lib/python/isc/config/cfgmgr.py
View file @
91bab511
...
...
@@ -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
:
...
...
src/lib/python/isc/config/cfgmgr_messages.mes
View file @
91bab511
...
...
@@ -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.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment