Merge lp:~javier.collado/utah/bug1123896 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 815
Merged at revision: 818
Proposed branch: lp:~javier.collado/utah/bug1123896
Merge into: lp:utah
Diff against target: 38 lines (+11/-6)
2 files modified
utah/provisioning/provisioning.py (+5/-3)
utah/provisioning/ssh.py (+6/-3)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1123896
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Review via email: mp+148217@code.launchpad.net

Description of the change

This branch makes sure that warning messages for command failures contain the
command that failed to make sure it's clear even if log level isn't set to
debug.

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

+1 - this would have saved me about an hour yesterday :)

Revision history for this message
Max Brustkern (nuclearbob) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utah/provisioning/provisioning.py'
2--- utah/provisioning/provisioning.py 2013-02-08 16:59:00 +0000
3+++ utah/provisioning/provisioning.py 2013-02-13 15:46:26 +0000
4@@ -565,9 +565,11 @@
5 output = '\n'.join(output)
6
7 returncode = p.returncode
8- log_level = logging.DEBUG if returncode == 0 else logging.WARNING
9- log_message = 'Return code: {}'.format(returncode)
10- self.logger.log(log_level, log_message)
11+ if returncode == 0:
12+ self.logger.debug('Return code: {}'.format(returncode))
13+ else:
14+ self.logger.warning('Command ({}) failed with return code: {}'
15+ .format(' '.join(arglist), returncode))
16
17 return {'returncode': returncode,
18 'output': output}
19
20=== modified file 'utah/provisioning/ssh.py'
21--- utah/provisioning/ssh.py 2013-02-01 11:49:19 +0000
22+++ utah/provisioning/ssh.py 2013-02-13 15:46:26 +0000
23@@ -96,9 +96,12 @@
24 self.ssh_logger.debug('Closing SSH connection')
25 self.ssh_client.close()
26
27- log_level = logging.DEBUG if retval == 0 else logging.WARNING
28- log_message = 'Return code: {}'.format(retval)
29- self.ssh_logger.log(log_level, log_message)
30+ if retval == 0:
31+ self.ssh_logger.debug('Return code: {}'.format(retval))
32+ else:
33+ self.ssh_logger.warning(
34+ 'SSH command ({}) failed with return code: {}'
35+ .format(commandstring, retval))
36
37 self.ssh_logger.debug('Standard output follows:')
38 stdout_lines = stdout.readlines()

Subscribers

People subscribed via source and target branches