mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 18:50:38 +03:00
Improved logging of plugins
This commit is contained in:
parent
3e2e90be5b
commit
18aae2995b
@ -24,6 +24,9 @@ def info_code(code):
|
||||
info_ids[4] = 'Initializing Samba backend for domain'
|
||||
info_ids[5] = 'Initializing local backend without domain'
|
||||
info_ids[6] = 'Cache directory determined'
|
||||
info_ids[7] = 'Initializing plugin manager'
|
||||
info_ids[8] = 'ADP plugin initialized'
|
||||
info_ids[9] = 'Running ADP plugin'
|
||||
|
||||
return info_ids.get(code, 'Unknown info code')
|
||||
|
||||
@ -37,6 +40,7 @@ def error_code(code):
|
||||
error_ids[6] = 'Error running GPOA for user'
|
||||
error_ids[7] = 'Unable to initialize Samba backend'
|
||||
error_ids[8] = 'Unable to initialize no-domain backend'
|
||||
error_ids[9] = 'Error running ADP'
|
||||
|
||||
return error_ids.get(code, 'Unknown error code')
|
||||
|
||||
@ -59,6 +63,7 @@ def warning_code(code):
|
||||
)
|
||||
warning_ids[3] = 'oddjobd is inaccessible'
|
||||
warning_ids[4] = 'No SYSVOL entry assigned to GPO'
|
||||
warning_ids[5] = 'ADP package is not installed - plugin will not be initialized'
|
||||
|
||||
return warning_ids.get(code, 'Unknown warning code')
|
||||
|
||||
|
@ -22,19 +22,20 @@ import subprocess
|
||||
from util.rpm import is_rpm_installed
|
||||
from .exceptions import PluginInitError
|
||||
from util.logging import slogm
|
||||
from messages import message_with_code
|
||||
|
||||
class adp:
|
||||
def __init__(self):
|
||||
if not is_rpm_installed('adp'):
|
||||
raise PluginInitError('adp is not installed - plugin cannot be initialized')
|
||||
logging.info(slogm('ADP plugin initialized'))
|
||||
raise PluginInitError(message_with_code('W5'))
|
||||
logging.info(slogm(message_with_code('I8')))
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
logging.info('Running ADP plugin')
|
||||
logging.info(slogm(message_with_code('I9')))
|
||||
subprocess.call(['/usr/bin/adp', 'fetch'])
|
||||
subprocess.call(['/usr/bin/adp', 'apply'])
|
||||
except Exception as exc:
|
||||
logging.error(slogm('Error running ADP'))
|
||||
logging.error(slogm(message_with_code('E9')))
|
||||
raise exc
|
||||
|
||||
|
@ -23,15 +23,16 @@ from .roles import roles
|
||||
from .exceptions import PluginInitError
|
||||
from .plugin import plugin
|
||||
from util.logging import slogm
|
||||
from messages import message_with_code
|
||||
|
||||
class plugin_manager:
|
||||
def __init__(self):
|
||||
self.plugins = dict()
|
||||
logging.info(slogm('Starting plugin manager'))
|
||||
logging.info(slogm(message_with_code('I7')))
|
||||
try:
|
||||
self.plugins['adp'] = adp()
|
||||
except PluginInitError as exc:
|
||||
logging.error(slogm(exc))
|
||||
logging.warning(slogm(str(exc)))
|
||||
|
||||
def run(self):
|
||||
self.plugins.get('adp', plugin('adp')).run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user