Skip to content

Commit

Permalink
send bastion parameter through to paramiko ssh client
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Mielke committed Jun 15, 2016
1 parent aa3fa3e commit e368323
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ in development
functionality (file upload, directory upload, etc.) is not used. (improvement)
Reported by Cody A. Ray
* API and CLI allow rules to be filtered by their enable state. (improvement)
* Fix SSH bastion host support by ensuring the bastion parameter is passed to the paramiko ssh
client. (bug-fix) #2543 [Adam Mielke]

1.4.0 - April 18, 2016
----------------------
Expand Down
1 change: 1 addition & 0 deletions st2actions/st2actions/runners/ssh/parallel_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def _connect(self, host, results, raise_on_any_error=False):

client = ParamikoSSHClient(hostname, username=self._ssh_user,
password=self._ssh_password,
bastion_host=self._bastion_host,
key_files=self._ssh_key_file,
key_material=self._ssh_key_material,
passphrase=self._passphrase,
Expand Down
14 changes: 14 additions & 0 deletions st2actions/tests/unit/test_parallel_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ def test_connect_with_key(self):
expected_conn['port'] = port
client._hosts_client[hostname].client.connect.assert_called_once_with(**expected_conn)

@patch('paramiko.SSHClient', Mock)
def test_connect_with_bastion(self):
hosts = ['localhost', '127.0.0.1']
client = ParallelSSHClient(hosts=hosts,
user='ubuntu',
pkey_file='~/.ssh/id_rsa',
bastion_host='testing_bastion_host',
connect=False)
client.connect()

for host in hosts:
hostname, _ = client._get_host_port_info(host)
self.assertEqual(client._hosts_client[hostname].bastion_host, 'testing_bastion_host')

@patch('paramiko.SSHClient', Mock)
@patch.object(ParamikoSSHClient, 'run', MagicMock(return_value=('/home/ubuntu', '', 0)))
def test_run_command(self):
Expand Down

0 comments on commit e368323

Please sign in to comment.