mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge branch '2016.3' into '2016.11'
Conflicts: - salt/modules/win_system.py - tests/unit/modules/win_system_test.py
This commit is contained in:
commit
315b2c8712
9 changed files with 53 additions and 38 deletions
|
@ -59,9 +59,16 @@ pillar data:
|
|||
Prior to version 0.16.2, this function is named ``pillar.data``. This
|
||||
function name is still supported for backwards compatibility.
|
||||
|
||||
By default the contents of the master configuration file are loaded into
|
||||
pillar for all minions. This enables the master configuration file to
|
||||
be used for global configuration of minions.
|
||||
By default, the contents of the master configuration file are not loaded into
|
||||
pillar for all minions. This default is stored in the ``pillar_opts`` setting,
|
||||
which defaults to ``False``.
|
||||
|
||||
The contents of the master configuration file can be made available to minion
|
||||
pillar files. This makes global configuration of services and systems very easy,
|
||||
but note that this may not be desired or appropriate if sensitive data is stored
|
||||
in the master's configuration file. To enable the master configuration file to be
|
||||
available to a minion's pillar files, set ``pillar_opts`` to ``True`` in the
|
||||
minion configuration file.
|
||||
|
||||
Similar to the state tree, the pillar is comprised of sls files and has a top file.
|
||||
The default location for the pillar is in /srv/pillar.
|
||||
|
|
|
@ -241,12 +241,15 @@ class Batch(object):
|
|||
active.remove(minion)
|
||||
if bwait:
|
||||
wait.append(datetime.now() + timedelta(seconds=bwait))
|
||||
# Munge retcode into return data
|
||||
if 'retcode' in data and isinstance(data['ret'], dict) and 'retcode' not in data['ret']:
|
||||
data['ret']['retcode'] = data['retcode']
|
||||
if self.opts.get('raw'):
|
||||
ret[minion] = data
|
||||
yield data
|
||||
else:
|
||||
ret[minion] = data
|
||||
yield {minion: data}
|
||||
ret[minion] = data['ret']
|
||||
yield {minion: data['ret']}
|
||||
if not self.quiet:
|
||||
ret[minion] = data['ret']
|
||||
data[minion] = data.pop('ret')
|
||||
|
|
|
@ -518,8 +518,8 @@ def apply_(mods=None,
|
|||
Argument name changed from ``env`` to ``saltenv``
|
||||
|
||||
.. versionchanged:: 2014.7.0
|
||||
If no saltenv is specified, the minion config will be checked for a
|
||||
``saltenv`` parameter and if found, it will be used. If none is
|
||||
If no saltenv is specified, the minion config will be checked for an
|
||||
``environment`` parameter and if found, it will be used. If none is
|
||||
found, ``base`` will be used. In prior releases, the minion config
|
||||
was not checked and ``base`` would always be assumed when the
|
||||
saltenv was not explicitly set.
|
||||
|
@ -888,8 +888,8 @@ def sls(mods,
|
|||
Argument name changed from ``env`` to ``saltenv``.
|
||||
|
||||
.. versionchanged:: 2014.7.0
|
||||
If no saltenv is specified, the minion config will be checked for a
|
||||
``saltenv`` parameter and if found, it will be used. If none is
|
||||
If no saltenv is specified, the minion config will be checked for an
|
||||
``environment`` parameter and if found, it will be used. If none is
|
||||
found, ``base`` will be used. In prior releases, the minion config
|
||||
was not checked and ``base`` would always be assumed when the
|
||||
saltenv was not explicitly set.
|
||||
|
|
|
@ -545,10 +545,9 @@ def get_hostname():
|
|||
|
||||
salt 'minion-id' system.get_hostname
|
||||
'''
|
||||
cmd = 'wmic nicconfig get dnshostname'
|
||||
cmd = 'hostname'
|
||||
ret = __salt__['cmd.run'](cmd=cmd)
|
||||
_, _, hostname = ret.split("\n")
|
||||
return hostname
|
||||
return ret
|
||||
|
||||
|
||||
def set_hostname(hostname):
|
||||
|
|
|
@ -584,6 +584,7 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
|
||||
def process_log_level(self):
|
||||
if not getattr(self.options, self._loglevel_config_setting_name_, None):
|
||||
# Log level is not set via CLI, checking loaded configuration
|
||||
if self.config.get(self._loglevel_config_setting_name_, None):
|
||||
# Is the regular log level setting set?
|
||||
setattr(self.options,
|
||||
|
@ -591,7 +592,7 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
self.config.get(self._loglevel_config_setting_name_)
|
||||
)
|
||||
else:
|
||||
# Nothing is set on the configuration? Let's use the cli tool
|
||||
# Nothing is set on the configuration? Let's use the CLI tool
|
||||
# defined default
|
||||
setattr(self.options,
|
||||
self._loglevel_config_setting_name_,
|
||||
|
@ -611,6 +612,7 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
|
||||
def process_log_file(self):
|
||||
if not getattr(self.options, self._logfile_config_setting_name_, None):
|
||||
# Log file is not set via CLI, checking loaded configuration
|
||||
if self.config.get(self._logfile_config_setting_name_, None):
|
||||
# Is the regular log file setting set?
|
||||
setattr(self.options,
|
||||
|
@ -618,7 +620,7 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
self.config.get(self._logfile_config_setting_name_)
|
||||
)
|
||||
else:
|
||||
# Nothing is set on the configuration? Let's use the cli tool
|
||||
# Nothing is set on the configuration? Let's use the CLI tool
|
||||
# defined default
|
||||
setattr(self.options,
|
||||
self._logfile_config_setting_name_,
|
||||
|
@ -630,6 +632,7 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
|
||||
def process_log_level_logfile(self):
|
||||
if not getattr(self.options, self._logfile_loglevel_config_setting_name_, None):
|
||||
# Log file level is not set via CLI, checking loaded configuration
|
||||
if self.config.get(self._logfile_loglevel_config_setting_name_, None):
|
||||
# Is the regular log file level setting set?
|
||||
setattr(self.options,
|
||||
|
@ -637,14 +640,18 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
self.config.get(self._logfile_loglevel_config_setting_name_)
|
||||
)
|
||||
else:
|
||||
# Nothing is set on the configuration? Let's use the cli tool
|
||||
# Nothing is set on the configuration? Let's use the CLI tool
|
||||
# defined default
|
||||
setattr(self.options,
|
||||
self._logfile_loglevel_config_setting_name_,
|
||||
self._default_logging_level_
|
||||
# From the console log level config setting
|
||||
self.config.get(
|
||||
self._loglevel_config_setting_name_,
|
||||
self._default_logging_level_
|
||||
)
|
||||
)
|
||||
if self._logfile_loglevel_config_setting_name_ in self.config:
|
||||
# Remove it from config so it inherits from log_level
|
||||
# Remove it from config so it inherits from log_level_logfile
|
||||
self.config.pop(self._logfile_loglevel_config_setting_name_)
|
||||
|
||||
def __setup_logfile_logger_config(self, *args): # pylint: disable=unused-argument
|
||||
|
@ -654,7 +661,9 @@ class LogLevelMixIn(six.with_metaclass(MixInMeta, object)):
|
|||
self.config.pop(self._logfile_loglevel_config_setting_name_)
|
||||
|
||||
loglevel = getattr(self.options,
|
||||
# From the options setting
|
||||
self._logfile_loglevel_config_setting_name_,
|
||||
# From the default setting
|
||||
self._default_logging_level_
|
||||
)
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ You should see output related to the ESXi host's syslog configuration.
|
|||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
import atexit
|
||||
import errno
|
||||
import logging
|
||||
import time
|
||||
from salt.ext.six.moves.http_client import BadStatusLine # pylint: disable=E0611
|
||||
|
@ -706,6 +707,10 @@ def get_mors_with_properties(service_instance, object_type, property_list=None,
|
|||
content = get_content(*content_args, **content_kwargs)
|
||||
except BadStatusLine:
|
||||
content = get_content(*content_args, **content_kwargs)
|
||||
except IOError as e:
|
||||
if e.errno != errno.EPIPE:
|
||||
raise e
|
||||
content = get_content(*content_args, **content_kwargs)
|
||||
|
||||
object_list = []
|
||||
for obj in content:
|
||||
|
|
|
@ -291,11 +291,11 @@ class WinSystemTestCase(TestCase):
|
|||
'''
|
||||
Test setting a new hostname
|
||||
'''
|
||||
cmd_run_mock = MagicMock(return_value="DNSHostName\n\nMINION")
|
||||
cmd_run_mock = MagicMock(return_value="MINION")
|
||||
with patch.dict(win_system.__salt__, {'cmd.run': cmd_run_mock}):
|
||||
ret = win_system.get_hostname()
|
||||
self.assertEqual(ret, "MINION")
|
||||
cmd_run_mock.assert_called_once_with(cmd="wmic nicconfig get dnshostname")
|
||||
cmd_run_mock.assert_called_once_with(cmd="hostname")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -126,11 +126,11 @@ Pkg.removed("samba-imported", names=[Other.server, Other.client])
|
|||
|
||||
random_password_template = '''#!pyobjects
|
||||
import random, string
|
||||
password = ''.join(random.SystemRandom().choice(
|
||||
string.ascii_letters + string.digits) for _ in range(20))
|
||||
password = ''.join([random.SystemRandom().choice(
|
||||
string.ascii_letters + string.digits) for _ in range(20)])
|
||||
'''
|
||||
|
||||
random_password_import_template = '''#!pyobjecs
|
||||
random_password_import_template = '''#!pyobjects
|
||||
from salt://password.sls import password
|
||||
'''
|
||||
|
||||
|
|
|
@ -167,9 +167,6 @@ class LogSettingsParserTests(TestCase):
|
|||
'''
|
||||
Tests that log level match the configured value
|
||||
'''
|
||||
# Set defaults
|
||||
default_log_level = self.default_config[self.loglevel_config_setting_name]
|
||||
|
||||
args = self.args
|
||||
|
||||
# Set log level in config
|
||||
|
@ -193,7 +190,7 @@ class LogSettingsParserTests(TestCase):
|
|||
log_level)
|
||||
self.assertEqual(self.log_setup.temp_log_level, 'error')
|
||||
# Check log file logger log level
|
||||
self.assertEqual(self.log_setup.log_level_logfile, default_log_level)
|
||||
self.assertEqual(self.log_setup.log_level_logfile, log_level)
|
||||
|
||||
def test_get_log_level_default(self):
|
||||
'''
|
||||
|
@ -342,7 +339,7 @@ class LogSettingsParserTests(TestCase):
|
|||
Tests that file log level match command-line specified value
|
||||
'''
|
||||
# Set defaults
|
||||
log_level = self.default_config[self.loglevel_config_setting_name]
|
||||
default_log_level = self.default_config[self.loglevel_config_setting_name]
|
||||
|
||||
# Set log file level in CLI
|
||||
log_level_logfile = 'error'
|
||||
|
@ -359,10 +356,10 @@ class LogSettingsParserTests(TestCase):
|
|||
|
||||
if not self.skip_console_logging_config:
|
||||
# Check console loggger
|
||||
self.assertEqual(self.log_setup.log_level, log_level)
|
||||
self.assertEqual(self.log_setup.log_level, default_log_level)
|
||||
# Check extended logger
|
||||
self.assertEqual(self.log_setup.config[self.loglevel_config_setting_name],
|
||||
log_level)
|
||||
default_log_level)
|
||||
self.assertEqual(self.log_setup.config[self.logfile_loglevel_config_setting_name],
|
||||
log_level_logfile)
|
||||
# Check temp logger
|
||||
|
@ -464,7 +461,6 @@ class LogSettingsParserTests(TestCase):
|
|||
parser = self.parser()
|
||||
with patch(self.config_func, MagicMock(return_value=opts)):
|
||||
parser.parse_args(args)
|
||||
|
||||
with patch('salt.utils.parsers.is_writeable', MagicMock(return_value=True)):
|
||||
parser.setup_logfile_logger()
|
||||
|
||||
|
@ -701,19 +697,15 @@ class SaltKeyOptionParserTestCase(LogSettingsParserTests):
|
|||
'''
|
||||
Tests that log level set in config is ignored
|
||||
'''
|
||||
# Set defaults
|
||||
default_log_level = self.default_config[self.loglevel_config_setting_name]
|
||||
|
||||
log_level = None
|
||||
log_level = 'info'
|
||||
args = self.args
|
||||
|
||||
# Set log level in config
|
||||
opts = {self.loglevel_config_setting_name: 'info'}
|
||||
opts = {self.loglevel_config_setting_name: log_level}
|
||||
|
||||
parser = self.parser()
|
||||
with patch(self.config_func, MagicMock(return_value=opts)):
|
||||
parser.parse_args(args)
|
||||
|
||||
with patch('salt.utils.parsers.is_writeable', MagicMock(return_value=True)):
|
||||
parser.parse_args(args)
|
||||
parser.setup_logfile_logger()
|
||||
|
@ -721,12 +713,12 @@ class SaltKeyOptionParserTestCase(LogSettingsParserTests):
|
|||
# Check config name absence in options
|
||||
self.assertNotIn(self.loglevel_config_setting_name, parser.options.__dict__)
|
||||
# Check console loggger has not been set
|
||||
self.assertEqual(self.log_setup.log_level, log_level)
|
||||
self.assertEqual(self.log_setup.log_level, None)
|
||||
self.assertNotIn(self.loglevel_config_setting_name, self.log_setup.config)
|
||||
# Check temp logger
|
||||
self.assertEqual(self.log_setup.temp_log_level, 'error')
|
||||
# Check log file logger log level
|
||||
self.assertEqual(self.log_setup.log_level_logfile, default_log_level)
|
||||
self.assertEqual(self.log_setup.log_level_logfile, log_level)
|
||||
|
||||
def test_get_log_level_default(self):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue