summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTorsten Rehn <torsten@rehn.tel>2011-10-13 12:33:08 +0200
committerTorsten Rehn <torsten@rehn.tel>2011-10-13 12:33:08 +0200
commit4982bb54895eae5e338eb67e8c6ddd1bc52396ca (patch)
treec5bba54f180fee4f1e36aba0110305543ae44e4a /src
parent5f878bfc6c6c33ffaea193502f205f86a893694f (diff)
downloadbcfg2-4982bb54895eae5e338eb67e8c6ddd1bc52396ca.tar.gz
bcfg2-4982bb54895eae5e338eb67e8c6ddd1bc52396ca.tar.bz2
bcfg2-4982bb54895eae5e338eb67e8c6ddd1bc52396ca.zip
improve error logging during LDAP query processing
This replaces the mostly useless error messages likes LdapPlugin error: list index out of range with information about which query failed and a traceback for debugging
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugins/Ldap.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lib/Server/Plugins/Ldap.py b/src/lib/Server/Plugins/Ldap.py
index 06ecaed7b..f1e2198d2 100644
--- a/src/lib/Server/Plugins/Ldap.py
+++ b/src/lib/Server/Plugins/Ldap.py
@@ -2,6 +2,7 @@ import imp
import logging
import sys
import time
+import traceback
import Bcfg2.Options
import Bcfg2.Server.Plugin
@@ -64,7 +65,7 @@ class Ldap(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Connector):
name = "Ldap"
version = "$Revision: $"
experimental = True
- debug_flag = True
+ debug_flag = False
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
@@ -76,6 +77,7 @@ class Ldap(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Connector):
self.logger.error(message)
def get_additional_data(self, metadata):
+ query = None
try:
data = {}
self.debug_log("LdapPlugin debug: found queries " +
@@ -91,13 +93,18 @@ class Ldap(Bcfg2.Server.Plugin.Plugin, Bcfg2.Server.Plugin.Connector):
"' not applicable to host '" + metadata.hostname + "'")
return data
except Exception:
- error_msg = sys.exc_info()[1]
- if self.debug_flag:
- raise
- else:
+ if hasattr(query, "name"):
+ Bcfg2.Server.Plugin.logger.error("LdapPlugin error: " +
+ "Exception during processing of query named '" +
+ str(query.name) +
+ "', query results will be empty" +
+ " and may cause bind failures")
+ for line in traceback.format_exception(sys.exc_info()[0],
+ sys.exc_info()[1],
+ sys.exc_info()[2]):
Bcfg2.Server.Plugin.logger.error("LdapPlugin error: " +
- str(error_msg))
- return {}
+ line.replace("\n", ""))
+ return {}
class LdapConnection(object):
"""