Merge branch '2017.7' into libcloud_dns_fixes

This commit is contained in:
Nicole Thomas 2017-12-14 12:38:05 -05:00 committed by GitHub
commit e9bbc23b11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 53 additions and 38 deletions

View file

@ -67,8 +67,8 @@ Engage SaltStack
`SaltConf`_, **User Groups and Meetups** - SaltStack has a vibrant and `global
community`_ of customers, users, developers and enthusiasts. Connect with other
Salted folks in your area of the world, or join `SaltConf16`_, the SaltStack
annual user conference, April 19-21 in Salt Lake City. Please let us know if
Salted folks in your area of the world, or join `SaltConf18`_, the SaltStack
annual user conference, September 10-14 in Salt Lake City. Please let us know if
you would like to start a user group or if we should add your existing
SaltStack user group to this list by emailing: info@saltstack.com
@ -91,7 +91,7 @@ services`_ offerings.
.. _SaltConf: http://www.youtube.com/user/saltstack
.. _global community: http://www.meetup.com/pro/saltstack/
.. _SaltConf16: http://saltconf.com/
.. _SaltConf18: http://saltconf.com/
.. _SaltStack education offerings: http://saltstack.com/training/
.. _SaltStack Certified Engineer (SSCE): http://saltstack.com/certification/
.. _SaltStack professional services: http://saltstack.com/services/

View file

@ -1542,13 +1542,13 @@ Example:
.. code-block:: jinja
regex_escape = {{ 'https://example.com?foo=bar%20baz' | regex_escape }}
regex_escape = {{ 'https://example.com?foo=bar%20baz' | regex_escape }}
will be rendered as:
.. code-block:: text
regex_escape = https\:\/\/example\.com\?foo\=bar\%20baz
regex_escape = https\:\/\/example\.com\?foo\=bar\%20baz
Set Theory Filters
------------------
@ -1566,13 +1566,13 @@ Example:
.. code-block:: jinja
unique = {{ ['foo', 'foo', 'bar'] | unique }}
unique = {{ ['foo', 'foo', 'bar'] | unique }}
will be rendered as:
.. code-block:: text
unique = ['foo', 'bar']
unique = ['foo', 'bar']
Jinja in Files
==============

View file

@ -10,6 +10,7 @@ import socket
import ctypes
import os
import ipaddress
import salt.ext.six as six
class sockaddr(ctypes.Structure):
@ -36,7 +37,7 @@ def inet_pton(address_family, ip_string):
# This will catch IP Addresses such as 10.1.2
if address_family == socket.AF_INET:
try:
ipaddress.ip_address(ip_string.decode())
ipaddress.ip_address(six.u(ip_string))
except ValueError:
raise socket.error('illegal IP address string passed to inet_pton')
return socket.inet_aton(ip_string)

View file

@ -144,17 +144,17 @@ def _parse_acl(acl, user, group):
# Set the permissions fields
octal = 0
vals['permissions'] = {}
if 'r' in comps[2]:
if 'r' in comps[-1]:
octal += 4
vals['permissions']['read'] = True
else:
vals['permissions']['read'] = False
if 'w' in comps[2]:
if 'w' in comps[-1]:
octal += 2
vals['permissions']['write'] = True
else:
vals['permissions']['write'] = False
if 'x' in comps[2]:
if 'x' in comps[-1]:
octal += 1
vals['permissions']['execute'] = True
else:

View file

@ -245,7 +245,7 @@ def install_ruby(ruby, runas=None):
ret = {}
ret = _rbenv_exec(['install', ruby], env=env, runas=runas, ret=ret)
if ret['retcode'] == 0:
if ret is not False and ret['retcode'] == 0:
rehash(runas=runas)
return ret['stderr']
else:

View file

@ -316,7 +316,7 @@ def get_site_packages(venv):
ret = __salt__['cmd.exec_code_all'](
bin_path,
'from distutils import sysconfig; '
'print sysconfig.get_python_lib()'
'print(sysconfig.get_python_lib())'
)
if ret['retcode'] != 0:

View file

@ -276,10 +276,9 @@ def list_available(*names, **kwargs):
saltenv = kwargs.get('saltenv', 'base')
refresh = salt.utils.is_true(kwargs.get('refresh', False))
_refresh_db_conditional(saltenv, force=refresh)
return_dict_always = \
salt.utils.is_true(kwargs.get('return_dict_always', False))
_refresh_db_conditional(saltenv, force=refresh)
if len(names) == 1 and not return_dict_always:
pkginfo = _get_package_info(names[0], saltenv=saltenv)
if not pkginfo:
@ -356,6 +355,7 @@ def list_pkgs(versions_as_list=False, **kwargs):
List the packages currently installed
Args:
version_as_list (bool): Returns the versions as a list
Kwargs:
saltenv (str): The salt environment to use. Default ``base``.
@ -1069,7 +1069,6 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
'''
ret = {}
saltenv = kwargs.pop('saltenv', 'base')
refresh = salt.utils.is_true(refresh)
# no need to call _refresh_db_conditional as list_pkgs will do it
@ -1256,6 +1255,7 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
log.debug('Source hash matches package hash.')
# Get install flags
install_flags = pkginfo[version_num].get('install_flags', '')
if options and options.get('extra_install_flags'):
install_flags = '{0} {1}'.format(
@ -1330,14 +1330,12 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
log.error('Scheduled Task failed to run')
ret[pkg_name] = {'install status': 'failed'}
else:
# Launch the command
result = __salt__['cmd.run_all'](
'"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
cache_path,
output_loglevel='trace',
python_shell=False,
redirect_stderr=True)
result = __salt__['cmd.run_all']('"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
cache_path,
output_loglevel='trace',
python_shell=False,
redirect_stderr=True)
if not result['retcode']:
ret[pkg_name] = {'install status': 'success'}
changed.append(pkg_name)
@ -1514,7 +1512,6 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
removal_targets.append(version_num)
for target in removal_targets:
# Get the uninstaller
uninstaller = pkginfo[target].get('uninstaller', '')
cache_dir = pkginfo[target].get('cache_dir', False)
@ -1539,6 +1536,7 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
# If true, the entire directory will be cached instead of the
# individual file. This is useful for installations that are not
# single files
if cache_dir and uninstaller.startswith('salt:'):
path, _ = os.path.split(uninstaller)
__salt__['cp.cache_dir'](path,
@ -1579,15 +1577,13 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
else:
# Run the uninstaller directly
# (not hosted on salt:, https:, etc.)
cached_pkg = uninstaller
cached_pkg = os.path.expandvars(uninstaller)
# Fix non-windows slashes
cached_pkg = cached_pkg.replace('/', '\\')
cache_path, _ = os.path.split(cached_pkg)
# Get parameters for cmd
expanded_cached_pkg = str(os.path.expandvars(cached_pkg))
expanded_cache_path = str(os.path.expandvars(cache_path))
# os.path.expandvars is not required as we run everything through cmd.exe /s /c
# Get uninstall flags
uninstall_flags = pkginfo[target].get('uninstall_flags', '')
@ -1603,9 +1599,11 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
# Build cmd and arguments
# cmd and arguments must be separated for use with the task scheduler
if use_msiexec:
arguments = '"{0}" /X "{1}"'.format(msiexec, uninstaller if uninstaller else expanded_cached_pkg)
# Check if uninstaller is set to {guid}, if not we assume its a remote msi file.
# which has already been downloaded.
arguments = '"{0}" /X "{1}"'.format(msiexec, cached_pkg)
else:
arguments = '"{0}"'.format(expanded_cached_pkg)
arguments = '"{0}"'.format(cached_pkg)
if uninstall_flags:
arguments = '{0} {1}'.format(arguments, uninstall_flags)
@ -1620,7 +1618,7 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
action_type='Execute',
cmd=cmd_shell,
arguments='/s /c "{0}"'.format(arguments),
start_in=expanded_cache_path,
start_in=cache_path,
trigger_type='Once',
start_date='1975-01-01',
start_time='01:00',
@ -1635,7 +1633,6 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
# Launch the command
result = __salt__['cmd.run_all'](
'"{0}" /s /c "{1}"'.format(cmd_shell, arguments),
expanded_cache_path,
output_loglevel='trace',
python_shell=False,
redirect_stderr=True)

View file

@ -37,7 +37,7 @@ log = logging.getLogger(__name__)
def _ping(tgt, tgt_type, timeout, gather_job_timeout):
client = salt.client.get_local_client(__opts__['conf_file'])
pub_data = client.run_job(tgt, 'test.ping', (), tgt_type, '', timeout, '')
pub_data = client.run_job(tgt, 'test.ping', (), tgt_type, '', timeout, '', listen=True)
if not pub_data:
return pub_data

View file

@ -142,12 +142,12 @@ def get_pidfile(pidfile):
'''
Return the pid from a pidfile as an integer
'''
with salt.utils.fopen(pidfile) as pdf:
pid = pdf.read()
if pid:
try:
with salt.utils.fopen(pidfile) as pdf:
pid = pdf.read().strip()
return int(pid)
else:
return
except (OSError, IOError, TypeError, ValueError):
return None
def clean_proc(proc, wait_for_kill=10):

View file

@ -63,6 +63,22 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
linux_acl.getfacl(*self.files, recursive=True)
self.cmdrun.assert_called_once_with('getfacl --absolute-names -R ' + ' '.join(self.quoted_files), python_shell=False)
def test_getfacl__effective_acls(self):
line = 'group:webmaster:r-x #effective:---'
user = 'root'
group = 'root'
expected = {
'type': 'acl',
'group': 'webmaster',
'permissions': {
'read': False,
'write': False,
'execute': False
},
'octal': 0,
}
self.assertEqual(linux_acl._parse_acl(line, user, group), expected)
def test_wipefacls_wo_args(self):
self.assertRaises(CommandExecutionError, linux_acl.wipefacls)

View file

@ -489,6 +489,7 @@ class LogSettingsParserTests(TestCase):
# Check log file logger
self.assertEqual(self.log_setup.log_level_logfile, log_level_logfile)
@skipIf(salt.utils.is_windows(), 'Windows uses a logging listener')
def test_log_created(self):
'''
Tests that log file is created