Merge lp:~hopem/maas-deployer/lp1493765 into lp:~maas-deployers/maas-deployer/next

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 34
Proposed branch: lp:~hopem/maas-deployer/lp1493765
Merge into: lp:~maas-deployers/maas-deployer/next
Diff against target: 74 lines (+21/-4)
2 files modified
maas_deployer/vmaas/maasclient/clidriver.py (+19/-2)
maas_deployer/vmaas/util.py (+2/-2)
To merge this branch: bzr merge lp:~hopem/maas-deployer/lp1493765
Reviewer Review Type Date Requested Status
Billy Olsen Approve
Review via email: mp+270706@code.launchpad.net
To post a comment you must log in.
lp:~hopem/maas-deployer/lp1493765 updated
33. By Edward Hope-Morley

logging cleanup

Revision history for this message
Billy Olsen (billy-olsen) wrote :

LGTM, Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'maas_deployer/vmaas/maasclient/clidriver.py'
2--- maas_deployer/vmaas/maasclient/clidriver.py 2015-09-01 23:15:07 +0000
3+++ maas_deployer/vmaas/maasclient/clidriver.py 2015-09-10 16:05:07 +0000
4@@ -35,6 +35,14 @@
5 def _get_base_command(self):
6 return ['maas', 'maas']
7
8+ @property
9+ def cmd_stdin(self):
10+ """String to be provided as stdin when executing commands.
11+
12+ If nothing required, always return None.
13+ """
14+ return None
15+
16 def _maas_execute(self, cmd, *args, **kwargs):
17 """
18 Executes the specified subcommand. The keyword maas and the profile
19@@ -54,7 +62,8 @@
20 cmdarr.append("%s='%s'" % (key, str(v)))
21 else:
22 cmdarr.append("%s='%s'" % (key, str(value)))
23- stdout = execc(cmdarr)[0]
24+
25+ stdout = execc(cmdarr, stdin=self.cmd_stdin)[0]
26
27 display_stdout = stdout
28 if display_stdout and len(display_stdout) > 100:
29@@ -320,6 +329,14 @@
30 super(SSHDriver, self).__init__(api_url, api_key)
31 self._login(api_url, api_key)
32
33+ @property
34+ def cmd_stdin(self):
35+ """Space-separated list of environment variables.
36+
37+ If no env vars required, always return None.
38+ """
39+ return 'LC_ALL=C'
40+
41 def _login(self, api_url, api_key):
42 cmd = ['ssh', '-i', os.path.expanduser('~/.ssh/id_maas'),
43 '-o', 'UserKnownHostsFile=/dev/null',
44@@ -327,7 +344,7 @@
45 '-o', 'LogLevel=quiet',
46 '{}@{}'.format(self.ssh_user, self.maas_ip),
47 'maas', 'login', 'maas', api_url, api_key]
48- execc(cmd)
49+ execc(cmd, stdin=self.cmd_stdin)
50
51 def _get_base_command(self):
52 cmd = ['ssh', '-i', os.path.expanduser('~/.ssh/id_maas'),
53
54=== modified file 'maas_deployer/vmaas/util.py'
55--- maas_deployer/vmaas/util.py 2015-08-14 09:16:18 +0000
56+++ maas_deployer/vmaas/util.py 2015-09-10 16:05:07 +0000
57@@ -53,7 +53,7 @@
58 _input = None
59
60 # Abridge stdin for log if provided
61- _stdin = None
62+ _stdin = ''
63 if stdin:
64 _stdin = stdin
65 if type(stdin) == file:
66@@ -62,7 +62,7 @@
67 if len(_stdin) > 10:
68 _stdin = "'%s...'" % _stdin[:10]
69
70- log.debug("Executing: '%s' stdin=%s", ' '.join(cmd), _stdin)
71+ log.debug("Executing: '%s' stdin='%s'", ' '.join(cmd), _stdin)
72
73 if stdin:
74 if type(stdin) == file:

Subscribers

People subscribed via source and target branches