Merge pull request #31457 from rallytime/merge-2015.8

[2015.8] Merge forward from 2015.5 to 2015.8
This commit is contained in:
Mike Place 2016-02-24 09:42:17 -07:00
commit 330c4d8b0f
6 changed files with 39 additions and 10 deletions

View file

@ -1356,22 +1356,40 @@ def _validate_opts(opts):
if isinstance(val, VALID_OPTS[key]):
continue
else:
errors.append(err.format(key, val, type(val), 'list'))
errors.append(
err.format(key, val, type(val).__name__, 'list')
)
if isinstance(VALID_OPTS[key](), dict):
if isinstance(val, VALID_OPTS[key]):
continue
else:
errors.append(err.format(key, val, type(val), 'dict'))
errors.append(
err.format(key, val, type(val).__name__, 'dict')
)
else:
try:
VALID_OPTS[key](val)
if isinstance(val, (list, dict)):
# We'll only get here if VALID_OPTS[key] is str or
# bool, and the passed value is a list/dict. Attempting
# to run int() or float() on a list/dict will raise an
# exception, but running str() or bool() on it will
# pass despite not being the correct type.
errors.append(
err.format(
key,
val,
type(val).__name__,
VALID_OPTS[key].__name__
)
)
except ValueError:
errors.append(
err.format(key, val, type(val), VALID_OPTS[key])
err.format(key, val, type(val).__name__, VALID_OPTS[key])
)
except TypeError:
errors.append(
err.format(key, val, type(val), VALID_OPTS[key])
err.format(key, val, type(val).__name__, VALID_OPTS[key])
)
# RAET on Windows uses 'win32file.CreateMailslot()' for IPC. Due to this,

View file

@ -2837,6 +2837,9 @@ def copy(src, dst, recurse=False, remove_existing=False):
if not os.path.isabs(src):
raise SaltInvocationError('File path must be absolute.')
if not os.path.exists(src):
raise CommandExecutionError('No such file or directory \'{0}\''.format(src))
if not salt.utils.is_windows():
pre_user = get_user(src)
pre_group = get_group(src)

View file

@ -4,9 +4,10 @@ Execute calls on selinux
.. note::
This module requires the ``semanage`` and ``setsebool`` commands to be
available on the minion. On RHEL-based distros, this means that the
``policycoreutils`` and ``policycoreutils-python`` packages must be
installed. If not on a RHEL-based distribution, consult the selinux
available on the minion. On RHEL-based distributions, ensure that the
``policycoreutils-python`` package is installed. On Fedora 23 and up,
ensure that the ``policycoreutils-python-utils`` package is installed. If
not on a Fedora or RHEL-based distribution, consult the selinux
documentation for your distro to ensure that the proper packages are
installed.
'''

View file

@ -181,7 +181,7 @@ def list_state(subset=None, show_ipv4=False, state=None):
# Always return 'present' for 0MQ for now
# TODO: implement other states spport for 0MQ
ckminions = salt.utils.minions.CkMinions(__opts__)
minions = ckminions.connected_ids(show_ipv4=show_ipv4, subset=subset)
minions = ckminions.connected_ids(show_ipv4=show_ipv4, subset=subset, include_localhost=True)
connected = dict(minions) if show_ipv4 else sorted(minions)

View file

@ -553,7 +553,7 @@ class CkMinions(object):
return list(minions)
def connected_ids(self, subset=None, show_ipv4=False):
def connected_ids(self, subset=None, show_ipv4=False, include_localhost=False):
'''
Return a set of all connected minion ids, optionally within a subset
'''
@ -580,7 +580,9 @@ class CkMinions(object):
except (AttributeError, IOError, OSError):
continue
for ipv4 in grains.get('ipv4', []):
if ipv4 == '127.0.0.1' or ipv4 == '0.0.0.0':
if ipv4 == '127.0.0.1' and not include_localhost:
continue
if ipv4 == '0.0.0.0':
continue
if ipv4 in addrs:
if show_ipv4:

View file

@ -555,6 +555,11 @@ def _interfaces_ifconfig(out):
iface = miface.group(1)
if mmac:
data['hwaddr'] = mmac.group(1)
if salt.utils.is_sunos():
expand_mac = []
for chunk in data['hwaddr'].split(':'):
expand_mac.append('0{0}'.format(chunk) if len(chunk) < 2 else '{0}'.format(chunk))
data['hwaddr'] = ':'.join(expand_mac)
if mip:
if 'inet' not in data:
data['inet'] = list()