Merge branch '2015.8' into '2016.3'

No conflicts.
This commit is contained in:
rallytime 2016-06-28 14:26:24 -06:00
commit f9ab8ba46d
21 changed files with 77 additions and 45 deletions

View file

@ -64,8 +64,8 @@ Examples:
Default: ``warning``
The level of log record messages to send to the console.
One of ``all``, ``garbage``, ``trace``, ``debug``, ``info``, ``warning``,
The level of log record messages to send to the console. One of ``all``,
``garbage``, ``trace``, ``debug``, ``profile``, ``info``, ``warning``,
``error``, ``critical``, ``quiet``.
.. code-block:: yaml
@ -85,9 +85,9 @@ One of ``all``, ``garbage``, ``trace``, ``debug``, ``info``, ``warning``,
Default: ``info``
The level of messages to send to the log file.
One of ``all``, ``garbage``, ``trace``, ``debug``, ``info``, ``warning``,
``error``, ``critical``, ``quiet``.
The level of messages to send to the log file. One of ``all``, ``garbage``,
``trace``, ``debug``, ``profile``, ``info``, ``warning``, ``error``,
``critical``, ``quiet``.
.. code-block:: yaml

View file

@ -410,13 +410,23 @@ to test states:
.. code-block:: python
# Import python libs
from __future__ import absolute_import
import os
import shutil
# Import Salt Testing libs
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import salt libs
import integration
import salt.utils
HFILE = os.path.join(integration.TMP, 'hosts')
class HostTest(integration.ModuleCase):
class HostTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
'''
Validate the host state
'''
@ -437,9 +447,8 @@ to test states:
name = 'spam.bacon'
ip = '10.10.10.10'
ret = self.run_state('host.present', name=name, ip=ip)
result = self.state_result(ret)
self.assertTrue(result)
with open(HFILE) as fp_:
self.assertSaltTrueReturn(ret)
with salt.utils.fopen(HFILE) as fp_:
output = fp_.read()
self.assertIn('{0}\t\t{1}'.format(ip, name), output)

View file

@ -60,7 +60,7 @@ def __define_global_system_encoding_variable__():
# than expected. See:
# https://github.com/saltstack/salt/issues/21036
if sys.version_info[0] < 3:
import __builtin__ as builtins
import __builtin__ as builtins # pylint: disable=incompatible-py3-code
else:
import builtins # pylint: disable=import-error

View file

@ -142,7 +142,7 @@ except Exception:
# Disable InsecureRequestWarning generated on python > 2.6
try:
from requests.packages.urllib3 import disable_warnings
from requests.packages.urllib3 import disable_warnings # pylint: disable=no-name-in-module
disable_warnings()
except Exception:
pass

View file

@ -71,13 +71,19 @@ def set_config(config_file='/etc/dnsmasq.conf', follow=True, **kwargs):
to the end of the main config file (and not to any includes). If you need
an option added to a specific include file, specify it as the config_file.
:param string config_file: config file where settings should be updated / added.
:param bool follow: attempt to set the config option inside any file within
the ``conf-dir`` where it has already been enabled.
:param kwargs: key value pairs that contain the configuration settings that you
want set.
CLI Examples:
.. code-block:: bash
salt '*' dnsmasq.set_config domain=mydomain.com
salt '*' dnsmasq.set_config follow=False domain=mydomain.com
salt '*' dnsmasq.set_config file=/etc/dnsmasq.conf domain=mydomain.com
salt '*' dnsmasq.set_config config_file=/etc/dnsmasq.conf domain=mydomain.com
'''
dnsopts = get_config(config_file)
includes = [config_file]

View file

@ -2871,6 +2871,13 @@ def copy(src, dst, recurse=False, remove_existing=False):
remove_existing will remove all files in the target directory,
and then copy files from the source.
.. note::
The copy function accepts paths that are local to the Salt minion.
This function does not support salt://, http://, or the other
additional file paths that are supported by :mod:`states.file.managed
<salt.states.file.managed>` and :mod:`states.file.recurse
<salt.states.file.recurse>`.
CLI Example:
.. code-block:: bash

View file

@ -343,7 +343,7 @@ def __is_long(token):
def __get_long(token):
if six.PY2:
return long(token[0:-1])
return long(token[0:-1]) # pylint: disable=incompatible-py3-code
else:
return int(token[0:-1])

View file

@ -153,7 +153,9 @@ class Serial(object):
for idx, entry in enumerate(obj):
obj[idx] = verylong_encoder(entry)
return obj
if six.PY2 and isinstance(obj, long) and long > pow(2, 64):
# This is a spurious lint failure as we are gating this check
# behind a check for six.PY2.
if six.PY2 and isinstance(obj, long) and long > pow(2, 64): # pylint: disable=incompatible-py3-code
return str(obj)
elif six.PY3 and isinstance(obj, int) and int > pow(2, 64):
return str(obj)

View file

@ -390,7 +390,7 @@ Dumper.add_multi_representer(type(None), Dumper.represent_none)
if six.PY2:
Dumper.add_multi_representer(six.binary_type, Dumper.represent_str)
Dumper.add_multi_representer(six.text_type, Dumper.represent_unicode)
Dumper.add_multi_representer(long, Dumper.represent_long)
Dumper.add_multi_representer(long, Dumper.represent_long) # pylint: disable=incompatible-py3-code
else:
Dumper.add_multi_representer(six.binary_type, Dumper.represent_binary)
Dumper.add_multi_representer(six.text_type, Dumper.represent_str)

View file

@ -75,7 +75,7 @@ Available Functions
docker.running:
- container: mysuperdocker
- image: corp/mysuperdocker_img
- port_bindings:
- ports:
- "5000/tcp":
HostIp: ""
HostPort: "5000"

View file

@ -1115,7 +1115,10 @@ def managed(name,
source
The source file to download to the minion, this source file can be
hosted on either the salt master server, or on an HTTP or FTP server.
hosted on either the salt master server (``salt://``), the salt minion
local file system (``/``), or on an HTTP or FTP server (``http(s)://``,
``ftp://``).
Both HTTPS and HTTP are supported as well as downloading directly
from Amazon S3 compatible URLs with both pre-configured and automatic
IAM credentials. (see s3.get state documentation)
@ -4082,6 +4085,14 @@ def copy(
If the name is a directory then place the file inside the named
directory
.. note::
The copy function accepts paths that are local to the Salt minion.
This function does not support salt://, http://, or the other
additional file paths that are supported by :mod:`states.file.managed
<salt.states.file.managed>` and :mod:`states.file.recurse
<salt.states.file.recurse>`.
'''
name = os.path.expanduser(name)
source = os.path.expanduser(source)

View file

@ -774,9 +774,6 @@ def flush(name, table='filter', family='ipv4', **kwargs):
if ignore in kwargs:
del kwargs[ignore]
if 'table' not in kwargs:
table = 'filter'
if 'chain' not in kwargs:
kwargs['chain'] = ''
if __opts__['test']:

View file

@ -2,6 +2,7 @@
'''
Manage Windows features via the ServerManager powershell module
'''
from __future__ import absolute_import
# Import salt modules
import salt.utils

View file

@ -2046,11 +2046,7 @@ def alias_function(fun, name, doc=None):
if doc and isinstance(doc, six.string_types):
alias_fun.__doc__ = doc
else:
if six.PY3:
orig_name = fun.__name__
else:
orig_name = fun.func_name
orig_name = fun.__name__
alias_msg = ('\nThis function is an alias of '
'``{0}``.\n'.format(orig_name))
alias_fun.__doc__ = alias_msg + fun.__doc__
@ -2843,7 +2839,7 @@ def to_str(s, encoding=None):
else:
if isinstance(s, bytearray):
return str(s)
if isinstance(s, unicode):
if isinstance(s, unicode): # pylint: disable=incompatible-py3-code
return s.encode(encoding or __salt_system_encoding__)
raise TypeError('expected str, bytearray, or unicode')
@ -2874,7 +2870,7 @@ def to_unicode(s, encoding=None):
else:
if isinstance(s, str):
return s.decode(encoding or __salt_system_encoding__)
return unicode(s)
return unicode(s) # pylint: disable=incompatible-py3-code
def is_list(value):

View file

@ -27,7 +27,7 @@ def condition_input(args, kwargs):
# XXX: We might need to revisit this code when we move to Py3
# since long's are int's in Py3
if (six.PY3 and isinstance(arg, six.integer_types)) or \
(six.PY2 and isinstance(arg, long)):
(six.PY2 and isinstance(arg, long)): # pylint: disable=incompatible-py3-code
ret.append(str(arg))
else:
ret.append(arg)

View file

@ -38,7 +38,7 @@ def deepcopy_bound(name):
'''
def _deepcopy_method(x, memo):
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class)
return type(x)(x.im_func, copy.deepcopy(x.im_self, memo), x.im_class) # pylint: disable=incompatible-py3-code
try:
pre_dispatch = copy._deepcopy_dispatch
copy._deepcopy_dispatch[types.MethodType] = _deepcopy_method

View file

@ -303,13 +303,13 @@ class _DeprecationDecorator(object):
try:
return self._function(*args, **kwargs)
except TypeError as error:
error = str(error).replace(self._function.func_name, self._orig_f_name) # Hide hidden functions
error = str(error).replace(self._function.__name__, self._orig_f_name) # Hide hidden functions
log.error('Function "{f_name}" was not properly called: {error}'.format(f_name=self._orig_f_name,
error=error))
return self._function.__doc__
except Exception as error:
log.error('Unhandled exception occurred in '
'function "{f_name}: {error}'.format(f_name=self._function.func_name,
'function "{f_name}: {error}'.format(f_name=self._function.__name__,
error=error))
raise error
else:
@ -324,7 +324,7 @@ class _DeprecationDecorator(object):
:return:
'''
self._function = function
self._orig_f_name = self._function.func_name
self._orig_f_name = self._function.__name__
class _IsDeprecated(_DeprecationDecorator):
@ -405,13 +405,13 @@ class _IsDeprecated(_DeprecationDecorator):
'''
if self._curr_version < self._exp_version:
msg = ['The function "{f_name}" is deprecated and will '
'expire in version "{version_name}".'.format(f_name=self._function.func_name,
'expire in version "{version_name}".'.format(f_name=self._function.__name__,
version_name=self._exp_version_name)]
if self._successor:
msg.append('Use successor "{successor}" instead.'.format(successor=self._successor))
log.warning(' '.join(msg))
else:
msg = ['The lifetime of the function "{f_name}" expired.'.format(f_name=self._function.func_name)]
msg = ['The lifetime of the function "{f_name}" expired.'.format(f_name=self._function.__name__)]
if self._successor:
msg.append('Please use its successor "{successor}" instead.'.format(successor=self._successor))
log.warning(' '.join(msg))
@ -513,13 +513,13 @@ class _WithDeprecated(_DeprecationDecorator):
:return:
'''
full_name = "{m_name}.{f_name}".format(m_name=self._globals.get(self.MODULE_NAME, ''),
f_name=function.func_name)
f_name=function.__name__)
if full_name.startswith("."):
self._raise_later = CommandExecutionError('Module not found for function "{f_name}"'.format(
f_name=function.func_name))
f_name=function.__name__))
if full_name in self._options.get(self.CFG_KEY, list()):
self._function = self._globals.get(self._with_name or "_{0}".format(function.func_name))
self._function = self._globals.get(self._with_name or "_{0}".format(function.__name__))
def _is_used_deprecated(self):
'''
@ -565,7 +565,7 @@ class _WithDeprecated(_DeprecationDecorator):
log.warning(' '.join(msg))
else:
msg_patt = 'The lifetime of the function "{f_name}" expired.'
if '_' + self._orig_f_name == self._function.func_name:
if '_' + self._orig_f_name == self._function.__name__:
msg = [msg_patt.format(f_name=self._orig_f_name),
'Please turn off its deprecated version in the configuration']
else:

View file

@ -9,15 +9,18 @@ import re
import sys
import platform
# Don't rely on external packages in this module since it's used at install time
# pylint: disable=invalid-name,redefined-builtin
# Import 3rd-party libs
from salt.ext import six
from salt.ext.six.moves import map
# Don't rely on external packages in this module since it's used at install time
if sys.version_info[0] == 3:
MAX_SIZE = sys.maxsize
string_types = (str,)
else:
MAX_SIZE = sys.maxint
string_types = (basestring,)
from itertools import imap as map
string_types = (six.string_types,)
# pylint: enable=invalid-name,redefined-builtin
# ----- ATTENTION --------------------------------------------------------------------------------------------------->

View file

@ -215,7 +215,7 @@ class PkgTest(integration.ModuleCase,
# If this assert fails, we need to find new targets, this test needs to
# be able to test successful installation of packages, so these
# packages need to not be installed before we run the states below
#self.assertFalse(any(version.values()))
self.assertFalse(any(version.values()))
ret = self.run_state('pkg.installed', name=None, pkgs=pkg_targets)
self.assertSaltTrueReturn(ret)

View file

@ -124,7 +124,7 @@ class PCAPParser(object):
'tcp': {}
}
(header, packet) = cap.next()
(header, packet) = cap.next() # pylint: disable=incompatible-py3-code
eth_length, eth_protocol = self.parse_ether(packet)

View file

@ -353,8 +353,8 @@ class IptablesTestCase(TestCase):
with patch.dict(iptables.__salt__,
{'iptables.flush': mock}):
ret.update({'changes': {'locale': 'salt'},
'comment': 'Flush iptables rules in '
'filter table chain ipv4 family',
'comment': 'Flush iptables rules in '
'table chain ipv4 family',
'result': True})
self.assertDictEqual(iptables.flush('salt',
table='', chain=''),