Commit f362096f authored by Iustin Pop's avatar Iustin Pop
Browse files

Make utils.RunCmd log failures when using debug

This patch adds logging of command failures to the debug log in case the
user either started the command (gnt-*) or the node daemon with the
debug flag.

Reviewed-by: imsnah
parent 037da795
......@@ -519,6 +519,7 @@ def main():
options, args = ParseOptions()
utils.debug = options.debug
for fname in (constants.SSL_CERT_FILE,):
if not os.path.isfile(fname):
print "config %s not there, will not run." % fname
......@@ -453,6 +453,7 @@ def GenericMain(commands, override=None):
logger.SetupLogging(debug=options.debug, program=binary)
utils.debug = options.debug
utils.Lock('cmd', max_retries=options.lock_retries, debug=options.debug)
except errors.LockError, err:
......@@ -44,6 +44,8 @@ from ganeti import errors
_locksheld = []
_re_shell_unquoted = re.compile('^[-.,=:/_+@A-Za-z0-9]+$')
debug = False
class RunResult(object):
"""Simple class for holding the result of running external programs.
......@@ -78,6 +80,10 @@ class RunResult(object):
self.fail_reason = "unable to determine termination reason"
if debug and self.failed:
logger.Debug("Command '%s' failed (%s); output: %s" %
(self.cmd, self.fail_reason, self.output))
def _GetOutput(self):
"""Returns the combined stdout and stderr for easier usage.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment