Enhance logging around image building

Currently when the scripts doing the image-building fail, there is
nothing of note put into the publicly-available log files
(i.e. those published at nodepool.openstack.org).  The exception gets
raised and goes back to the main log file but doesn't leave anything
in the build log file.

This means there is no way to effectively monitor the status of a
image build externally, other than making guesses about what should be
at the end of the last-running script.

This provides some standard sentinel values around script running that
can be used to quickly verify the success or failure of scripts.

Change-Id: I54db78b028017500b58693ec717c23eaf6a220b6
This commit is contained in:
Ian Wienand
2015-06-12 11:20:23 +10:00
parent da80841ed8
commit db91bb9ba9

View File

@@ -33,7 +33,8 @@ class SSHClient(object):
def ssh(self, action, command, get_pty=True, output=False):
if self.log:
self.log.info(command)
self.log.debug("*** START to %s" % action)
self.log.debug("executing: %s" % command)
stdin, stdout, stderr = self.client.exec_command(
command, get_pty=get_pty)
out = ''
@@ -50,9 +51,13 @@ class SSHClient(object):
self.log.error(line.rstrip())
ret = stdout.channel.recv_exit_status()
if ret:
if self.log:
self.log.debug("*** FAILED to %s (%s)" % (action, ret))
raise Exception(
"Unable to %s\ncommand: %s\nstdout: %s\nstderr: %s"
% (action, command, out, err))
if self.log:
self.log.debug("*** SUCCESSFULLY %s" % action)
return out
def scp(self, source, dest):