Skip to content

Commit 403f140

Browse files
committed
Merge pull request saltstack#18956 from thatch45/merge_forward_8798
Merge forward 2014.7
2 parents 59f8a2b + 3def3ea commit 403f140

23 files changed

+202
-78
lines changed

salt/cli/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
import logging
1010
import os
1111
import sys
12-
from glob import glob
1312

1413
# Import salt libs
1514
import salt.client
15+
import salt.client.ssh
16+
import salt.client.netapi
17+
import salt.defaults.exitcodes
1618
import salt.output
1719
import salt.client.ssh
1820
from salt.config import _expand_glob_path
@@ -443,11 +445,11 @@ def run(self):
443445

444446
if self.options.doc:
445447
caller.print_docs()
446-
self.exit(os.EX_OK)
448+
self.exit(salt.defaults.exitcodes.EX_OK)
447449

448450
if self.options.grains_run:
449451
caller.print_grains()
450-
self.exit(os.EX_OK)
452+
self.exit(salt.defaults.exitcodes.EX_OK)
451453

452454
caller.run()
453455

@@ -487,8 +489,8 @@ def run(self):
487489

488490
runner = salt.runner.Runner(self.config)
489491
if self.options.doc:
490-
runner.print_docs()
491-
self.exit(os.EX_OK)
492+
runner._print_docs()
493+
self.exit(salt.defaults.exitcodes.EX_OK)
492494

493495
# Run this here so SystemExit isn't raised anywhere else when
494496
# someone tries to use the runners via the python API

salt/client/ssh/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def _key_deploy_run(self, host, target, re_run=True):
312312
if stderr:
313313
return {host: stderr}
314314
return {host: 'Bad Return'}
315-
if os.EX_OK != retcode:
315+
if salt.exitcodes.EX_OK != retcode:
316316
return {host: stderr}
317317
return {host: stdout}
318318

@@ -961,7 +961,7 @@ def categorize_shim_errors(self, stdout, stderr, retcode):
961961
'The salt thin transfer was corrupted'
962962
),
963963
(
964-
(os.EX_CANTCREAT,),
964+
(salt.exitcodes.EX_CANTCREAT,),
965965
'salt path .* exists but is not a directory',
966966
'A necessary path for salt thin unexpectedly exists:\n ' + stderr,
967967
),
@@ -986,7 +986,7 @@ def categorize_shim_errors(self, stdout, stderr, retcode):
986986
perm_error_fmt.format(stderr)
987987
),
988988
(
989-
(os.EX_SOFTWARE,),
989+
(salt.exitcodes.EX_SOFTWARE,),
990990
'exists but is not',
991991
'An internal error occurred with the shim, please investigate:\n ' + stderr,
992992
),

salt/client/ssh/shell.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import subprocess
1414

1515
# Import salt libs
16+
import salt.defaults.exitcodes
1617
import salt.utils
1718
import salt.utils.nb_popen
1819
import salt.utils.vt
@@ -186,7 +187,7 @@ def copy_id(self):
186187
Execute ssh-copy-id to plant the id file on the target
187188
'''
188189
stdout, stderr, retcode = self._run_cmd(self._copy_id_str_old())
189-
if os.EX_OK != retcode and stderr.startswith('Usage'):
190+
if salt.defaults.exitcodes.EX_OK != retcode and stderr.startswith('Usage'):
190191
stdout, stderr, retcode = self._run_cmd(self._copy_id_str_new())
191192
return stdout, stderr, retcode
192193

salt/client/ssh/ssh_py_shim.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
THIN_ARCHIVE = 'salt-thin.tgz'
2121
EXT_ARCHIVE = 'salt-ext_mods.tgz'
2222

23-
# FIXME - it would be ideal if these could be obtained directly from
24-
# salt.exitcodes rather than duplicated.
23+
# Keep these in sync with salt/exitcodes.py
2524
EX_THIN_DEPLOY = 11
2625
EX_THIN_CHECKSUM = 12
2726
EX_MOD_DEPLOY = 13

salt/cloud/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def run(self):
8080
self.options.output, self.config
8181
)
8282
print(display_output(ret))
83-
self.exit(os.EX_OK)
83+
self.exit(salt.exitcodes.EX_OK)
8484

8585
log.info('salt-cloud starting')
8686
mapper = salt.cloud.Map(self.config)
@@ -173,7 +173,7 @@ def run(self):
173173

174174
if not matching:
175175
print('No machines were found to be destroyed')
176-
self.exit(os.EX_OK)
176+
self.exit(salt.exitcodes.EX_OK)
177177

178178
msg = 'The following virtual machines are set to be destroyed:\n'
179179
names = set()
@@ -334,7 +334,7 @@ def run(self):
334334
)
335335
# display output using salt's outputter system
336336
print(display_output(ret))
337-
self.exit(os.EX_OK)
337+
self.exit(salt.exitcodes.EX_OK)
338338

339339
def print_confirm(self, msg):
340340
if self.options.assume_yes:

salt/cloud/clouds/ec2.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3295,7 +3295,10 @@ def _toggle_delvol(name=None, instance_id=None, device=None, volume_id=None,
32953295
opts=__opts__,
32963296
sigver='4')
32973297

3298-
return _get_node(instance_id=instance_id)
3298+
kwargs = {'instance_id': instance_id,
3299+
'device': device,
3300+
'volume_id': volume_id}
3301+
return show_delvol_on_destroy(name, kwargs, call='action')
32993302

33003303

33013304
def create_volume(kwargs=None, call=None, wait_to_finish=False):

salt/cloud/deploy/bootstrap-salt.sh

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# CREATED: 10/15/2012 09:49:37 PM WEST
1818
#======================================================================================================================
1919
set -o nounset # Treat unset variables as an error
20-
__ScriptVersion="2014.10.30"
20+
__ScriptVersion="2014.12.11"
2121
__ScriptName="bootstrap-salt.sh"
2222

2323
#======================================================================================================================
@@ -243,7 +243,7 @@ usage() {
243243
-D Show debug output.
244244
-c Temporary configuration directory
245245
-g Salt repository URL. (default: git://github.com/saltstack/salt.git)
246-
-G Insteady of cloning from git://github.com/saltstack/salt.git, clone from https://github.com/saltstack/salt.git (Usually necessary on systems which have the regular git protocol port blocked, where https usualy is not)
246+
-G Instead of cloning from git://github.com/saltstack/salt.git, clone from https://github.com/saltstack/salt.git (Usually necessary on systems which have the regular git protocol port blocked, where https usually is not)
247247
-k Temporary directory holding the minion keys which will pre-seed
248248
the master.
249249
-s Sleep time used when waiting for daemons to start, restart and when checking
@@ -987,11 +987,12 @@ __debian_derivatives_translation() {
987987
# If the file does not exist, return
988988
[ ! -f /etc/os-release ] && return
989989

990-
DEBIAN_DERIVATIVES="(kali)"
990+
DEBIAN_DERIVATIVES="(kali|linuxmint)"
991991
# Mappings
992992
kali_1_debian_base="7.0"
993+
linuxmint_1_debian_base="8.0"
993994

994-
# Detect derivates, Kali *only* for now
995+
# Detect derivates, Kali and LinuxMint *only* for now
995996
rv=$(grep ^ID= /etc/os-release | sed -e 's/.*=//')
996997

997998
# Translate Debian derivatives to their base Debian version
@@ -1003,6 +1004,10 @@ __debian_derivatives_translation() {
10031004
_major=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).*/\1/g')
10041005
_debian_derivative="kali"
10051006
;;
1007+
linuxmint)
1008+
_major=$(echo "$DISTRO_VERSION" | sed 's/^\([0-9]*\).*/\1/g')
1009+
_debian_derivative="linuxmint"
1010+
;;
10061011
esac
10071012

10081013
_debian_version=$(eval echo "\$${_debian_derivative}_${_major}_debian_base")
@@ -2544,7 +2549,7 @@ __install_epel_repository() {
25442549
elif [ "$DISTRO_MAJOR_VERSION" -eq 6 ]; then
25452550
rpm -Uvh --force "http://download.fedoraproject.org/pub/epel/6/${EPEL_ARCH}/epel-release-6-8.noarch.rpm" || return 1
25462551
elif [ "$DISTRO_MAJOR_VERSION" -eq 7 ]; then
2547-
rpm -Uvh --force "http://download.fedoraproject.org/pub/epel/7/${EPEL_ARCH}/e/epel-release-7-2.noarch.rpm" || return 1
2552+
rpm -Uvh --force "http://download.fedoraproject.org/pub/epel/7/${EPEL_ARCH}/e/epel-release-7-5.noarch.rpm" || return 1
25482553
else
25492554
echoerror "Failed add EPEL repository support."
25502555
return 1
@@ -2562,7 +2567,7 @@ __install_saltstack_copr_zeromq_repository() {
25622567
__REPOTYPE="epel"
25632568
fi
25642569
wget -O /etc/yum.repos.d/saltstack-zeromq4.repo \
2565-
"https://copr.fedoraproject.org/coprs/saltstack/zeromq4/repo/${__REPOTYPE}-${DISTRO_MAJOR_VERSION}/saltstack-zeromq4-${__REPOTYPE}-${DISTRO_MAJOR_VERSION}.repo" || return 1
2570+
"http://copr.fedoraproject.org/coprs/saltstack/zeromq4/repo/${__REPOTYPE}-${DISTRO_MAJOR_VERSION}/saltstack-zeromq4-${__REPOTYPE}-${DISTRO_MAJOR_VERSION}.repo" || return 1
25662571
fi
25672572
return 0
25682573
}
@@ -2684,9 +2689,9 @@ install_centos_git_deps() {
26842689
install_centos_stable_deps || return 1
26852690
if [ "$DISTRO_NAME_L" = "oracle_linux" ]; then
26862691
# try both ways --enablerepo=X disables ALL OTHER REPOS!!!!
2687-
yum -y install git || yum -y install git --enablerepo=${_EPEL_REPO} || return 1
2692+
yum install -y git systemd-python || yum install -y git systemd-python --enablerepo=${_EPEL_REPO} || return 1
26882693
else
2689-
yum -y install git --enablerepo=${_EPEL_REPO} || return 1
2694+
yum install -y git systemd-python --enablerepo=${_EPEL_REPO} || return 1
26902695
fi
26912696

26922697
__git_clone_and_checkout || return 1
@@ -2715,6 +2720,7 @@ install_centos_git() {
27152720
}
27162721

27172722
install_centos_git_post() {
2723+
SYSTEMD_RELOAD=$BS_FALSE
27182724
for fname in minion master syndic api; do
27192725

27202726
# Skip if not meant to be installed
@@ -2723,8 +2729,15 @@ install_centos_git_post() {
27232729
[ $fname = "api" ] && ([ "$_INSTALL_MASTER" -eq $BS_FALSE ] || [ "$(which salt-${fname} 2>/dev/null)" = "" ]) && continue
27242730
[ $fname = "syndic" ] && [ "$_INSTALL_SYNDIC" -eq $BS_FALSE ] && continue
27252731

2726-
# While the RPM's use init.d, so will we.
2727-
if [ ! -f /etc/init.d/salt-$fname ] || ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then
2732+
if [ ! -f /usr/lib/systemd/system/salt-${fname}.service ] || ([ -f /usr/lib/systemd/system/salt-${fname}.service ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then
2733+
copyfile "${__SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}.service" /usr/lib/systemd/system/
2734+
2735+
# Skip salt-api since the service should be opt-in and not necessarily started on boot
2736+
[ $fname = "api" ] && continue
2737+
2738+
/bin/systemctl enable salt-${fname}.service
2739+
SYSTEMD_RELOAD=$BS_TRUE
2740+
elif [ ! -f /usr/lib/systemd/system/salt-${fname}.service ] && [ ! -f /etc/init.d/salt-$fname ] || ([ -f /etc/init.d/salt-$fname ] && [ $_FORCE_OVERWRITE -eq $BS_TRUE ]); then
27282741
copyfile "${__SALT_GIT_CHECKOUT_DIR}/pkg/rpm/salt-${fname}" /etc/init.d/
27292742
chmod +x /etc/init.d/salt-${fname}
27302743

@@ -2748,6 +2761,10 @@ install_centos_git_post() {
27482761
# /sbin/chkconfig salt-${fname} on
27492762
#fi
27502763
done
2764+
2765+
if [ "$SYSTEMD_RELOAD" -eq $BS_TRUE ]; then
2766+
/bin/systemctl daemon-reload
2767+
fi
27512768
}
27522769

27532770
install_centos_restart_daemons() {
@@ -2921,11 +2938,6 @@ install_red_hat_linux_git_deps() {
29212938
return 0
29222939
}
29232940

2924-
install_red_hat_enterprise_linux_7_stable_deps() {
2925-
echoerror "Stable version is not available on RHEL 7 Beta/RC. Please set installation type to git."
2926-
return 1
2927-
}
2928-
29292941
install_red_hat_enterprise_linux_stable_deps() {
29302942
install_red_hat_linux_stable_deps || return 1
29312943
return 0

salt/crypt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
pass
2929

3030
# Import salt libs
31+
import salt.defaults.exitcodes
3132
import salt.utils
3233
import salt.payload
3334
import salt.utils.verify
@@ -679,7 +680,7 @@ def sign_in(self, timeout=60, safe=True, tries=1):
679680
'minion.\nOr restart the Salt Master in open mode to '
680681
'clean out the keys. The Salt Minion will now exit.'
681682
)
682-
sys.exit(os.EX_OK)
683+
sys.exit(salt.defaults.exitcodes.EX_OK)
683684
# has the master returned that its maxed out with minions?
684685
elif payload['load']['ret'] == 'full':
685686
return 'full'

salt/defaults/exitcodes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,17 @@
1313
EX_THIN_PYTHON_OLD = 10
1414
EX_THIN_DEPLOY = 11
1515
EX_THIN_CHECKSUM = 12
16+
EX_MOD_DEPLOY = 13
17+
18+
# The os.EX_* exit codes are Unix only so in the interest of cross-platform
19+
# compatiblility define them explicitly here.
20+
#
21+
# These constants are documented here:
22+
# https://docs.python.org/2/library/os.html#os.EX_OK
23+
24+
EX_OK = 0
25+
EX_NOUSER = 67
26+
EX_UNAVAILABLE = 69
27+
EX_CANTCREAT = 73
28+
EX_SOFTWARE = 70
29+
EX_USAGE = 64

salt/grains/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,8 @@ def _virtual(osdata):
670670
grains['virtual'] = 'xen'
671671
if maker.startswith('Microsoft') and product.startswith('Virtual'):
672672
grains['virtual'] = 'VirtualPC'
673+
if maker.startswith('OpenStack'):
674+
grains['virtual'] = 'OpenStack'
673675
if sysctl:
674676
model = __salt__['cmd.run']('{0} hw.model'.format(sysctl))
675677
jail = __salt__['cmd.run'](

salt/modules/genesis.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def bootstrap(platform,
9090
9191
CLI Examples:
9292
93+
.. code-block:: bash
94+
9395
salt myminion genesis.bootstrap pacman /root/arch
9496
salt myminion genesis.bootstrap rpm /root/redhat
9597
salt myminion genesis.bootstrap deb /root/wheezy arch=amd64 \
@@ -264,6 +266,8 @@ def avail_platforms():
264266
265267
CLI Example:
266268
269+
.. code-block:: bash
270+
267271
salt myminion genesis.avail_platforms
268272
'''
269273
ret = {}
@@ -281,6 +285,8 @@ def pack(name, root, path=None, pack_format='tar', compress='bzip2'):
281285
282286
CLI Examples:
283287
288+
.. code-block:: bash
289+
284290
salt myminion genesis.pack centos /root/centos
285291
salt myminion genesis.pack centos /root/centos pack_format='tar'
286292
'''
@@ -294,6 +300,8 @@ def unpack(name, dest=None, path=None, pack_format='tar', compress='bz2'):
294300
295301
CLI Example:
296302
303+
.. code-block:: bash
304+
297305
salt myminion genesis.unpack centos /root/centos
298306
'''
299307
if pack_format == 'tar':

salt/modules/pkgng.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def install(name=None,
723723
opts += 'q'
724724
if salt.utils.is_true(reinstall_requires):
725725
opts += 'R'
726-
if salt.utils.is_true(fromrepo):
726+
if fromrepo:
727727
repo_opts += 'r {0}'.format(fromrepo)
728728
if salt.utils.is_true(regex):
729729
opts += 'x'
@@ -1514,11 +1514,11 @@ def fetch(name,
15141514
if opts:
15151515
opts = '-' + opts
15161516
if repo_opts:
1517-
opts = '-' + repo_opts
1517+
repo_opts = '-' + repo_opts
15181518

15191519
return __salt__['cmd.run'](
15201520
'{0} fetch -y {1} {2} {3}'.format(
1521-
_pkg(jail, chroot), repo_opts, opts, name
1521+
_pkg(jail, chroot), opts, repo_opts, name
15221522
),
15231523
output_loglevel='trace'
15241524
)

salt/scripts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# Import salt libs
2020
import salt
2121
from salt.exceptions import SaltSystemExit, SaltClientError, SaltReqTimeoutError
22+
import salt.defaults.exitcodes
2223
import salt.cli
2324

2425

@@ -302,7 +303,7 @@ def salt_cloud():
302303

303304
if not has_saltcloud:
304305
print('salt-cloud is not available in this system')
305-
sys.exit(os.EX_UNAVAILABLE)
306+
sys.exit(salt.defaults.exitcodes.EX_UNAVAILABLE)
306307

307308
client = None
308309
try:

0 commit comments

Comments
 (0)