mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge remote-tracking branch 'upstream/2016.11' into fix-apache-config-multi-entity
This commit is contained in:
commit
c15bcbe1cc
@ -260,6 +260,13 @@ The Salt development team will back-port bug fixes made to ``develop`` to the
|
||||
current release branch if the contributor cannot create the pull request
|
||||
against that branch.
|
||||
|
||||
Release Branches
|
||||
----------------
|
||||
|
||||
For each release a branch will be created when we are ready to tag. The branch will be the same name as the tag minus the v. For example, the v2017.7.1 release was created from the 2017.7.1 branch. This branching strategy will allow for more stability when there is a need for a re-tag during the testing phase of our releases.
|
||||
|
||||
Once the branch is created, the fixes required for a given release, as determined by the SaltStack release team, will be added to this branch. All commits in this branch will be merged forward into the parent branch as well.
|
||||
|
||||
Keeping Salt Forks in Sync
|
||||
==========================
|
||||
|
||||
|
@ -135,19 +135,6 @@ def _reconstruct_ppa_name(owner_name, ppa_name):
|
||||
return 'ppa:{0}/{1}'.format(owner_name, ppa_name)
|
||||
|
||||
|
||||
def _get_repo(**kwargs):
|
||||
'''
|
||||
Check the kwargs for either 'fromrepo' or 'repo' and return the value.
|
||||
'fromrepo' takes precedence over 'repo'.
|
||||
'''
|
||||
for key in ('fromrepo', 'repo'):
|
||||
try:
|
||||
return kwargs[key]
|
||||
except KeyError:
|
||||
pass
|
||||
return ''
|
||||
|
||||
|
||||
def _check_apt():
|
||||
'''
|
||||
Abort if python-apt is not installed
|
||||
@ -242,18 +229,11 @@ def latest_version(*names, **kwargs):
|
||||
'''
|
||||
refresh = salt.utils.is_true(kwargs.pop('refresh', True))
|
||||
show_installed = salt.utils.is_true(kwargs.pop('show_installed', False))
|
||||
|
||||
if 'repo' in kwargs:
|
||||
# Remember to kill _get_repo() too when removing this warning.
|
||||
salt.utils.warn_until(
|
||||
'Hydrogen',
|
||||
'The \'repo\' argument to apt.latest_version is deprecated, and '
|
||||
'will be removed in Salt {version}. Please use \'fromrepo\' '
|
||||
'instead.'
|
||||
raise SaltInvocationError(
|
||||
'The \'repo\' argument is invalid, use \'fromrepo\' instead'
|
||||
)
|
||||
fromrepo = _get_repo(**kwargs)
|
||||
kwargs.pop('fromrepo', None)
|
||||
kwargs.pop('repo', None)
|
||||
fromrepo = kwargs.pop('fromrepo', None)
|
||||
cache_valid_time = kwargs.pop('cache_valid_time', 0)
|
||||
|
||||
if len(names) == 0:
|
||||
@ -1380,9 +1360,10 @@ def _get_upgradable(dist_upgrade=True, **kwargs):
|
||||
cmd.append('dist-upgrade')
|
||||
else:
|
||||
cmd.append('upgrade')
|
||||
fromrepo = _get_repo(**kwargs)
|
||||
if fromrepo:
|
||||
cmd.extend(['-o', 'APT::Default-Release={0}'.format(fromrepo)])
|
||||
try:
|
||||
cmd.extend(['-o', 'APT::Default-Release={0}'.format(kwargs['fromrepo'])])
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
call = __salt__['cmd.run_all'](cmd,
|
||||
python_shell=False,
|
||||
|
@ -199,7 +199,7 @@ def execute(context=None, lens=None, commands=(), load_path=None):
|
||||
method = METHOD_MAP[cmd]
|
||||
nargs = arg_map[method]
|
||||
|
||||
parts = salt.utils.shlex_split(arg, posix=False)
|
||||
parts = salt.utils.shlex_split(arg)
|
||||
|
||||
if len(parts) not in nargs:
|
||||
err = '{0} takes {1} args: {2}'.format(method, nargs, parts)
|
||||
|
@ -22,6 +22,10 @@ import salt.utils.decorators as decorators
|
||||
from salt.utils.decorators import depends
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
__func_alias__ = {
|
||||
'format_': 'format'
|
||||
}
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
HAS_HDPARM = salt.utils.which('hdparm') is not None
|
||||
|
@ -24,6 +24,8 @@ import salt.utils.kickstart
|
||||
import salt.syspaths
|
||||
from salt.exceptions import SaltInvocationError
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -325,6 +327,8 @@ def _bootstrap_yum(
|
||||
'''
|
||||
if pkgs is None:
|
||||
pkgs = []
|
||||
elif isinstance(pkgs, six.string_types):
|
||||
pkgs = pkgs.split(',')
|
||||
|
||||
default_pkgs = ('yum', 'centos-release', 'iputils')
|
||||
for pkg in default_pkgs:
|
||||
@ -333,6 +337,8 @@ def _bootstrap_yum(
|
||||
|
||||
if exclude_pkgs is None:
|
||||
exclude_pkgs = []
|
||||
elif isinstance(exclude_pkgs, six.string_types):
|
||||
exclude_pkgs = exclude_pkgs.split(',')
|
||||
|
||||
for pkg in exclude_pkgs:
|
||||
pkgs.remove(pkg)
|
||||
@ -393,15 +399,27 @@ def _bootstrap_deb(
|
||||
if repo_url is None:
|
||||
repo_url = 'http://ftp.debian.org/debian/'
|
||||
|
||||
if not salt.utils.which('debootstrap'):
|
||||
log.error('Required tool debootstrap is not installed.')
|
||||
return False
|
||||
|
||||
if isinstance(pkgs, (list, tuple)):
|
||||
pkgs = ','.join(pkgs)
|
||||
if isinstance(exclude_pkgs, (list, tuple)):
|
||||
exclude_pkgs = ','.join(exclude_pkgs)
|
||||
|
||||
deb_args = [
|
||||
'debootstrap',
|
||||
'--foreign',
|
||||
'--arch',
|
||||
_cmd_quote(arch),
|
||||
'--include',
|
||||
] + pkgs + [
|
||||
'--exclude',
|
||||
] + exclude_pkgs + [
|
||||
_cmd_quote(arch)]
|
||||
|
||||
if pkgs:
|
||||
deb_args += ['--include', _cmd_quote(pkgs)]
|
||||
if exclude_pkgs:
|
||||
deb_args += ['--exclude', _cmd_quote(exclude_pkgs)]
|
||||
|
||||
deb_args += [
|
||||
_cmd_quote(flavor),
|
||||
_cmd_quote(root),
|
||||
_cmd_quote(repo_url),
|
||||
@ -469,6 +487,8 @@ def _bootstrap_pacman(
|
||||
|
||||
if pkgs is None:
|
||||
pkgs = []
|
||||
elif isinstance(pkgs, six.string_types):
|
||||
pkgs = pkgs.split(',')
|
||||
|
||||
default_pkgs = ('pacman', 'linux', 'systemd-sysvcompat', 'grub')
|
||||
for pkg in default_pkgs:
|
||||
@ -477,6 +497,8 @@ def _bootstrap_pacman(
|
||||
|
||||
if exclude_pkgs is None:
|
||||
exclude_pkgs = []
|
||||
elif isinstance(exclude_pkgs, six.string_types):
|
||||
exclude_pkgs = exclude_pkgs.split(',')
|
||||
|
||||
for pkg in exclude_pkgs:
|
||||
pkgs.remove(pkg)
|
||||
|
@ -1317,6 +1317,23 @@ def latest(name,
|
||||
'if it does not already exist).',
|
||||
comments
|
||||
)
|
||||
remote_tags = set([
|
||||
x.replace('refs/tags/', '') for x in __salt__['git.ls_remote'](
|
||||
cwd=target,
|
||||
remote=remote,
|
||||
opts="--tags",
|
||||
user=user,
|
||||
password=password,
|
||||
identity=identity,
|
||||
saltenv=__env__,
|
||||
ignore_retcode=True,
|
||||
).keys() if '^{}' not in x
|
||||
])
|
||||
if set(all_local_tags) != remote_tags:
|
||||
has_remote_rev = False
|
||||
ret['changes']['new_tags'] = list(remote_tags.symmetric_difference(
|
||||
all_local_tags
|
||||
))
|
||||
|
||||
if not has_remote_rev:
|
||||
try:
|
||||
@ -2221,11 +2238,11 @@ def detached(name,
|
||||
return ret
|
||||
|
||||
# Determine if supplied ref is a hash
|
||||
remote_ref_type = 'ref'
|
||||
remote_rev_type = 'ref'
|
||||
if len(ref) <= 40 \
|
||||
and all(x in string.hexdigits for x in ref):
|
||||
ref = ref.lower()
|
||||
remote_ref_type = 'hash'
|
||||
remote_rev_type = 'hash'
|
||||
|
||||
comments = []
|
||||
hash_exists_locally = False
|
||||
@ -2238,12 +2255,17 @@ def detached(name,
|
||||
|
||||
local_commit_id = _get_local_rev_and_branch(target, user, password)[0]
|
||||
|
||||
if remote_ref_type is 'hash' \
|
||||
and __salt__['git.describe'](target,
|
||||
if remote_rev_type is 'hash':
|
||||
try:
|
||||
__salt__['git.describe'](target,
|
||||
ref,
|
||||
user=user,
|
||||
password=password):
|
||||
# The ref is a hash and it exists locally so skip to checkout
|
||||
password=password,
|
||||
ignore_retcode=True)
|
||||
except CommandExecutionError:
|
||||
hash_exists_locally = False
|
||||
else:
|
||||
# The rev is a hash and it exists locally so skip to checkout
|
||||
hash_exists_locally = True
|
||||
else:
|
||||
# Check that remote is present and set to correct url
|
||||
@ -2409,7 +2431,7 @@ def detached(name,
|
||||
|
||||
#get refs and checkout
|
||||
checkout_commit_id = ''
|
||||
if remote_ref_type is 'hash':
|
||||
if remote_rev_type is 'hash':
|
||||
if __salt__['git.describe'](target, ref, user=user, password=password):
|
||||
checkout_commit_id = ref
|
||||
else:
|
||||
|
@ -1,6 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Some of the utils used by salt
|
||||
|
||||
NOTE: The dev team is working on splitting up this file for the Oxygen release.
|
||||
Please do not add any new functions to this file. New functions should be
|
||||
organized in other files under salt/utils/. Please consult the dev team if you
|
||||
are unsure where a new function should go.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
|
@ -40,7 +40,7 @@ class NpmStateTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
|
||||
'''
|
||||
Determine if URL-referenced NPM module can be successfully installed.
|
||||
'''
|
||||
ret = self.run_state('npm.installed', name='git://github.com/request/request')
|
||||
ret = self.run_state('npm.installed', name='request/request#v2.81.1')
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state('npm.removed', name='git://github.com/request/request')
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
@ -49,12 +49,57 @@ class GenesisTestCase(TestCase):
|
||||
with patch.dict(genesis.__salt__, {'disk.blkid': MagicMock(return_value={})}):
|
||||
self.assertEqual(genesis.bootstrap('rpm', 'root', 'dir'), None)
|
||||
|
||||
with patch.object(genesis, '_bootstrap_deb', return_value='A'):
|
||||
common_parms = {'platform': 'deb',
|
||||
'root': 'root',
|
||||
'img_format': 'dir',
|
||||
'arch': 'amd64',
|
||||
'flavor': 'stable',
|
||||
'static_qemu': 'qemu'}
|
||||
|
||||
param_sets = [
|
||||
|
||||
{'params': {},
|
||||
'cmd': ['debootstrap', '--foreign', '--arch', 'amd64',
|
||||
'stable', 'root', 'http://ftp.debian.org/debian/']
|
||||
},
|
||||
|
||||
{'params': {'pkgs': 'vim'},
|
||||
'cmd': ['debootstrap', '--foreign', '--arch', 'amd64',
|
||||
'--include', 'vim',
|
||||
'stable', 'root', 'http://ftp.debian.org/debian/']
|
||||
},
|
||||
|
||||
{'params': {'pkgs': 'vim,emacs'},
|
||||
'cmd': ['debootstrap', '--foreign', '--arch', 'amd64',
|
||||
'--include', 'vim,emacs',
|
||||
'stable', 'root', 'http://ftp.debian.org/debian/']
|
||||
},
|
||||
|
||||
{'params': {'pkgs': ['vim', 'emacs']},
|
||||
'cmd': ['debootstrap', '--foreign', '--arch', 'amd64',
|
||||
'--include', 'vim,emacs',
|
||||
'stable', 'root', 'http://ftp.debian.org/debian/']
|
||||
},
|
||||
|
||||
{'params': {'pkgs': ['vim', 'emacs'], 'exclude_pkgs': ['vim', 'foo']},
|
||||
'cmd': ['debootstrap', '--foreign', '--arch', 'amd64',
|
||||
'--include', 'vim,emacs', '--exclude', 'vim,foo',
|
||||
'stable', 'root', 'http://ftp.debian.org/debian/']
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
for param_set in param_sets:
|
||||
|
||||
with patch.dict(genesis.__salt__, {'mount.umount': MagicMock(),
|
||||
'file.rmdir': MagicMock(),
|
||||
'file.directory_exists': MagicMock()}):
|
||||
with patch.dict(genesis.__salt__, {'disk.blkid': MagicMock(return_value={})}):
|
||||
self.assertEqual(genesis.bootstrap('deb', 'root', 'dir'), None)
|
||||
'file.directory_exists': MagicMock(),
|
||||
'cmd.run': MagicMock(),
|
||||
'disk.blkid': MagicMock(return_value={})}):
|
||||
with patch('salt.modules.genesis.salt.utils.which', return_value=True):
|
||||
param_set['params'].update(common_parms)
|
||||
self.assertEqual(genesis.bootstrap(**param_set['params']), None)
|
||||
genesis.__salt__['cmd.run'].assert_any_call(param_set['cmd'], python_shell=False)
|
||||
|
||||
with patch.object(genesis, '_bootstrap_pacman', return_value='A') as pacman_patch:
|
||||
with patch.dict(genesis.__salt__, {'mount.umount': MagicMock(),
|
||||
|
Loading…
Reference in New Issue
Block a user