Fix SSH client exception if SSH is not found

When no SSH client is installed, salt will create an empty
SaltSystemExit exception:

Traceback (most recent call last):
  File "tests/unit/ssh/test_ssh.py", line 42, in test_password_failure
    client = ssh.SSH(opts)
  File "salt/client/ssh/__init__.py", line 226, in __init__
    raise salt.exceptions.SaltSystemExit('No ssh binary found in path -- ssh must be '
salt.exceptions.SaltSystemExit: None

The SaltSystemExit exception takes two parameters: code and msg.

Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
This commit is contained in:
Benjamin Drung 2018-03-07 15:10:03 +01:00
parent ca28cfd4e4
commit e48c13d9e0

View file

@ -220,7 +220,8 @@ class SSH(object):
if self.opts['regen_thin']:
self.opts['ssh_wipe'] = True
if not salt.utils.which('ssh'):
raise salt.exceptions.SaltSystemExit('No ssh binary found in path -- ssh must be installed for salt-ssh to run. Exiting.')
raise salt.exceptions.SaltSystemExit(code=-1,
msg='No ssh binary found in path -- ssh must be installed for salt-ssh to run. Exiting.')
self.opts['_ssh_version'] = ssh_version()
self.tgt_type = self.opts['selected_target_option'] \
if self.opts['selected_target_option'] else 'glob'