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
=== modified file 'maas_deployer/vmaas/maasclient/clidriver.py'
--- maas_deployer/vmaas/maasclient/clidriver.py 2015-09-01 23:15:07 +0000
+++ maas_deployer/vmaas/maasclient/clidriver.py 2015-09-10 16:05:07 +0000
@@ -35,6 +35,14 @@
35 def _get_base_command(self):35 def _get_base_command(self):
36 return ['maas', 'maas']36 return ['maas', 'maas']
3737
38 @property
39 def cmd_stdin(self):
40 """String to be provided as stdin when executing commands.
41
42 If nothing required, always return None.
43 """
44 return None
45
38 def _maas_execute(self, cmd, *args, **kwargs):46 def _maas_execute(self, cmd, *args, **kwargs):
39 """47 """
40 Executes the specified subcommand. The keyword maas and the profile48 Executes the specified subcommand. The keyword maas and the profile
@@ -54,7 +62,8 @@
54 cmdarr.append("%s='%s'" % (key, str(v)))62 cmdarr.append("%s='%s'" % (key, str(v)))
55 else:63 else:
56 cmdarr.append("%s='%s'" % (key, str(value)))64 cmdarr.append("%s='%s'" % (key, str(value)))
57 stdout = execc(cmdarr)[0]65
66 stdout = execc(cmdarr, stdin=self.cmd_stdin)[0]
5867
59 display_stdout = stdout68 display_stdout = stdout
60 if display_stdout and len(display_stdout) > 100:69 if display_stdout and len(display_stdout) > 100:
@@ -320,6 +329,14 @@
320 super(SSHDriver, self).__init__(api_url, api_key)329 super(SSHDriver, self).__init__(api_url, api_key)
321 self._login(api_url, api_key)330 self._login(api_url, api_key)
322331
332 @property
333 def cmd_stdin(self):
334 """Space-separated list of environment variables.
335
336 If no env vars required, always return None.
337 """
338 return 'LC_ALL=C'
339
323 def _login(self, api_url, api_key):340 def _login(self, api_url, api_key):
324 cmd = ['ssh', '-i', os.path.expanduser('~/.ssh/id_maas'),341 cmd = ['ssh', '-i', os.path.expanduser('~/.ssh/id_maas'),
325 '-o', 'UserKnownHostsFile=/dev/null',342 '-o', 'UserKnownHostsFile=/dev/null',
@@ -327,7 +344,7 @@
327 '-o', 'LogLevel=quiet',344 '-o', 'LogLevel=quiet',
328 '{}@{}'.format(self.ssh_user, self.maas_ip),345 '{}@{}'.format(self.ssh_user, self.maas_ip),
329 'maas', 'login', 'maas', api_url, api_key]346 'maas', 'login', 'maas', api_url, api_key]
330 execc(cmd)347 execc(cmd, stdin=self.cmd_stdin)
331348
332 def _get_base_command(self):349 def _get_base_command(self):
333 cmd = ['ssh', '-i', os.path.expanduser('~/.ssh/id_maas'),350 cmd = ['ssh', '-i', os.path.expanduser('~/.ssh/id_maas'),
334351
=== modified file 'maas_deployer/vmaas/util.py'
--- maas_deployer/vmaas/util.py 2015-08-14 09:16:18 +0000
+++ maas_deployer/vmaas/util.py 2015-09-10 16:05:07 +0000
@@ -53,7 +53,7 @@
53 _input = None53 _input = None
5454
55 # Abridge stdin for log if provided55 # Abridge stdin for log if provided
56 _stdin = None56 _stdin = ''
57 if stdin:57 if stdin:
58 _stdin = stdin58 _stdin = stdin
59 if type(stdin) == file:59 if type(stdin) == file:
@@ -62,7 +62,7 @@
62 if len(_stdin) > 10:62 if len(_stdin) > 10:
63 _stdin = "'%s...'" % _stdin[:10]63 _stdin = "'%s...'" % _stdin[:10]
6464
65 log.debug("Executing: '%s' stdin=%s", ' '.join(cmd), _stdin)65 log.debug("Executing: '%s' stdin='%s'", ' '.join(cmd), _stdin)
6666
67 if stdin:67 if stdin:
68 if type(stdin) == file:68 if type(stdin) == file:

Subscribers

People subscribed via source and target branches