Merge branch '2018.3' into 'develop'

No conflicts.
This commit is contained in:
rallytime 2018-07-13 11:00:26 -04:00
commit 6c8fb063ac
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19
12 changed files with 2607 additions and 23 deletions

View file

@ -22,7 +22,6 @@ pipeline {
stage('build') {
steps {
sh 'eval "$(pyenv init -)"; make -C doc clean html'
archiveArtifacts artifacts: 'doc/_build/html/'
}
}
}

View file

@ -44,7 +44,7 @@ pipeline {
parserName: 'PyLint',
pattern: 'pylint-report*.xml'
]],
unstableTotalAll: '999',
failedTotalAll: '1',
usePreviousBuildAsReference: true
])
cleanWs()

File diff suppressed because it is too large Load diff

View file

@ -24,7 +24,7 @@ pycrypto==2.6.1
pycurl==7.43.0
PyMySQL==0.7.11
pyOpenSSL==17.5.0
python-certifi-win32==1.2
#python-certifi-win32==1.2
python-dateutil==2.6.1
python-gnupg==0.4.1
pythonnet==2.3.0

View file

@ -11,6 +11,7 @@ import time
# Import salt libs
import salt.utils.path
import salt.utils.stringutils
import salt.utils.vt
__virtualname__ = 'sh'
@ -81,14 +82,14 @@ def beacon(config):
stream_stdout=False,
stream_stderr=False)
__context__[pkey][pid]['user'] = ps_out[pid].get('user')
for pid in __context__[pkey]:
for pid in list(__context__[pkey]):
out = ''
err = ''
while __context__[pkey][pid]['vt'].has_unread_data:
tout, terr = __context__[pkey][pid]['vt'].recv()
if not terr:
break
out += tout
out += salt.utils.stringutils.to_unicode(tout or '')
err += terr
for line in err.split('\n'):
event = {'args': [],

View file

@ -957,7 +957,7 @@ def alter_db(name, character_set=None, collate=None, **connection_args):
return []
cur = dbc.cursor()
existing = db_get(name, **connection_args)
qry = 'ALTER DATABASE {0} CHARACTER SET {1} COLLATE {2};'.format(
qry = 'ALTER DATABASE `{0}` CHARACTER SET {1} COLLATE {2};'.format(
name.replace('%', r'\%').replace('_', r'\_'),
character_set or existing.get('character_set'),
collate or existing.get('collate'))
@ -1810,11 +1810,16 @@ def grant_exists(grant,
if not target_tokens: # Avoid the overhead of re-calc in loop
target_tokens = _grant_to_tokens(target)
grant_tokens = _grant_to_tokens(grant)
grant_tokens_database = grant_tokens['database'].replace('"', '').replace('\\', '').replace('`', '')
target_tokens_database = target_tokens['database'].replace('"', '').replace('\\', '').replace('`', '')
if grant_tokens['user'] == target_tokens['user'] and \
grant_tokens_database == target_tokens_database and \
grant_tokens['host'] == target_tokens['host'] and \
_grant_tokens = {}
_target_tokens = {}
for item in ['user', 'database', 'host']:
_grant_tokens[item] = grant_tokens[item].replace('"', '').replace('\\', '').replace('`', '')
_target_tokens[item] = target_tokens[item].replace('"', '').replace('\\', '').replace('`', '')
if _grant_tokens['user'] == _target_tokens['user'] and \
_grant_tokens['database'] == _target_tokens['database'] and \
_grant_tokens['host'] == _target_tokens['host'] and \
set(grant_tokens['grant']) >= set(target_tokens['grant']):
return True
else:

View file

@ -6132,7 +6132,7 @@ def copy_(name,
if not os.path.isdir(dname):
if makedirs:
try:
_makedirs(name=name)
_makedirs(name=name, user=user, group=group, dir_mode=mode)
except CommandExecutionError as exc:
return _error(ret, 'Drive {0} is not mapped'.format(exc.message))
else:

View file

@ -72,9 +72,16 @@ def _changes(name,
delusers = [salt.utils.win_functions.get_sam_name(user).lower() for user in delusers]
change = {}
ret = {}
if gid:
if lgrp['gid'] != gid:
change['gid'] = gid
try:
gid = int(gid)
if lgrp['gid'] != gid:
change['gid'] = gid
except (TypeError, ValueError):
ret['result'] = False
ret['comment'] = 'Invalid gid'
return ret
if members:
# -- if new member list if different than the current

View file

@ -23,6 +23,7 @@ from tests.support.helpers import flaky, expensiveTest
from tests.support.mock import MagicMock, patch
# Import Salt Libs
import salt.exceptions
import salt.utils.platform
import salt.utils.event
import salt.utils.files
@ -62,7 +63,6 @@ class StateRunnerTest(ShellCase):
Also test against some sample "good" output that would be included in a correct
orchestrate run.
'''
#ret_output = self.run_run_plus('state.orchestrate', 'orch.simple')['out']
ret_output = self.run_run('state.orchestrate orch.simple')
bad_out = ['outputter:', ' highstate']
good_out = [' Function: salt.state',
@ -212,8 +212,8 @@ class StateRunnerTest(ShellCase):
' Result: False']
second = [' ID: test-state',
' Function: salt.state',
' Result: True']
' Function: salt.state',
' Result: True']
third = [' ID: cmd.run',
' Function: salt.function',

View file

@ -24,6 +24,7 @@ from tests.support.case import ModuleCase
from tests.support.unit import skipIf
from tests.support.paths import FILES, TMP, TMP_STATE_TREE
from tests.support.helpers import (
destructiveTest,
skip_if_not_root,
with_system_user_and_group,
with_tempdir,
@ -143,6 +144,10 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
'''
remove files created in previous tests
'''
user = 'salt'
if user in str(self.run_function('user.list_users', [user])):
self.run_function('user.delete', [user])
for path in (FILEPILLAR, FILEPILLARDEF, FILEPILLARGIT):
try:
os.remove(path)
@ -2304,6 +2309,30 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
self.assertTrue(os.path.exists(dest))
self.assertTrue(filecmp.cmp(source, dest))
os.remove(source)
os.remove(dest)
@destructiveTest
@with_tempfile()
def test_file_copy_make_dirs(self, source):
'''
ensure make_dirs creates correct user perms
'''
shutil.copyfile(os.path.join(FILES, 'hosts'), source)
dest = os.path.join(TMP, 'dir1', 'dir2', 'copied_file.txt')
user = 'salt'
mode = '0644'
self.run_function('user.add', [user])
ret = self.run_state('file.copy', name=dest, source=source, user=user,
makedirs=True, mode=mode)
file_checks = [dest, os.path.join(TMP, 'dir1'), os.path.join(TMP, 'dir1', 'dir2')]
for check in file_checks:
user_check = self.run_function('file.get_user', [check])
mode_check = self.run_function('file.get_mode', [check])
assert user_check == user
assert salt.utils.files.normalize_mode(mode_check) == mode
def test_contents_pillar_with_pillar_list(self):
'''
This tests for any regressions for this issue:

View file

@ -33,7 +33,7 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin):
Basic test to determine if NPM module was successfully installed and
removed.
'''
ret = self.run_state('npm.installed', name='pm2', registry="http://registry.npmjs.org/")
ret = self.run_state('npm.installed', name='pm2@2.10.4', registry="http://registry.npmjs.org/")
self.assertSaltTrueReturn(ret)
ret = self.run_state('npm.removed', name='pm2')
self.assertSaltTrueReturn(ret)
@ -69,7 +69,7 @@ class NpmStateTest(ModuleCase, SaltReturnAssertsMixin):
Basic test to determine if NPM module successfully installs multiple
packages.
'''
ret = self.run_state('npm.installed', name='unused', pkgs=['pm2', 'grunt'], registry="http://registry.npmjs.org/")
ret = self.run_state('npm.installed', name='unused', pkgs=['pm2@2.10.4', 'grunt@1.0.2'], registry="http://registry.npmjs.org/")
self.assertSaltTrueReturn(ret)
@skipIf(salt.utils.path.which('npm') and LooseVersion(cmd.run('npm -v')) >= LooseVersion(MAX_NPM_VERSION),

View file

@ -4,7 +4,7 @@ skip_missing_interpreters = True
skipsdist = True
[testenv]
deps = -r{toxinidir}/requirements/tests.txt
deps = -Ur{toxinidir}/requirements/tests.txt
commands = pytest --rootdir {toxinidir} {posargs}
passenv = LANG HOME
sitepackages = True