mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Updated setup(): use setuptools' console_scripts if available, else fallback to distutils' scripts. Refs #1028.
This commit is contained in:
parent
5c6b8aea28
commit
ee0072d3e8
10 changed files with 177 additions and 159 deletions
77
salt/scripts.py
Normal file
77
salt/scripts.py
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
"""Salt scripts."""
|
||||||
|
import os
|
||||||
|
|
||||||
|
import salt
|
||||||
|
import salt.cli
|
||||||
|
import salt.log
|
||||||
|
|
||||||
|
|
||||||
|
def salt_master():
|
||||||
|
'''Start the salt-master.'''
|
||||||
|
master = salt.Master()
|
||||||
|
master.start()
|
||||||
|
|
||||||
|
|
||||||
|
def salt_minion():
|
||||||
|
'''Kick off a salt minion daemon.'''
|
||||||
|
minion = salt.Minion()
|
||||||
|
minion.start()
|
||||||
|
|
||||||
|
|
||||||
|
def salt_syndic():
|
||||||
|
'''Kick off a salt syndic daemon.'''
|
||||||
|
pid = os.getpid()
|
||||||
|
try:
|
||||||
|
syndic = salt.Syndic()
|
||||||
|
syndic.start()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
os.kill(pid, 15)
|
||||||
|
|
||||||
|
|
||||||
|
def salt_key():
|
||||||
|
'''Manage the authentication keys with salt-key.'''
|
||||||
|
try:
|
||||||
|
saltkey = salt.cli.SaltKey()
|
||||||
|
saltkey.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
||||||
|
|
||||||
|
|
||||||
|
def salt_cp():
|
||||||
|
'''Publish commands to the salt system from the command line on the
|
||||||
|
master.'''
|
||||||
|
try:
|
||||||
|
cp_ = salt.cli.SaltCP()
|
||||||
|
cp_.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
||||||
|
|
||||||
|
|
||||||
|
def salt_call():
|
||||||
|
'''Directly call a salt command in the modules, does not require a running
|
||||||
|
salt minion to run.'''
|
||||||
|
salt.log.setup_console_logger()
|
||||||
|
try:
|
||||||
|
client = salt.cli.SaltCall()
|
||||||
|
client.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
||||||
|
|
||||||
|
|
||||||
|
def salt_run():
|
||||||
|
'''Execute a salt convenience routine.'''
|
||||||
|
try:
|
||||||
|
client = salt.cli.SaltRun()
|
||||||
|
client.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
||||||
|
|
||||||
|
|
||||||
|
def salt_main():
|
||||||
|
'''Publish commands to the salt system from the command line on the
|
||||||
|
master.'''
|
||||||
|
try:
|
||||||
|
client = salt.cli.SaltCMD()
|
||||||
|
client.run()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
14
scripts/salt
14
scripts/salt
|
@ -3,18 +3,8 @@
|
||||||
Publish commands to the salt system from the command line on the master.
|
Publish commands to the salt system from the command line on the master.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import salt.cli
|
from salt.scripts import salt_main
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
client = salt.cli.SaltCMD()
|
|
||||||
client.run()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
salt_main()
|
||||||
main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
|
||||||
|
|
|
@ -4,20 +4,8 @@ Directly call a salt command in the modules, does not require a running salt
|
||||||
minion to run.
|
minion to run.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import salt.cli
|
from salt.scripts import salt_call
|
||||||
import salt.log
|
|
||||||
salt.log.setup_console_logger()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
client = salt.cli.SaltCall()
|
|
||||||
client.run()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
salt_call()
|
||||||
main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
|
||||||
|
|
|
@ -3,18 +3,8 @@
|
||||||
Publish commands to the salt system from the command line on the master.
|
Publish commands to the salt system from the command line on the master.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import salt.cli
|
from salt.scripts import salt_cp
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
cp_ = salt.cli.SaltCP()
|
|
||||||
cp_.run()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
salt_cp()
|
||||||
main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
|
||||||
|
|
|
@ -3,18 +3,8 @@
|
||||||
Manage the authentication keys with salt-key
|
Manage the authentication keys with salt-key
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import salt.cli
|
from salt.scripts import salt_key
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
saltkey = salt.cli.SaltKey()
|
|
||||||
saltkey.run()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
salt_key()
|
||||||
main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
|
||||||
|
|
|
@ -3,15 +3,8 @@
|
||||||
Start the salt-master
|
Start the salt-master
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import salt
|
from salt.scripts import salt_master
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
master = salt.Master()
|
|
||||||
master.start()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
salt_master()
|
||||||
|
|
|
@ -3,16 +3,8 @@
|
||||||
This script is used to kick off a salt minion daemon
|
This script is used to kick off a salt minion daemon
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
from salt.scripts import salt_minion
|
||||||
import salt
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
minion = salt.Minion()
|
|
||||||
minion.start()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
salt_minion()
|
||||||
|
|
|
@ -3,18 +3,8 @@
|
||||||
Execute a salt convenience routine
|
Execute a salt convenience routine
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import salt.cli
|
from salt.scripts import salt_run
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
client = salt.cli.SaltRun()
|
|
||||||
client.run()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
try:
|
salt_run()
|
||||||
main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
raise SystemExit('\nExiting gracefully on Ctrl-c')
|
|
||||||
|
|
|
@ -3,20 +3,8 @@
|
||||||
This script is used to kick off a salt syndic daemon
|
This script is used to kick off a salt syndic daemon
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
from salt.scripts import salt_minion
|
||||||
import salt
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
'''
|
|
||||||
The main function
|
|
||||||
'''
|
|
||||||
pid = os.getpid()
|
|
||||||
try:
|
|
||||||
syndic = salt.Syndic()
|
|
||||||
syndic.start()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
os.kill(pid, 15)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
salt_minion()
|
||||||
|
|
148
setup.py
148
setup.py
|
@ -9,13 +9,19 @@ from __future__ import with_statement
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from distutils.core import setup, Extension
|
|
||||||
from distutils.command.sdist import sdist
|
|
||||||
from distutils.cmd import Command
|
from distutils.cmd import Command
|
||||||
from distutils.sysconfig import get_python_lib, PREFIX
|
from distutils.sysconfig import get_python_lib, PREFIX
|
||||||
|
|
||||||
if os.environ.get('VIRTUAL_ENV'):
|
# Use setuptools if available, else fallback to distutils.
|
||||||
|
# As an example, setuptools is available in virtualenvs and buildouts through
|
||||||
|
# Setuptools or Distribute.
|
||||||
|
try:
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
with_setuptools = True
|
||||||
|
except ImportError:
|
||||||
|
from distutils.core import setup
|
||||||
|
with_setuptools = False
|
||||||
|
|
||||||
|
|
||||||
exec(compile(open("salt/version.py").read(), "salt/version.py", 'exec'))
|
exec(compile(open("salt/version.py").read(), "salt/version.py", 'exec'))
|
||||||
|
|
||||||
|
@ -59,64 +65,78 @@ requirements=''
|
||||||
with open('requirements.txt') as f:
|
with open('requirements.txt') as f:
|
||||||
requirements = f.read()
|
requirements = f.read()
|
||||||
|
|
||||||
setup(
|
|
||||||
name=NAME,
|
setup_kwargs = {'name': NAME,
|
||||||
version=VER,
|
'version': VER,
|
||||||
description=DESC,
|
'description': DESC,
|
||||||
author='Thomas S Hatch',
|
'author': 'Thomas S Hatch',
|
||||||
author_email='thatch45@gmail.com',
|
'author_email': 'thatch45@gmail.com',
|
||||||
url='http://saltstack.org',
|
'url': 'http://saltstack.org',
|
||||||
cmdclass={'test': TestCommand},
|
'cmdclass': {'test': TestCommand},
|
||||||
classifiers=[
|
'classifiers': ['Programming Language :: Python',
|
||||||
'Programming Language :: Python',
|
'Programming Language :: Cython',
|
||||||
'Programming Language :: Cython',
|
'Programming Language :: Python :: 2.6',
|
||||||
'Programming Language :: Python :: 2.6',
|
'Programming Language :: Python :: 2.7',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Development Status :: 5 - Production/Stable',
|
||||||
'Development Status :: 5 - Production/Stable',
|
'Environment :: Console',
|
||||||
'Environment :: Console',
|
'Intended Audience :: Developers',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Information Technology',
|
||||||
'Intended Audience :: Information Technology',
|
'Intended Audience :: System Administrators',
|
||||||
'Intended Audience :: System Administrators',
|
'License :: OSI Approved :: Apache Software License',
|
||||||
'License :: OSI Approved :: Apache Software License',
|
'Operating System :: POSIX :: Linux',
|
||||||
'Operating System :: POSIX :: Linux',
|
'Topic :: System :: Clustering',
|
||||||
'Topic :: System :: Clustering',
|
'Topic :: System :: Distributed Computing',
|
||||||
'Topic :: System :: Distributed Computing',
|
],
|
||||||
],
|
'packages': ['salt',
|
||||||
packages=['salt',
|
'salt.cli',
|
||||||
'salt.cli',
|
'salt.ext',
|
||||||
'salt.ext',
|
'salt.grains',
|
||||||
'salt.grains',
|
'salt.modules',
|
||||||
'salt.modules',
|
'salt.renderers',
|
||||||
'salt.renderers',
|
'salt.returners',
|
||||||
'salt.returners',
|
'salt.runners',
|
||||||
'salt.runners',
|
'salt.states',
|
||||||
'salt.states',
|
'salt.utils',
|
||||||
'salt.utils',
|
],
|
||||||
],
|
'package_data': {
|
||||||
package_data = {
|
'salt.modules': ['rh_ip/*.jinja'],
|
||||||
'salt.modules': ['rh_ip/*.jinja'],
|
},
|
||||||
},
|
'data_files': [('share/man/man1',
|
||||||
scripts=['scripts/salt-master',
|
['doc/man/salt-master.1',
|
||||||
'scripts/salt-minion',
|
'doc/man/salt-key.1',
|
||||||
'scripts/salt-syndic',
|
'doc/man/salt.1',
|
||||||
'scripts/salt-key',
|
'doc/man/salt-cp.1',
|
||||||
'scripts/salt-cp',
|
'doc/man/salt-call.1',
|
||||||
'scripts/salt-call',
|
'doc/man/salt-syndic.1',
|
||||||
'scripts/salt-run',
|
'doc/man/salt-run.1',
|
||||||
'scripts/salt'],
|
'doc/man/salt-minion.1',
|
||||||
data_files=[('share/man/man1',
|
]),
|
||||||
['doc/man/salt-master.1',
|
('share/man/man7', ['doc/man/salt.7']),
|
||||||
'doc/man/salt-key.1',
|
],
|
||||||
'doc/man/salt.1',
|
'install_requires': requirements,
|
||||||
'doc/man/salt-cp.1',
|
}
|
||||||
'doc/man/salt-call.1',
|
|
||||||
'doc/man/salt-syndic.1',
|
if with_setuptools:
|
||||||
'doc/man/salt-run.1',
|
setup_kwargs['entry_points'] = {
|
||||||
'doc/man/salt-minion.1',
|
"console_scripts": [
|
||||||
]),
|
"salt-master = salt.scripts:salt_master",
|
||||||
('share/man/man7',
|
"salt-minion = salt.scripts:salt_minion",
|
||||||
['doc/man/salt.7',
|
"salt-syndic = salt.scripts:salt_syndic",
|
||||||
]),
|
"salt-key = salt.scripts:salt_key",
|
||||||
],
|
"salt-cp = salt.scripts:salt_cp",
|
||||||
install_requires=requirements,
|
"salt-call = salt.scripts:salt_call",
|
||||||
)
|
"salt-run = salt.scripts:salt_run",
|
||||||
|
"salt = salt.scripts:salt_main"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
setup_kwargs['scripts'] = ['scripts/salt-master',
|
||||||
|
'scripts/salt-minion',
|
||||||
|
'scripts/salt-syndic',
|
||||||
|
'scripts/salt-key',
|
||||||
|
'scripts/salt-cp',
|
||||||
|
'scripts/salt-call',
|
||||||
|
'scripts/salt-run',
|
||||||
|
'scripts/salt']
|
||||||
|
|
||||||
|
setup(**setup_kwargs)
|
||||||
|
|
Loading…
Add table
Reference in a new issue