Merge pull request #19633 from ether42/develop

lxc module: kwarg shadowing in run_cmd provokes unexpected return value
This commit is contained in:
Thomas S Hatch 2015-01-12 12:04:54 -07:00
commit 8d45f147bf

View File

@ -2138,7 +2138,7 @@ def run_cmd(name, cmd, no_start=False, preserve_state=True,
if not use_vt: if not use_vt:
res = __salt__['cmd.run_all'](cmd) res = __salt__['cmd.run_all'](cmd)
else: else:
stdout, stderr = '', '' stdout_buffer, stderr_buffer = '', ''
try: try:
proc = vt.Terminal(cmd, proc = vt.Terminal(cmd,
shell=True, shell=True,
@ -2158,26 +2158,26 @@ def run_cmd(name, cmd, no_start=False, preserve_state=True,
except IOError: except IOError:
cstdout, cstderr = '', '' cstdout, cstderr = '', ''
if cstdout: if cstdout:
stdout += cstdout stdout_buffer += cstdout
else: else:
cstdout = '' cstdout = ''
if cstderr: if cstderr:
stderr += cstderr stderr_buffer += cstderr
else: else:
cstderr = '' cstderr = ''
except KeyboardInterrupt: except KeyboardInterrupt:
break break
res = {'retcode': proc.exitstatus, res = {'retcode': proc.exitstatus,
'pid': 2, 'pid': 2,
'stdout': stdout, 'stdout': stdout_buffer,
'stderr': stderr} 'stderr': stderr_buffer}
except vt.TerminalException: except vt.TerminalException:
trace = traceback.format_exc() trace = traceback.format_exc()
log.error(trace) log.error(trace)
res = {'retcode': 127, res = {'retcode': 127,
'pid': '2', 'pid': '2',
'stdout': stdout, 'stdout': stdout_buffer,
'stderr': stderr} 'stderr': stderr_buffer}
finally: finally:
proc.close(terminate=True, kill=True) proc.close(terminate=True, kill=True)
else: else: