mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Merge pull request #48487 from rallytime/merge-2018.3
[2018.3] Merge forward from 2017.7 to 2018.3
This commit is contained in:
commit
fc3eeef6b3
7
.ci/lint
7
.ci/lint
@ -16,8 +16,7 @@ pipeline {
|
||||
stage('setup') {
|
||||
steps {
|
||||
sh 'eval "$(pyenv init -)"; pyenv install 2.7.14 || echo "We already have this python."; pyenv local 2.7.14; pyenv shell 2.7.14'
|
||||
sh 'eval "$(pyenv init -)"; pip install pylint SaltPyLint'
|
||||
sh 'eval "$(pyenv init -)"; which pylint; pylint --version'
|
||||
sh 'eval "$(pyenv init -)"; pip install tox'
|
||||
}
|
||||
}
|
||||
stage('linting') {
|
||||
@ -25,13 +24,13 @@ pipeline {
|
||||
parallel {
|
||||
stage('salt linting') {
|
||||
steps {
|
||||
sh 'eval "$(pyenv init -)"; pylint --rcfile=.testing.pylintrc --disable=W1307,str-format-in-logging setup.py salt/ | tee pylint-report.xml'
|
||||
sh 'eval "$(pyenv init -)"; tox -e pylint-salt | tee pylint-report.xml'
|
||||
archiveArtifacts artifacts: 'pylint-report.xml'
|
||||
}
|
||||
}
|
||||
stage('test linting') {
|
||||
steps {
|
||||
sh 'eval "$(pyenv init -)"; pylint --rcfile=.testing.pylintrc --disable=W0232,E1002,W1307,str-format-in-logging tests/ | tee pylint-report-tests.xml'
|
||||
sh 'eval "$(pyenv init -)"; tox -e pylint-tests | tee pylint-report-tests.xml'
|
||||
archiveArtifacts artifacts: 'pylint-report-tests.xml'
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ Function Get-Settings {
|
||||
"SSLeay" = "ssleay32.dll"
|
||||
"OpenSSLLic" = "OpenSSL_License.txt"
|
||||
"msvcr" = "msvcr120.dll"
|
||||
"Libsodium" = "libsodium.dll"
|
||||
}
|
||||
$ini.Add("64bitDLLs", $64bitDLLs)
|
||||
|
||||
@ -86,6 +87,7 @@ Function Get-Settings {
|
||||
"SSLeay" = "ssleay32.dll"
|
||||
"OpenSSLLic" = "OpenSSL_License.txt"
|
||||
"msvcr" = "msvcr120.dll"
|
||||
"Libsodium" = "libsodium.dll"
|
||||
}
|
||||
$ini.Add("32bitDLLs", $32bitDLLs)
|
||||
|
||||
|
@ -9,34 +9,36 @@ salt for Windows with their corresponding licenses:
|
||||
| certifi | ISC |
|
||||
| cffi | MIT |
|
||||
| CherryPy | BSD |
|
||||
| cryptography | BSD |
|
||||
| enum34 | BSD |
|
||||
| futures | BSD |
|
||||
| gitdb | BSD |
|
||||
| GitPython | BSD |
|
||||
| idna | BSD-like |
|
||||
| ioflo | Apache 2.0 |
|
||||
| ioloop | MIT |
|
||||
| ipaddress | PSF |
|
||||
| Jinja2 | BSD |
|
||||
| libnacl | --- |
|
||||
| libnacl | Apache |
|
||||
| lxml | BSD |
|
||||
| Mako | MIT |
|
||||
| MarkupSafe | BSD |
|
||||
| msgpack-python | --- |
|
||||
| msgpack-python | Apache 2.0 |
|
||||
| pip | MIT |
|
||||
| psutil | BSD |
|
||||
| pyasn1 | BSD |
|
||||
| pycparser | BSD |
|
||||
| pycurl | LGPL + MIT |
|
||||
| PyMySQL | MIT |
|
||||
| pypiwin32 | PSF |
|
||||
| PyOpenSSL | Apache 2.0 |
|
||||
| python-certifi-win32 | BSD |
|
||||
| python-dateutil | Simplified BSD |
|
||||
| python-gnupg | BSD |
|
||||
| pywin32 | PSF |
|
||||
| PyYAML | MIT |
|
||||
| pyzmq | LGPL + BSD |
|
||||
| requests | Apache 2.0 |
|
||||
| setuptools | MIT |
|
||||
| singledispatch | MIT |
|
||||
| six | MIT |
|
||||
| smmap | BSD |
|
||||
| timelib | ZLIB/PHP |
|
||||
| tornado | Apache 2.0 |
|
||||
|
@ -12,6 +12,7 @@ idna==2.5
|
||||
ioloop==0.1a0
|
||||
ipaddress==1.0.18
|
||||
Jinja2==2.9.6
|
||||
libnacl==1.6.1 # required by the nacl module
|
||||
lxml==3.7.3
|
||||
Mako==1.0.6
|
||||
MarkupSafe==1.0
|
||||
@ -23,6 +24,7 @@ pycrypto==2.6.1
|
||||
pycurl==7.43.0
|
||||
PyMySQL==0.7.11
|
||||
pyOpenSSL==17.5.0
|
||||
python-certifi-win32==1.2
|
||||
python-dateutil==2.6.1
|
||||
python-gnupg==0.4.1
|
||||
pythonnet==2.3.0
|
||||
|
@ -11,3 +11,4 @@ testinfra>=1.7.0
|
||||
# satisfy other requirements, and httpretty 0.8.10 has bugs in setup.py that
|
||||
# prevent it from being successfully installed (at least on Python 3.4).
|
||||
httpretty; python_version >= '3.4'
|
||||
pylint==1.6.5
|
||||
|
@ -289,12 +289,14 @@ def raw_cron(user):
|
||||
# Preserve line endings
|
||||
lines = sdecode(__salt__['cmd.run_stdout'](cmd,
|
||||
runas=user,
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)).splitlines(True)
|
||||
else:
|
||||
cmd = 'crontab -u {0} -l'.format(user)
|
||||
# Preserve line endings
|
||||
lines = sdecode(__salt__['cmd.run_stdout'](cmd,
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)).splitlines(True)
|
||||
|
||||
|
@ -4539,6 +4539,27 @@ def check_perms(name, ret, user, group, mode, attrs=None, follow_symlinks=False)
|
||||
elif 'cgroup' in perms and user != '':
|
||||
ret['changes']['group'] = group
|
||||
|
||||
# Mode changes if needed
|
||||
if mode is not None:
|
||||
# File is a symlink, ignore the mode setting
|
||||
# if follow_symlinks is False
|
||||
if os.path.islink(name) and not follow_symlinks:
|
||||
pass
|
||||
else:
|
||||
mode = salt.utils.files.normalize_mode(mode)
|
||||
if mode != perms['lmode']:
|
||||
if __opts__['test'] is True:
|
||||
ret['changes']['mode'] = mode
|
||||
else:
|
||||
set_mode(name, mode)
|
||||
if mode != salt.utils.files.normalize_mode(get_mode(name)):
|
||||
ret['result'] = False
|
||||
ret['comment'].append(
|
||||
'Failed to change mode to {0}'.format(mode)
|
||||
)
|
||||
else:
|
||||
ret['changes']['mode'] = mode
|
||||
|
||||
if isinstance(orig_comment, six.string_types):
|
||||
if orig_comment:
|
||||
ret['comment'].insert(0, orig_comment)
|
||||
|
@ -19,6 +19,7 @@ Module to provide redis functionality to Salt
|
||||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
from salt.ext.six.moves import zip
|
||||
from salt.ext import six
|
||||
from salt.utils import clean_kwargs
|
||||
from datetime import datetime
|
||||
|
||||
# Import third party libs
|
||||
@ -395,7 +396,7 @@ def hmset(key, **fieldsvals):
|
||||
database = fieldsvals.pop('db', None)
|
||||
password = fieldsvals.pop('password', None)
|
||||
server = _connect(host, port, database, password)
|
||||
return server.hmset(key, **fieldsvals)
|
||||
return server.hmset(key, clean_kwargs(**fieldsvals))
|
||||
|
||||
|
||||
def hset(key, field, value, host=None, port=None, db=None, password=None):
|
||||
|
@ -203,8 +203,6 @@ import tornado.web
|
||||
import tornado.gen
|
||||
from tornado.concurrent import Future
|
||||
# pylint: enable=import-error
|
||||
import salt.utils
|
||||
salt.utils.zeromq.install_zmq()
|
||||
|
||||
# salt imports
|
||||
import salt.ext.six as six
|
||||
@ -214,6 +212,7 @@ import salt.utils.event
|
||||
import salt.utils.jid
|
||||
import salt.utils.json
|
||||
import salt.utils.yaml
|
||||
import salt.utils.zeromq
|
||||
from salt.utils.event import tagify
|
||||
import salt.client
|
||||
import salt.runner
|
||||
@ -224,6 +223,7 @@ from salt.exceptions import (
|
||||
EauthAuthenticationError
|
||||
)
|
||||
|
||||
salt.utils.zeromq.install_zmq()
|
||||
json = salt.utils.json.import_json()
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -153,7 +153,7 @@ def lookup_jid(jid,
|
||||
try:
|
||||
# Check if the return data has an 'out' key. We'll use that as the
|
||||
# outputter in the absence of one being passed on the CLI.
|
||||
outputter = data[next(iter(data))].get('out')
|
||||
outputter = returns[next(iter(returns))].get('out')
|
||||
except (StopIteration, AttributeError):
|
||||
outputter = None
|
||||
|
||||
|
@ -84,7 +84,7 @@ def _checksum_file_path(path):
|
||||
path.lstrip('/\\'),
|
||||
)
|
||||
elif str(exc).startswith('Cannot mix UNC'):
|
||||
relpath = salt.utils.path_join('unc', path)
|
||||
relpath = salt.utils.path.join('unc', path)
|
||||
else:
|
||||
raise
|
||||
ret = salt.utils.path.join(__opts__['cachedir'], 'archive_hash', relpath)
|
||||
|
4
setup.py
4
setup.py
@ -367,14 +367,14 @@ class DownloadWindowsDlls(Command):
|
||||
import pip
|
||||
# pip has moved many things to `_internal` starting with pip 10
|
||||
if LooseVersion(pip.__version__) < LooseVersion('10.0'):
|
||||
from pip.utils.logging import indent_log
|
||||
from pip.utils.logging import indent_log # pylint: disable=no-name-in-module
|
||||
else:
|
||||
from pip._internal.utils.logging import indent_log # pylint: disable=no-name-in-module
|
||||
platform_bits, _ = platform.architecture()
|
||||
url = 'https://repo.saltstack.com/windows/dependencies/{bits}/{fname}.dll'
|
||||
dest = os.path.join(os.path.dirname(sys.executable), '{fname}.dll')
|
||||
with indent_log():
|
||||
for fname in ('libeay32', 'ssleay32', 'msvcr120'):
|
||||
for fname in ('libeay32', 'libsodium', 'ssleay32', 'msvcr120'):
|
||||
# See if the library is already on the system
|
||||
if find_library(fname):
|
||||
continue
|
||||
|
@ -789,6 +789,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin):
|
||||
cron.raw_cron(STUB_USER)
|
||||
cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l",
|
||||
runas=STUB_USER,
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)
|
||||
|
||||
@ -803,6 +804,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin):
|
||||
MagicMock(return_value=False)):
|
||||
cron.raw_cron(STUB_USER)
|
||||
cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -u root -l",
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)
|
||||
|
||||
@ -818,6 +820,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin):
|
||||
cron.raw_cron(STUB_USER)
|
||||
cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l",
|
||||
runas=STUB_USER,
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)
|
||||
|
||||
@ -833,6 +836,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin):
|
||||
cron.raw_cron(STUB_USER)
|
||||
cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l",
|
||||
runas=STUB_USER,
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)
|
||||
|
||||
@ -848,6 +852,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin):
|
||||
cron.raw_cron(STUB_USER)
|
||||
cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l",
|
||||
runas=STUB_USER,
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)
|
||||
|
||||
@ -863,6 +868,7 @@ class CronTestCase(TestCase, LoaderModuleMockMixin):
|
||||
cron.raw_cron(STUB_USER)
|
||||
cron.__salt__['cmd.run_stdout'].assert_called_with("crontab -l",
|
||||
runas=STUB_USER,
|
||||
ignore_retcode=True,
|
||||
rstrip=False,
|
||||
python_shell=False)
|
||||
|
||||
|
@ -174,7 +174,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
'file.group_to_gid': mock_empty,
|
||||
'user.info': mock_empty,
|
||||
'user.current': mock_user}):
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
comt = ('User {0} does not exist'.format(user))
|
||||
ret = return_val({'comment': comt, 'name': name})
|
||||
else:
|
||||
@ -191,7 +191,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
'user.current': mock_user}):
|
||||
with patch.dict(filestate.__opts__, {'test': True}):
|
||||
with patch.object(os.path, 'exists', mock_f):
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
comt = ('User {0} does not exist'.format(user))
|
||||
ret = return_val(
|
||||
{
|
||||
@ -220,7 +220,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
with patch.dict(filestate.__opts__, {'test': False}):
|
||||
with patch.object(os.path, 'isdir', mock_f):
|
||||
with patch.object(os.path, 'exists', mock_f):
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
comt = 'User {0} does not exist'.format(user)
|
||||
ret = return_val(
|
||||
{
|
||||
@ -250,7 +250,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
with patch.object(os.path, 'isdir', mock_t):
|
||||
with patch.object(salt.states.file, '_check_symlink_ownership', mock_t):
|
||||
with patch('salt.utils.win_functions.get_sid_from_name', return_value='test-sid'):
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
comt = ('Symlink {0} is present and owned by '
|
||||
'{1}'.format(name, user))
|
||||
else:
|
||||
@ -1178,7 +1178,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
Test to ensure that some text appears at the beginning of a file.
|
||||
'''
|
||||
name = '/etc/motd'
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
name = 'c:\\etc\\motd'
|
||||
source = ['salt://motd/hr-messages.tmpl']
|
||||
sources = ['salt://motd/devops-messages.tmpl']
|
||||
@ -1205,13 +1205,14 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
{'file.directory_exists': mock_f,
|
||||
'file.makedirs': mock_t,
|
||||
'file.stats': mock_f,
|
||||
'file.touch': mock_t,
|
||||
'cp.get_template': mock_f,
|
||||
'file.search': mock_f,
|
||||
'file.prepend': mock_t}):
|
||||
comt = ('The following files will be changed:\n/etc:'
|
||||
' directory - new\n')
|
||||
pchanges = {'/etc': {'directory': 'new'}}
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
comt = 'The directory "c:\\etc" will be changed'
|
||||
pchanges = {'c:\\etc': {'directory': 'new'}}
|
||||
ret.update({'comment': comt, 'name': name, 'pchanges': pchanges})
|
||||
|
21
tox.ini
21
tox.ini
@ -1,10 +1,29 @@
|
||||
[tox]
|
||||
envlist = py27,py3
|
||||
envlist = py27,py34,py35,py36,pylint-salt,pylint-tests
|
||||
skip_missing_interpreters = True
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
deps = -r{toxinidir}/requirements/tests.txt
|
||||
commands = pytest --rootdir {toxinidir} {posargs}
|
||||
passenv = LANG HOME
|
||||
sitepackages = True
|
||||
|
||||
[testenv:pylint-salt]
|
||||
basepython = python2.7
|
||||
deps = -r{toxinidir}/requirements/dev.txt
|
||||
commands =
|
||||
pylint --version
|
||||
pylint --rcfile=.testing.pylintrc --disable=W1307,str-format-in-logging setup.py salt/
|
||||
sitepackages = False
|
||||
|
||||
[testenv:pylint-tests]
|
||||
basepython = python2.7
|
||||
deps = -r{toxinidir}/requirements/dev.txt
|
||||
commands =
|
||||
pylint --version
|
||||
pylint --rcfile=.testing.pylintrc --disable=W1307,str-format-in-logging setup.py salt/
|
||||
sitepackages = False
|
||||
|
||||
[pytest]
|
||||
addopts = --log-file /tmp/salt-runtests.log --no-print-logs --ssh-tests -ra -sv
|
||||
|
Loading…
Reference in New Issue
Block a user