Skip to content

Commit 1696658

Browse files
author
Dan
committed
Moving environment updates to feature branch
1 parent 495b777 commit 1696658

File tree

3 files changed

+7
-27
lines changed

3 files changed

+7
-27
lines changed

pssh/pssh_client.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ def __init__(self, hosts,
336336
self.channel_timeout = channel_timeout
337337

338338
def run_command(self, command, sudo=False, user=None, stop_on_errors=True,
339-
shell=None, use_shell=True, use_pty=True, host_args=None,
340-
environment=None):
339+
shell=None, use_shell=True, use_pty=True, host_args=None):
341340
"""Run command on all hosts in parallel, honoring self.pool_size,
342341
and return output buffers.
343342
@@ -384,10 +383,6 @@ def run_command(self, command, sudo=False, user=None, stop_on_errors=True,
384383
host list - :py:class:`pssh.exceptions.HostArgumentException` is raised \
385384
otherwise
386385
:type host_args: tuple or list
387-
:param environment: (Optional) Environment variables to be exposed to \
388-
command to be run. This requires that ``AcceptEnv`` server setting \
389-
is enabled - variables will silently not be set otherwise
390-
:type environment: dict
391386
392387
:rtype: Dictionary with host as key and \
393388
:py:class:`pssh.output.HostOutput` as value as per \
@@ -630,8 +625,7 @@ def run_command(self, command, sudo=False, user=None, stop_on_errors=True,
630625
cmds = [self.pool.spawn(self._exec_command, host,
631626
command % host_args[host_i],
632627
sudo=sudo, user=user, shell=shell,
633-
use_shell=use_shell, use_pty=use_pty,
634-
environment=environment)
628+
use_shell=use_shell, use_pty=use_pty)
635629
for host_i, host in enumerate(self.hosts)]
636630
except IndexError:
637631
raise HostArgumentException(
@@ -641,8 +635,7 @@ def run_command(self, command, sudo=False, user=None, stop_on_errors=True,
641635
cmds = [self.pool.spawn(
642636
self._exec_command, host, command,
643637
sudo=sudo, user=user, shell=shell,
644-
use_shell=use_shell, use_pty=use_pty,
645-
environment=environment)
638+
use_shell=use_shell, use_pty=use_pty)
646639
for host in self.hosts]
647640
for cmd in cmds:
648641
try:
@@ -660,8 +653,7 @@ def _get_host_config_values(self, host):
660653
return _user, _port, _password, _pkey
661654

662655
def _exec_command(self, host, command, sudo=False, user=None,
663-
shell=None, use_shell=True, use_pty=True,
664-
environment=None):
656+
shell=None, use_shell=True, use_pty=True):
665657
"""Make SSHClient, run command on host"""
666658
if host not in self.host_clients or self.host_clients[host] is None:
667659
_user, _port, _password, _pkey = self._get_host_config_values(host)
@@ -682,7 +674,7 @@ def _exec_command(self, host, command, sudo=False, user=None,
682674
channel_timeout=self.channel_timeout)
683675
return self.host_clients[host].exec_command(
684676
command, sudo=sudo, user=user, shell=shell,
685-
use_shell=use_shell, use_pty=use_pty, environment=environment)
677+
use_shell=use_shell, use_pty=use_pty)
686678

687679
def get_output(self, cmd, output):
688680
"""Get output from command.

pssh/ssh_client.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,13 @@ def _connect(self, client, host, port, sock=None, retries=1,
202202

203203
def exec_command(self, command, sudo=False, user=None,
204204
shell=None,
205-
use_shell=True, use_pty=True,
206-
environment=None):
205+
use_shell=True, use_pty=True):
207206
"""Wrapper to :py:func:`paramiko.SSHClient.exec_command`
208207
209208
Opens a new SSH session with a new pty and runs command before yielding
210209
the main gevent loop to allow other greenlets to execute.
211210
212-
:param command: Cxommand to execute
211+
:param command: Command to execute
213212
:type command: str
214213
:param sudo: (Optional) Run with sudo. Defaults to False
215214
:type sudo: bool
@@ -241,8 +240,6 @@ def exec_command(self, command, sudo=False, user=None,
241240
channel.get_pty()
242241
if self.channel_timeout:
243242
channel.settimeout(self.channel_timeout)
244-
if environment:
245-
channel.update_environment(environment)
246243
stdout, stderr, stdin = channel.makefile('rb'), \
247244
channel.makefile_stderr('rb'), channel.makefile('wb')
248245
for _char in ['\\', '"', '$', '`']:

tests/test_pssh_client.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,14 +1014,5 @@ def test_run_command_no_shell(self):
10141014
self.assertTrue(len(stdout) > 0)
10151015
self.assertTrue(output[self.host].exit_code == 0)
10161016

1017-
def test_run_command_environment(self):
1018-
env = {'ENV_VARIABLE': 'env value'}
1019-
output = self.client.run_command('echo ${ENV_VARIABLE}',
1020-
environment=env)
1021-
self.client.join(output)
1022-
stdout = list(output[self.host].stdout)
1023-
expected = [env.values()[0]]
1024-
self.assertEqual(stdout, expected)
1025-
10261017
if __name__ == '__main__':
10271018
unittest.main()

0 commit comments

Comments
 (0)