/usr/bin/salt-run
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'salt==2014.7.0','console_scripts','salt-run'
__requires__ = 'salt==2014.7.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('salt==2014.7.0', 'console_scripts', 'salt-run')()
)
/usr/lib/python2.6/site-packages/salt/scripts.py
def salt_run():
'''
Execute a salt convenience routine.
'''
if '' in sys.path:
sys.path.remove('')
client = None
try:
client = salt.cli.SaltRun()
client.run()
except KeyboardInterrupt, err:
trace = traceback.format_exc()
try:
hardcrash = client.options.hard_crash
except (AttributeError, KeyError):
hardcrash = False
_handle_interrupt(
SystemExit('\nExiting gracefully on Ctrl-c'),
err,
hardcrash, trace=trace)
/usr/lib/python2.6/site-packages/salt/cli/__init__.py
class SaltRun(parsers.SaltRunOptionParser):
'''
Used to execute Salt runners
'''
def run(self):
'''
Execute salt-run
'''
self.parse_args()
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
if not self.config['log_file'].startswith(('tcp://',
'udp://',
'file://')):
# Logfile is not using Syslog, verify
verify_files(
[self.config['log_file']],
self.config['user']
)
# Setup file logging!
self.setup_logfile_logger()
runner = salt.runner.Runner(self.config)
if self.options.doc:
runner._print_docs()
self.exit(os.EX_OK)
# Run this here so SystemExit isn't raised anywhere else when
# someone tries to use the runners via the python API
try:
if check_user(self.config['user']):
runner.run()
except SaltClientError as exc:
raise SystemExit(str(exc))
转载于:https://blog.51cto.com/john88wang/1656250