mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #8527 from s0undt3ch/hotfix/merge-salt-cloud-setup
Migrate salt-cloud setup features to salt
This commit is contained in:
commit
cfa3ba3d48
3 changed files with 143 additions and 213 deletions
|
@ -17,7 +17,7 @@
|
|||
# CREATED: 10/15/2012 09:49:37 PM WEST
|
||||
#===============================================================================
|
||||
set -o nounset # Treat unset variables as an error
|
||||
__ScriptVersion="1.5.8"
|
||||
__ScriptVersion="1.5.9"
|
||||
__ScriptName="bootstrap-salt.sh"
|
||||
|
||||
#===============================================================================
|
||||
|
@ -133,6 +133,7 @@ usage() {
|
|||
$ ${__ScriptName} daily
|
||||
$ ${__ScriptName} git
|
||||
$ ${__ScriptName} git develop
|
||||
$ ${__ScriptName} git v0.17.0
|
||||
$ ${__ScriptName} git 8c3fadf15ec183e5ce8c63739850d543617e4357
|
||||
|
||||
Options:
|
||||
|
@ -146,6 +147,7 @@ usage() {
|
|||
-M Also install salt-master
|
||||
-S Also install salt-syndic
|
||||
-N Do not install salt-minion
|
||||
-X Do not start daemons after installation
|
||||
-C Only run the configuration function. This option automatically
|
||||
bypasses any installation.
|
||||
-P Allow pip based installations. On some distributions the required salt
|
||||
|
@ -229,6 +231,7 @@ _TEMP_KEYS_DIR="null"
|
|||
_INSTALL_MASTER=$BS_FALSE
|
||||
_INSTALL_SYNDIC=$BS_FALSE
|
||||
_INSTALL_MINION=$BS_TRUE
|
||||
_START_DAEMONS=$BS_TRUE
|
||||
_ECHO_DEBUG=${BS_ECHO_DEBUG:-$BS_FALSE}
|
||||
_CONFIG_ONLY=$BS_FALSE
|
||||
_PIP_ALLOWED=${BS_PIP_ALLOWED:-$BS_FALSE}
|
||||
|
@ -241,7 +244,7 @@ _UPGRADE_SYS=${BS_UPGRADE_SYS:-$BS_FALSE}
|
|||
# __SIMPLIFY_VERSION is mostly used in Solaris based distributions
|
||||
__SIMPLIFY_VERSION=$BS_TRUE
|
||||
|
||||
while getopts ":hvnDc:k:MSNCPFUK" opt
|
||||
while getopts ":hvnDc:k:MSNXCPFUK" opt
|
||||
do
|
||||
case "${opt}" in
|
||||
|
||||
|
@ -271,6 +274,7 @@ do
|
|||
M ) _INSTALL_MASTER=$BS_TRUE ;;
|
||||
S ) _INSTALL_SYNDIC=$BS_TRUE ;;
|
||||
N ) _INSTALL_MINION=$BS_FALSE ;;
|
||||
X ) _START_DAEMONS=$BS_FALSE ;;
|
||||
C ) _CONFIG_ONLY=$BS_TRUE ;;
|
||||
P ) _PIP_ALLOWED=$BS_TRUE ;;
|
||||
F ) _FORCE_OVERWRITE=$BS_TRUE ;;
|
||||
|
@ -858,6 +862,10 @@ if [ $_INSTALL_SYNDIC -eq $BS_TRUE ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ $_START_DAEMONS -eq $BS_FALSE ]; then
|
||||
echoinfo "Daemons will not be started"
|
||||
fi
|
||||
|
||||
# Simplify distro name naming on functions
|
||||
DISTRO_NAME_L=$(echo $DISTRO_NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-zA-Z0-9_ ]//g' | sed -re 's/([[:space:]])+/_/g')
|
||||
|
||||
|
@ -1189,13 +1197,13 @@ movefile() {
|
|||
#
|
||||
# Optionally, define a salt master pre-seed function, which will be called if
|
||||
# the -k (pre-seed master keys) option is passed. One of:
|
||||
# 1. pressed_<distro>_<major_version>_<install_type>_master
|
||||
# 2. pressed_<distro>_<major_version>_<minor_version>_<install_type>_master
|
||||
# 3. pressed_<distro>_<major_version>_master
|
||||
# 4 pressed_<distro>_<major_version>_<minor_version>_master
|
||||
# 5. pressed_<distro>_<install_type>_master
|
||||
# 6. pressed_<distro>_master
|
||||
# 7. pressed_master [THIS ONE IS ALREADY DEFINED AS THE DEFAULT]
|
||||
# 1. preseed_<distro>_<major_version>_<install_type>_master
|
||||
# 2. preseed_<distro>_<major_version>_<minor_version>_<install_type>_master
|
||||
# 3. preseed_<distro>_<major_version>_master
|
||||
# 4 preseed_<distro>_<major_version>_<minor_version>_master
|
||||
# 5. preseed_<distro>_<install_type>_master
|
||||
# 6. preseed_<distro>_master
|
||||
# 7. preseed_master [THIS ONE IS ALREADY DEFINED AS THE DEFAULT]
|
||||
#
|
||||
# To install salt, which, of course, is required, one of:
|
||||
# 1. install_<distro>_<major_version>_<install_type>
|
||||
|
@ -1251,8 +1259,8 @@ __enable_universe_repository() {
|
|||
|
||||
install_ubuntu_deps() {
|
||||
apt-get update
|
||||
if [ $DISTRO_MAJOR_VERSION -gt 12 ] || [ $DISTRO_MAJOR_VERSION -eq 12 && $DISTRO_MINOR_VERSION -eq 10 ]; then
|
||||
# Above Ubuntu 11.10 add-apt-repository is in a different package
|
||||
if [ $DISTRO_MAJOR_VERSION -gt 12 ] || ([ $DISTRO_MAJOR_VERSION -eq 12 ] && [ $DISTRO_MINOR_VERSION -eq 10 ]); then
|
||||
# Above Ubuntu 12.04 add-apt-repository is in a different package
|
||||
__apt_get_install_noinput software-properties-common || return 1
|
||||
else
|
||||
__apt_get_install_noinput python-software-properties || return 1
|
||||
|
@ -1377,6 +1385,8 @@ install_ubuntu_git_post() {
|
|||
}
|
||||
|
||||
install_ubuntu_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
# Ensure upstart configs are loaded
|
||||
[ -f /sbin/initctl ] && /sbin/initctl reload-configuration
|
||||
for fname in minion master syndic; do
|
||||
|
@ -1440,7 +1450,7 @@ install_debian_6_deps() {
|
|||
if [ $_PIP_ALLOWED -eq $BS_TRUE ]; then
|
||||
echowarn "PyZMQ will be installed from PyPI in order to compile it against ZMQ3"
|
||||
echowarn "This is required for long term stable minion connections to the master."
|
||||
echowarn "YOU WILL END UP WILL QUITE A FEW PACKAGES FROM DEBIAN UNSTABLE"
|
||||
echowarn "YOU WILL END UP WITH QUITE A FEW PACKAGES FROM DEBIAN UNSTABLE"
|
||||
echowarn "Sleeping for 3 seconds so you can cancel..."
|
||||
sleep 3
|
||||
|
||||
|
@ -1511,7 +1521,7 @@ install_debian_7_deps() {
|
|||
if [ $_PIP_ALLOWED -eq $BS_TRUE ]; then
|
||||
echowarn "PyZMQ will be installed from PyPI in order to compile it against ZMQ3"
|
||||
echowarn "This is required for long term stable minion connections to the master."
|
||||
echowarn "YOU WILL END UP WILL QUITE A FEW PACKAGES FROM DEBIAN UNSTABLE"
|
||||
echowarn "YOU WILL END UP WITH QUITE A FEW PACKAGES FROM DEBIAN UNSTABLE"
|
||||
echowarn "Sleeping for 3 seconds so you can cancel..."
|
||||
sleep 3
|
||||
|
||||
|
@ -1676,6 +1686,8 @@ install_debian_git_post() {
|
|||
}
|
||||
|
||||
install_debian_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
|
||||
# Skip if not meant to be installed
|
||||
|
@ -1756,6 +1768,8 @@ install_fedora_git_post() {
|
|||
}
|
||||
|
||||
install_fedora_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
|
||||
# Skip if not meant to be installed
|
||||
|
@ -1881,6 +1895,8 @@ install_centos_git_post() {
|
|||
}
|
||||
|
||||
install_centos_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
# Skip if not meant to be installed
|
||||
[ $fname = "minion" ] && [ $_INSTALL_MINION -eq $BS_FALSE ] && continue
|
||||
|
@ -2183,7 +2199,8 @@ install_arch_linux_git_deps() {
|
|||
install_arch_linux_stable_deps
|
||||
|
||||
pacman -Sy --noconfirm pacman || return 1
|
||||
pacman -R --noconfirm python2-distribute || return 1
|
||||
# Don't fail if un-installing python2-distribute threw an error
|
||||
pacman -R --noconfirm python2-distribute
|
||||
pacman -Sy --noconfirm git python2-crypto python2-setuptools \
|
||||
python2-jinja python2-m2crypto python2-markupsafe python2-msgpack \
|
||||
python2-psutil python2-yaml python2-pyzmq zeromq || return 1
|
||||
|
@ -2275,6 +2292,8 @@ install_arch_linux_git_post() {
|
|||
}
|
||||
|
||||
install_arch_linux_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
|
||||
# Skip if not meant to be installed
|
||||
|
@ -2465,6 +2484,8 @@ install_freebsd_git_post() {
|
|||
}
|
||||
|
||||
install_freebsd_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
|
||||
# Skip if not meant to be installed
|
||||
|
@ -2590,6 +2611,8 @@ install_smartos_git_post() {
|
|||
}
|
||||
|
||||
install_smartos_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
|
||||
# Skip if not meant to be installed
|
||||
|
@ -2637,7 +2660,7 @@ install_opensuse_stable_deps() {
|
|||
|
||||
zypper --non-interactive install --auto-agree-with-licenses libzmq3 python \
|
||||
python-Jinja2 python-M2Crypto python-PyYAML python-msgpack-python \
|
||||
python-pycrypto python-pyzmq || return 1
|
||||
python-pycrypto python-pyzmq python-xml || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -2719,6 +2742,8 @@ install_opensuse_git_post() {
|
|||
}
|
||||
|
||||
install_opensuse_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
|
||||
# Skip if not meant to be installed
|
||||
|
@ -2767,13 +2792,13 @@ install_suse_11_stable_deps() {
|
|||
echowarn "PyYaml will be installed using pip"
|
||||
zypper --non-interactive install --auto-agree-with-licenses libzmq3 python \
|
||||
python-Jinja2 'python-M2Crypto>=0.21' python-msgpack-python \
|
||||
python-pycrypto python-pyzmq python-pip || return 1
|
||||
python-pycrypto python-pyzmq python-pip python-xml || return 1
|
||||
# There's no python-PyYaml in SP1, let's install it using pip
|
||||
pip install PyYaml || return 1
|
||||
else
|
||||
zypper --non-interactive install --auto-agree-with-licenses libzmq3 python \
|
||||
python-Jinja2 'python-M2Crypto>=0.21' python-PyYAML python-msgpack-python \
|
||||
python-pycrypto python-pyzmq || return 1
|
||||
python-pycrypto python-pyzmq python-xml || return 1
|
||||
fi
|
||||
|
||||
# PIP based installs need to copy configuration files "by hand".
|
||||
|
@ -2961,6 +2986,8 @@ install_gentoo_post() {
|
|||
}
|
||||
|
||||
install_gentoo_restart_daemons() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
for fname in minion master syndic; do
|
||||
|
||||
# Skip if not meant to be installed
|
||||
|
@ -3105,6 +3132,8 @@ preseed_master() {
|
|||
# This function checks if all of the installed daemons are running or not.
|
||||
#
|
||||
daemons_running() {
|
||||
[ $_START_DAEMONS -eq $BS_FALSE ] && return
|
||||
|
||||
FAILED_DAEMONS=0
|
||||
for fname in minion master syndic; do
|
||||
|
||||
|
@ -3348,7 +3377,7 @@ if [ "$STARTDAEMONS_INSTALL_FUNC" != "null" ]; then
|
|||
fi
|
||||
|
||||
# Check if the installed daemons are running or not
|
||||
if [ "$DAEMONS_RUNNING_FUNC" != "null" ]; then
|
||||
if [ "$DAEMONS_RUNNING_FUNC" != "null" ] && [ $_START_DAEMONS -eq $BS_TRUE ]; then
|
||||
sleep 3 # Sleep a little bit to let daemons start
|
||||
echoinfo "Running ${DAEMONS_RUNNING_FUNC}()"
|
||||
$DAEMONS_RUNNING_FUNC
|
||||
|
|
|
@ -1,194 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
'''
|
||||
The setup script for salt
|
||||
'''
|
||||
|
||||
import os
|
||||
import sys
|
||||
import urllib2
|
||||
from distutils import log
|
||||
from distutils.core import setup
|
||||
from distutils.cmd import Command
|
||||
from distutils.command.sdist import sdist as original_sdist
|
||||
|
||||
setup_kwargs = {}
|
||||
USE_SETUPTOOLS = False
|
||||
SALTCLOUD_SOURCE_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION = os.environ.get(
|
||||
# The user can provide a different bootstrap-script version.
|
||||
# ATTENTION: A tag for that version MUST exist
|
||||
'BOOTSTRAP_SCRIPT_VERSION',
|
||||
# If no bootstrap-script version was provided from the environment, let's
|
||||
# provide the one we define.
|
||||
'v1.5.8'
|
||||
)
|
||||
|
||||
if 'USE_SETUPTOOLS' in os.environ:
|
||||
try:
|
||||
from setuptools import setup
|
||||
from setuptools.command.sdist import sdist as original_sdist
|
||||
USE_SETUPTOOLS = True
|
||||
saltcloud_reqs = os.path.join(SALTCLOUD_SOURCE_DIR, 'requirements.txt')
|
||||
requirements = ''
|
||||
with open(saltcloud_reqs) as f:
|
||||
requirements = f.read()
|
||||
|
||||
setup_kwargs['install_requires'] = requirements
|
||||
setup_kwargs['dependency_links'] = [
|
||||
'https://github.com/saltstack/salt-testing/tarball/develop#egg=SaltTesting'
|
||||
]
|
||||
setup_kwargs['tests_require'] = ['SaltTesting']
|
||||
except:
|
||||
USE_SETUPTOOLS = False
|
||||
|
||||
|
||||
if USE_SETUPTOOLS is False:
|
||||
from distutils.core import setup
|
||||
|
||||
exec(
|
||||
compile(
|
||||
open('saltcloud/version.py').read(), 'saltcloud/version.py', 'exec'
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class sdist(original_sdist):
|
||||
user_options = original_sdist.user_options + [
|
||||
('skip-bootstrap-download', None,
|
||||
'Skip downloading the bootstrap-salt.sh script. This can also be '
|
||||
'triggered by having `SKIP_BOOTSTRAP_DOWNLOAD=1` as an environment '
|
||||
'variable.')
|
||||
]
|
||||
boolean_options = original_sdist.boolean_options + [
|
||||
'skip-bootstrap-download'
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
original_sdist.initialize_options(self)
|
||||
self.skip_bootstrap_download = False
|
||||
|
||||
def finalize_options(self):
|
||||
original_sdist.finalize_options(self)
|
||||
if 'SKIP_BOOTSTRAP_DOWNLOAD' in os.environ:
|
||||
skip_bootstrap_download = os.environ.get(
|
||||
'SKIP_BOOTSTRAP_DOWNLOAD', '0'
|
||||
)
|
||||
self.skip_bootstrap_download = skip_bootstrap_download == '1'
|
||||
|
||||
def run(self):
|
||||
if self.skip_bootstrap_download is False:
|
||||
# Let's update the bootstrap-script to the version defined to be
|
||||
# distributed. See BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION above.
|
||||
url = (
|
||||
'https://github.com/saltstack/salt-bootstrap/raw/{0}'
|
||||
'/bootstrap-salt.sh'.format(
|
||||
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION
|
||||
)
|
||||
)
|
||||
req = urllib2.urlopen(url)
|
||||
deploy_path = os.path.join(
|
||||
SALTCLOUD_SOURCE_DIR,
|
||||
'saltcloud',
|
||||
'deploy',
|
||||
'bootstrap-salt.sh'
|
||||
)
|
||||
if req.getcode() == 200:
|
||||
try:
|
||||
log.info(
|
||||
'Updating bootstrap-salt.sh.'
|
||||
'\n\tSource: {0}'
|
||||
'\n\tDestination: {1}'.format(
|
||||
url,
|
||||
deploy_path
|
||||
)
|
||||
)
|
||||
with open(deploy_path, 'w') as fp_:
|
||||
fp_.write(req.read())
|
||||
except (OSError, IOError), err:
|
||||
log.error(
|
||||
'Failed to write the updated script: {0}'.format(err)
|
||||
)
|
||||
else:
|
||||
log.error(
|
||||
'Failed to update the bootstrap-salt.sh script. HTTP '
|
||||
'Error code: {0}'.format(
|
||||
req.getcode()
|
||||
)
|
||||
)
|
||||
|
||||
# Let's the rest of the build command
|
||||
original_sdist.run(self)
|
||||
|
||||
|
||||
class TestCommand(Command):
|
||||
description = 'Run tests'
|
||||
user_options = [
|
||||
('runtests-opts=', 'R', 'Command line options to pass to runtests.py')
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
self.runtests_opts = None
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
from subprocess import Popen
|
||||
self.run_command('build')
|
||||
build_cmd = self.get_finalized_command('build_ext')
|
||||
runner = os.path.abspath('tests/runtests.py')
|
||||
test_cmd = sys.executable + ' {0}'.format(runner)
|
||||
if self.runtests_opts:
|
||||
test_cmd += ' {0}'.format(self.runtests_opts)
|
||||
|
||||
print('running test')
|
||||
test_process = Popen(
|
||||
test_cmd, shell=True,
|
||||
stdout=sys.stdout, stderr=sys.stderr,
|
||||
cwd=build_cmd.build_lib
|
||||
)
|
||||
test_process.communicate()
|
||||
sys.exit(test_process.returncode)
|
||||
|
||||
|
||||
NAME = 'salt-cloud'
|
||||
VER = __version__
|
||||
DESC = ('Generic cloud provisioning system with build in functions ')
|
||||
|
||||
setup(name=NAME,
|
||||
version=VER,
|
||||
description=DESC,
|
||||
author='Thomas S Hatch',
|
||||
author_email='thatch@saltstack.com',
|
||||
url='http://saltstack.org',
|
||||
classifiers=[
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: Console',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Information Technology',
|
||||
'Intended Audience :: System Administrators',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Topic :: System :: Distributed Computing',
|
||||
],
|
||||
packages=['saltcloud',
|
||||
'saltcloud/utils',
|
||||
'saltcloud/clouds',
|
||||
],
|
||||
package_data={
|
||||
'saltcloud': ['deploy/*.sh'],
|
||||
},
|
||||
data_files=[('share/man/man1', ['doc/man/salt-cloud.1']),
|
||||
('share/man/man7', ['doc/man/salt-cloud.7'])
|
||||
],
|
||||
scripts=['scripts/salt-cloud'],
|
||||
cmdclass={
|
||||
'sdist': sdist,
|
||||
'test': TestCommand
|
||||
},
|
||||
**setup_kwargs
|
||||
)
|
97
setup.py
97
setup.py
|
@ -4,16 +4,23 @@
|
|||
The setup script for salt
|
||||
'''
|
||||
|
||||
# pylint: disable=C0111,E1101,E1103,F0401,W0611
|
||||
|
||||
# For Python 2.5. A no-op on 2.6 and above.
|
||||
from __future__ import with_statement
|
||||
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import urllib2
|
||||
from datetime import datetime
|
||||
# pylint: disable=E0611
|
||||
from distutils import log
|
||||
from distutils.cmd import Command
|
||||
from distutils.command.build import build
|
||||
from distutils.command.clean import clean
|
||||
from distutils.command.sdist import sdist
|
||||
# pylint: enable=E0611
|
||||
|
||||
# Change to salt source's directory prior to running any command
|
||||
try:
|
||||
|
@ -26,6 +33,15 @@ except NameError:
|
|||
if SETUP_DIRNAME != '':
|
||||
os.chdir(SETUP_DIRNAME)
|
||||
|
||||
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION = os.environ.get(
|
||||
# The user can provide a different bootstrap-script version.
|
||||
# ATTENTION: A tag for that version MUST exist
|
||||
'BOOTSTRAP_SCRIPT_VERSION',
|
||||
# If no bootstrap-script version was provided from the environment, let's
|
||||
# provide the one we define.
|
||||
'v1.5.9'
|
||||
)
|
||||
|
||||
# Store a reference to the executing platform
|
||||
IS_WINDOWS_PLATFORM = sys.platform.startswith('win')
|
||||
|
||||
|
@ -39,14 +55,17 @@ if 'USE_SETUPTOOLS' in os.environ or 'setuptools' in sys.modules:
|
|||
try:
|
||||
from setuptools import setup
|
||||
from setuptools.command.install import install
|
||||
from setuptools.command.sdist import sdist
|
||||
WITH_SETUPTOOLS = True
|
||||
except ImportError:
|
||||
WITH_SETUPTOOLS = False
|
||||
|
||||
if WITH_SETUPTOOLS is False:
|
||||
import warnings
|
||||
# pylint: disable=E0611
|
||||
from distutils.command.install import install
|
||||
from distutils.core import setup
|
||||
# pylint: enable=E0611
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
'Unknown distribution option: \'(tests_require|install_requires|zip_safe)\'',
|
||||
|
@ -76,8 +95,79 @@ SALT_SYSPATHS = os.path.join(
|
|||
os.path.abspath(SETUP_DIRNAME), 'salt', 'syspaths.py'
|
||||
)
|
||||
|
||||
# pylint: disable=W0122
|
||||
exec(compile(open(SALT_VERSION).read(), SALT_VERSION, 'exec'))
|
||||
exec(compile(open(SALT_SYSPATHS).read(), SALT_SYSPATHS, 'exec'))
|
||||
# pylint: enable=W0122
|
||||
|
||||
|
||||
class CloudSdist(sdist):
|
||||
user_options = sdist.user_options + [
|
||||
('skip-bootstrap-download', None,
|
||||
'Skip downloading the bootstrap-salt.sh script. This can also be '
|
||||
'triggered by having `SKIP_BOOTSTRAP_DOWNLOAD=1` as an environment '
|
||||
'variable.')
|
||||
]
|
||||
boolean_options = sdist.boolean_options + [
|
||||
'skip-bootstrap-download'
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
sdist.initialize_options(self)
|
||||
self.skip_bootstrap_download = False
|
||||
|
||||
def finalize_options(self):
|
||||
sdist.finalize_options(self)
|
||||
if 'SKIP_BOOTSTRAP_DOWNLOAD' in os.environ:
|
||||
skip_bootstrap_download = os.environ.get(
|
||||
'SKIP_BOOTSTRAP_DOWNLOAD', '0'
|
||||
)
|
||||
self.skip_bootstrap_download = skip_bootstrap_download == '1'
|
||||
|
||||
def run(self):
|
||||
if self.skip_bootstrap_download is False:
|
||||
# Let's update the bootstrap-script to the version defined to be
|
||||
# distributed. See BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION above.
|
||||
url = (
|
||||
'https://github.com/saltstack/salt-bootstrap/raw/{0}'
|
||||
'/bootstrap-salt.sh'.format(
|
||||
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION
|
||||
)
|
||||
)
|
||||
req = urllib2.urlopen(url)
|
||||
deploy_path = os.path.join(
|
||||
SETUP_DIRNAME,
|
||||
'salt',
|
||||
'cloud',
|
||||
'deploy',
|
||||
'bootstrap-salt.sh'
|
||||
)
|
||||
if req.getcode() == 200:
|
||||
try:
|
||||
log.info(
|
||||
'Updating bootstrap-salt.sh.'
|
||||
'\n\tSource: {0}'
|
||||
'\n\tDestination: {1}'.format(
|
||||
url,
|
||||
deploy_path
|
||||
)
|
||||
)
|
||||
with open(deploy_path, 'w') as fp_:
|
||||
fp_.write(req.read())
|
||||
except (OSError, IOError), err:
|
||||
log.error(
|
||||
'Failed to write the updated script: {0}'.format(err)
|
||||
)
|
||||
else:
|
||||
log.error(
|
||||
'Failed to update the bootstrap-salt.sh script. HTTP '
|
||||
'Error code: {0}'.format(
|
||||
req.getcode()
|
||||
)
|
||||
)
|
||||
|
||||
# Let's the rest of the build command
|
||||
sdist.run(self)
|
||||
|
||||
|
||||
class TestCommand(Command):
|
||||
|
@ -162,6 +252,7 @@ class Build(build):
|
|||
version_file_path = os.path.join(
|
||||
self.build_lib, 'salt', '_version.py'
|
||||
)
|
||||
# pylint: disable=E0602
|
||||
open(version_file_path, 'w').write(
|
||||
INSTALL_VERSION_TEMPLATE.format(
|
||||
date=datetime.utcnow(),
|
||||
|
@ -169,6 +260,7 @@ class Build(build):
|
|||
version_info=__version_info__
|
||||
)
|
||||
)
|
||||
# pylint: enable=E0602
|
||||
|
||||
# Write the system paths file
|
||||
system_paths_file_path = os.path.join(
|
||||
|
@ -217,6 +309,7 @@ class Install(install):
|
|||
|
||||
def initialize_options(self):
|
||||
install.initialize_options(self)
|
||||
# pylint: disable=E0602
|
||||
self.salt_root_dir = ROOT_DIR
|
||||
self.salt_config_dir = CONFIG_DIR
|
||||
self.salt_cache_dir = CACHE_DIR
|
||||
|
@ -227,6 +320,7 @@ class Install(install):
|
|||
self.salt_base_master_roots_dir = BASE_MASTER_ROOTS_DIR
|
||||
self.salt_logs_dir = LOGS_DIR
|
||||
self.salt_pidfile_dir = PIDFILE_DIR
|
||||
# pylint: enable=E0602
|
||||
|
||||
def finalize_options(self):
|
||||
install.finalize_options(self)
|
||||
|
@ -252,7 +346,7 @@ class Install(install):
|
|||
|
||||
|
||||
NAME = 'salt'
|
||||
VER = __version__
|
||||
VER = __version__ # pylint: disable=E0602
|
||||
DESC = ('Portable, distributed, remote execution and '
|
||||
'configuration management system')
|
||||
|
||||
|
@ -336,6 +430,7 @@ SETUP_KWARGS = {'name': NAME,
|
|||
}
|
||||
|
||||
if IS_WINDOWS_PLATFORM is False:
|
||||
SETUP_KWARGS['cmdclass']['sdist'] = CloudSdist
|
||||
SETUP_KWARGS['packages'].extend(['salt.cloud',
|
||||
'salt.cloud.utils',
|
||||
'salt.cloud.clouds'])
|
||||
|
|
Loading…
Add table
Reference in a new issue