Merge pull request #12656 from cachedout/salt-ssh-tweaking

salt-ssh tweaking
This commit is contained in:
Thomas S Hatch 2014-05-09 11:38:39 -06:00
commit abeb3731ca
2 changed files with 12 additions and 4 deletions

View File

@ -127,10 +127,10 @@ main()
if "$py_cmd" -c 'import sys; sys.exit(not sys.hexversion >= 0x02060000);' >/dev/null 2>&1; then
local py_cmd_path
py_cmd_path=`"$py_cmd" -c 'import sys; print sys.executable;'`
echo "FOUND: $py_cmd_path" >&2
exec $SUDO "$py_cmd_path" -c 'exec """{{SSH_PY_CODE}}""".decode("base64")' -- {{SSH_PY_ARGS}}
exit 0
else
echo "WARNING: $py_cmd not found or too old" >&2
continue
fi
done
@ -182,7 +182,10 @@ class SSH(object):
)
)
if not os.path.isfile(priv):
salt.client.ssh.shell.gen_key(priv)
try:
salt.client.ssh.shell.gen_key(priv)
except OSError:
raise salt.exceptions.SaltClientError('salt-ssh could not be run because it could not generate keys.\n\nYou can probably resolve this by executing this script with increased permissions via sudo or by running as root.\nYou could also use the \'-c\' option to supply a configuration directory that you have permissions to read and write to.')
self.defaults = {
'user': self.opts.get(
'ssh_user',
@ -341,6 +344,8 @@ class SSH(object):
returned = set()
rets = set()
init = False
if not self.targets:
raise salt.exceptions.SaltClientError('No matching targets found in roster.')
while True:
if len(running) < self.opts.get('ssh_max_procs', 25) and not init:
try:
@ -721,7 +726,7 @@ class Single(object):
else:
# RSTR was found in stdout but not stderr - which means there
# is a SHIM command for the master.
shim_command = re.split(r'\r?\n', stdout, 1)[0].strip()
shim_command = re.split(r'\r?\n', stdout, 1)[1].strip()
if 'deploy' == shim_command and retcode == salt.exitcodes.EX_THIN_DEPLOY:
self.deploy()
stdout, stderr, retcode = self.shell.exec_cmd(cmd_str)

View File

@ -11,6 +11,7 @@ import time
# Import salt libs
import salt
import salt.exceptions
import salt.cli
try:
import salt.cloud.cli
@ -121,6 +122,8 @@ def salt_ssh():
client.run()
except KeyboardInterrupt:
raise SystemExit('\nExiting gracefully on Ctrl-c')
except salt.exceptions.SaltClientError as err:
raise SystemExit(err)
def salt_cloud():