summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-04-18 13:07:35 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-04-18 13:07:43 -0400
commitfb63e457428f5bb91e5e80be40f5ac166d712d50 (patch)
tree05e0d8e88410c629461111ebd4f6976519b14120 /src
parent918382284bb0195ab01ff470c4e4a016bc8aad87 (diff)
downloadbcfg2-fb63e457428f5bb91e5e80be40f5ac166d712d50.tar.gz
bcfg2-fb63e457428f5bb91e5e80be40f5ac166d712d50.tar.bz2
bcfg2-fb63e457428f5bb91e5e80be40f5ac166d712d50.zip
better error reporting
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg.py62
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py3
2 files changed, 38 insertions, 27 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg.py b/src/lib/Bcfg2/Server/Plugins/Cfg.py
index 8ec31bbae..81904d082 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg.py
@@ -119,8 +119,9 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
base_files = [matching.index(m) for m in matching
if not m.specific.delta]
if not base_files:
- logger.error("No base file found for %s" % entry.get('name'))
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "No base file found for %s" % entry.get('name')
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
base = min(base_files)
used = matching[:base + 1]
used.reverse()
@@ -132,15 +133,16 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
basefile = used.pop(0)
if entry.get('perms').lower() == 'inherit':
# use on-disk permissions
- fname = "%s/%s" % (self.path, entry.get('name'))
+ fname = os.path.join(self.path, entry.get('name'))
entry.set('perms',
str(oct(stat.S_IMODE(os.stat(fname).st_mode))))
if entry.tag == 'Path':
entry.set('type', 'file')
if basefile.name.endswith(".genshi"):
if not have_genshi:
- logger.error("Cfg: Genshi is not available")
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "Cfg: Genshi is not available: %s" % entry.get("name")
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
try:
template_cls = NewTextTemplate
loader = TemplateLoader()
@@ -158,13 +160,15 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
if data == '':
entry.set('empty', 'true')
except Exception:
- e = sys.exc_info()[1]
- logger.error("Cfg: genshi exception: %s" % e)
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "Cfg: genshi exception (%s): %s" % (entry.get("name"),
+ sys.exc_info()[1])
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
elif basefile.name.endswith(".cheetah"):
if not have_cheetah:
- logger.error("Cfg: Cheetah is not available")
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "Cfg: Cheetah is not available: %s" % entry.get("name")
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
try:
fname = entry.get('realname', entry.get('name'))
s = {'useStackFrames': False}
@@ -177,9 +181,10 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
if data == '':
entry.set('empty', 'true')
except Exception:
- e = sys.exc_info()[1]
- logger.error("Cfg: cheetah exception: %s" % e)
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "Cfg: cheetah exception (%s): %s" % (entry.get("name"),
+ sys.exc_info()[1])
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
else:
data = basefile.data
for delta in used:
@@ -190,17 +195,18 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
try:
entry.text = u_str(data, self.encoding)
except UnicodeDecodeError:
- e = sys.exc_info()[1]
- logger.error("Failed to decode %s: %s" % (entry.get('name'), e))
+ msg = "Failed to decode %s: %s" % (entry.get('name'),
+ sys.exc_info()[1])
+ logger.error(msg)
logger.error("Please verify you are using the proper encoding.")
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
except ValueError:
- e = sys.exc_info()[1]
- logger.error("Error in specification for %s" % entry.get('name'))
- logger.error("%s" % e)
+ msg = "Error in specification for %s: %s" % (entry.get('name'),
+ sys.exc_info()[1])
+ logger.error(msg)
logger.error("You need to specify base64 encoding for %s." %
entry.get('name'))
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
if entry.text in ['', None]:
entry.set('empty', 'true')
@@ -227,16 +233,20 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
if 'text' in new_entry:
name = self.build_filename(specific)
if os.path.exists("%s.genshi" % name):
- logger.error("Cfg: Unable to pull data for genshi types")
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "Cfg: Unable to pull data for genshi types"
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
elif os.path.exists("%s.cheetah" % name):
- logger.error("Cfg: Unable to pull data for cheetah types")
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "Cfg: Unable to pull data for cheetah types"
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
try:
etext = new_entry['text'].encode(self.encoding)
except:
- logger.error("Cfg: Cannot encode content of %s as %s" % (name, self.encoding))
- raise Bcfg2.Server.Plugin.PluginExecutionError
+ msg = "Cfg: Cannot encode content of %s as %s" % (name,
+ self.encoding)
+ logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
open(name, 'w').write(etext)
self.debug_log("Wrote file %s" % name, flag=log)
badattr = [attr for attr in ['owner', 'group', 'perms']
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index 5ba4de12f..970126b80 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -796,7 +796,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
try:
groups_tree.xinclude()
except lxml.etree.XIncludeError:
- self.logger.error("Failed to process XInclude for file %s" % dest)
+ self.logger.error("Failed to process XInclude for file %s: %s" %
+ (dest, sys.exc_info()[1]))
groups = groups_tree.getroot()
categories = {'default': 'grey83'}
viz_str = []