From 1fbca4521e7a797a3f3e9351e3cd37e1848d82d7 Mon Sep 17 00:00:00 2001 From: Matt Phillips Date: Wed, 3 Oct 2018 15:15:10 -0400 Subject: [PATCH 001/120] localclient: pass input args/kwargs through salt.utils.args.parse_input this functionality brings localclient in line with what happens on the cli, as well as what runnerclient does. this ensures that any foo=bar kwargs passed in as args are handled accordingly. right now localclient relies on SaltCMDOptionParser to do this handling for us, but that leaves a hole when salt-api interactions are brought in. --- salt/client/__init__.py | 21 +++++++++---------- salt/utils/args.py | 5 ++++- tests/unit/test_client.py | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/salt/client/__init__.py b/salt/client/__init__.py index ec0df3a95d04..648934a2e4b3 100644 --- a/salt/client/__init__.py +++ b/salt/client/__init__.py @@ -322,7 +322,7 @@ def run_job( >>> local.run_job('*', 'test.sleep', [300]) {'jid': '20131219215650131543', 'minions': ['jerry']} ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) try: pub_data = self.pub( @@ -378,7 +378,7 @@ def run_job_async( >>> local.run_job_async('*', 'test.sleep', [300]) {'jid': '20131219215650131543', 'minions': ['jerry']} ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) try: pub_data = yield self.pub_async( @@ -426,7 +426,7 @@ def cmd_async( >>> local.cmd_async('*', 'test.sleep', [300]) '20131219215921857715' ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) pub_data = self.run_job(tgt, fun, arg, @@ -532,7 +532,7 @@ def cmd_batch( # Late import - not used anywhere else in this file import salt.cli.batch - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) opts = {'tgt': tgt, 'fun': fun, 'arg': arg, @@ -680,7 +680,7 @@ def cmd(self, minion ID. A compound command will return a sub-dictionary keyed by function name. ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) was_listening = self.event.cpub try: @@ -740,7 +740,7 @@ def cmd_cli( :param verbose: Print extra information about the running command :returns: A generator ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) was_listening = self.event.cpub try: @@ -818,7 +818,7 @@ def cmd_iter( {'dave': {'ret': True}} {'stewart': {'ret': True}} ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) was_listening = self.event.cpub try: @@ -885,7 +885,7 @@ def cmd_iter_no_block( None {'stewart': {'ret': True}} ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) was_listening = self.event.cpub try: @@ -933,7 +933,7 @@ def cmd_full_return( ''' Execute a salt command and return ''' - arg = salt.utils.args.condition_input(arg, kwarg) + arg = salt.utils.args.parse_input(arg, kwargs=kwarg) was_listening = self.event.cpub try: @@ -2001,8 +2001,7 @@ def function(self, fun, *args, **kwargs): func = self.sminion.functions[fun] args, kwargs = salt.minion.load_args_and_kwargs( func, - salt.utils.args.parse_input(args), - kwargs) + salt.utils.args.parse_input(args, kwargs=kwargs),) return func(*args, **kwargs) diff --git a/salt/utils/args.py b/salt/utils/args.py index 75f57f674d3b..05a37611e381 100644 --- a/salt/utils/args.py +++ b/salt/utils/args.py @@ -88,7 +88,7 @@ def condition_input(args, kwargs): return ret -def parse_input(args, condition=True, no_parse=None): +def parse_input(args, kwargs=None, condition=True, no_parse=None): ''' Parse out the args and kwargs from a list of input values. Optionally, return the args and kwargs without passing them to condition_input(). @@ -97,6 +97,8 @@ def parse_input(args, condition=True, no_parse=None): ''' if no_parse is None: no_parse = () + if kwargs is None: + kwargs = {} _args = [] _kwargs = {} for arg in args: @@ -118,6 +120,7 @@ def parse_input(args, condition=True, no_parse=None): _args.append(arg) else: _args.append(arg) + _kwargs.update(kwargs) if condition: return condition_input(_args, _kwargs) return _args, _kwargs diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index 08f27f5bd5bf..90ce968779cd 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -10,6 +10,8 @@ import tests.integration as integration from tests.support.unit import TestCase, skipIf from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON +from tornado.concurrent import Future + # Import Salt libs from salt import client @@ -126,3 +128,45 @@ def test_pub_win32(self): self.assertRaises(SaltInvocationError, self.client.pub, 'non_existent_group', 'test.ping', tgt_type='nodegroup') + + # all of these parse_input test wrapper tests can be replaced by + # parameterize if/when we switch to pytest runner + #@pytest.mark.parametrize('method', [('run_job', 'cmd', ...)]) + def _test_parse_input(self, method, asynchronous=False): + if asynchronous: + target = 'salt.client.LocalClient.pub_async' + pub_ret = Future() + pub_ret.set_result({'jid': '123456789', 'minions': ['m1']}) + else: + target = 'salt.client.LocalClient.pub' + pub_ret = {'jid': '123456789', 'minions': ['m1']} + + with patch(target, return_value=pub_ret) as pub_mock: + with patch('salt.client.LocalClient.get_cli_event_returns', return_value=[{'m1': {'ret': ['test.arg']}}]): + with patch('salt.client.LocalClient.get_iter_returns', return_value=[{'m1': {'ret': True}}]): + ret = getattr(self.client, method)('*', + 'test.arg', + arg=['a', 5, "yaml_arg={qux: Qux}", "another_yaml={bax: 12345}"], + jid='123456789') + + # iterate generator if needed + if asynchronous: + pass + else: + ret = list(ret) + + # main test here is that yaml_arg is getting deserialized properly + parsed_args = ['a', 5, {'yaml_arg': {'qux': 'Qux'}, 'another_yaml': {'bax': 12345}, '__kwarg__': True}] + self.assertTrue(any(parsed_args in call[0] for call in pub_mock.call_args_list)) + + def test_parse_input_is_called(self): + self._test_parse_input('run_job') + self._test_parse_input('cmd') + self._test_parse_input('cmd_subset') + self._test_parse_input('cmd_batch') + self._test_parse_input('cmd_cli') + self._test_parse_input('cmd_full_return') + self._test_parse_input('cmd_iter') + self._test_parse_input('cmd_iter_no_block') + self._test_parse_input('cmd_async') + self._test_parse_input('run_job_async', asynchronous=True) From f46e8bec76730fae5ebe32e55452f134f6eada05 Mon Sep 17 00:00:00 2001 From: Lenard Fudala Date: Tue, 15 Jan 2019 15:35:18 -0600 Subject: [PATCH 002/120] Fix service name in minion plist --- pkg/darwin/com.saltstack.salt.minion.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/darwin/com.saltstack.salt.minion.plist b/pkg/darwin/com.saltstack.salt.minion.plist index 21359eff31ab..64cffaecc0f7 100644 --- a/pkg/darwin/com.saltstack.salt.minion.plist +++ b/pkg/darwin/com.saltstack.salt.minion.plist @@ -3,7 +3,7 @@ Label - salt-minion + com.saltstack.salt.minion RunAtLoad KeepAlive From 010393e1ce011328d478f40485af2357195ed62e Mon Sep 17 00:00:00 2001 From: Christian Biamont Date: Tue, 29 Jan 2019 15:18:14 +0100 Subject: [PATCH 003/120] Make binary data output possible If for example a pillar contains binary data it's possible that it won't be possible to print it when doing e.g pillar.items: File "/usr/lib/python3/dist-packages/salt/output/__init__.py", line 232, in strip_esc_sequence return txt.replace('\033', '?') TypeError: a bytes-like object is required, not 'str' Replace non-printable data during output with a message instead. --- salt/output/nested.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/salt/output/nested.py b/salt/output/nested.py index bb92644202e4..844fec0c457b 100644 --- a/salt/output/nested.py +++ b/salt/output/nested.py @@ -125,9 +125,19 @@ def display(self, ret, indent, prefix, out): elif isinstance(ret, six.string_types): first_line = True for line in ret.splitlines(): + line_prefix = ' ' * len(prefix) if not first_line else prefix + if isinstance(line, bytes): + out.append( + self.ustring( + indent, + self.YELLOW, + 'Not string data', + prefix=line_prefix + ) + ) + break if self.strip_colors: line = salt.output.strip_esc_sequence(line) - line_prefix = ' ' * len(prefix) if not first_line else prefix out.append( self.ustring( indent, From 2dc51714f61904bbfd7f32ffe700e8ec9bb2ffbe Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Wed, 30 Jan 2019 15:06:28 -0700 Subject: [PATCH 004/120] Hanlde multi_master failover when daemonized --- salt/cli/daemons.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/salt/cli/daemons.py b/salt/cli/daemons.py index d427479d8948..9b65ba4c5094 100644 --- a/salt/cli/daemons.py +++ b/salt/cli/daemons.py @@ -340,6 +340,16 @@ def start(self): NOTE: Run any required code before calling `super()`. ''' super(Minion, self).start() + while True: + try: + self._real_start() + except SaltClientError as exc: + # Restart for multi_master failover when daemonized + if self.options.daemon: + continue + break + + def _real_start(self): try: if check_user(self.config['user']): self.action_log_info('Starting up') From ed2b1e138321f308462adb69d387646d5f8fa57d Mon Sep 17 00:00:00 2001 From: Gil Brechbuhler Date: Fri, 8 Feb 2019 16:08:56 +0100 Subject: [PATCH 005/120] Fix RabbitMQ policy definition update check --- salt/states/rabbitmq_policy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/salt/states/rabbitmq_policy.py b/salt/states/rabbitmq_policy.py index 37c4c8ff7784..01844637e329 100644 --- a/salt/states/rabbitmq_policy.py +++ b/salt/states/rabbitmq_policy.py @@ -21,6 +21,7 @@ # Import python libs import logging +import json import salt.utils log = logging.getLogger(__name__) @@ -66,7 +67,10 @@ def present(name, if policy: if policy.get('pattern') != pattern: updates.append('Pattern') - if policy.get('definition') != definition: + current_definition = policy.get('definition') + current_definition = json.loads(current_definition) if current_definition else '' + new_definition = json.loads(definition) if definition else '' + if current_definition != new_definition: updates.append('Definition') if int(policy.get('priority')) != priority: updates.append('Priority') From e5972f5a03aa92c45081cd73ad9667cffcefdd40 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Mon, 11 Feb 2019 14:47:19 -0700 Subject: [PATCH 006/120] Use the code directory instead of cwd for python path --- tests/support/case.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/support/case.py b/tests/support/case.py index 0e2b4684468a..faf9bbad3897 100644 --- a/tests/support/case.py +++ b/tests/support/case.py @@ -252,9 +252,9 @@ def run_script(self, if 'env' not in popen_kwargs: popen_kwargs['env'] = os.environ.copy() if sys.version_info[0] < 3: - popen_kwargs['env'][b'PYTHONPATH'] = os.getcwd().encode() + popen_kwargs['env'][b'PYTHONPATH'] = CODE_DIR.encode() else: - popen_kwargs['env']['PYTHONPATH'] = os.getcwd() + popen_kwargs['env']['PYTHONPATH'] = CODE_DIR else: cmd = 'PYTHONPATH=' python_path = os.environ.get('PYTHONPATH', None) From 8697ce703e308cf1b0cf44493c4951be287b72c0 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Mon, 11 Feb 2019 17:25:22 -0700 Subject: [PATCH 007/120] Disable pylint checks, only for 2017.7 --- tests/support/case.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/support/case.py b/tests/support/case.py index faf9bbad3897..3afb17036ffa 100644 --- a/tests/support/case.py +++ b/tests/support/case.py @@ -141,14 +141,14 @@ def run_ssh(self, arg_str, with_retcode=False, timeout=25, ) return self.run_script('salt-ssh', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr, raw=True) - def run_run(self, arg_str, with_retcode=False, catch_stderr=False, async=False, timeout=60, config_dir=None): + def run_run(self, arg_str, with_retcode=False, catch_stderr=False, async=False, timeout=60, config_dir=None): # pylint: disable=W8606 ''' Execute salt-run ''' arg_str = '-c {0}{async_flag} -t {timeout} {1}'.format(config_dir or self.get_config_dir(), arg_str, timeout=timeout, - async_flag=' --async' if async else '') + async_flag=' --async' if async else '') # pylint: disable=W8606 return self.run_script('salt-run', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) def run_run_plus(self, fun, *arg, **kwargs): @@ -498,14 +498,14 @@ def run_ssh(self, arg_str, with_retcode=False, catch_stderr=False, timeout=timeout, raw=True) - def run_run(self, arg_str, with_retcode=False, catch_stderr=False, async=False, timeout=60, config_dir=None): + def run_run(self, arg_str, with_retcode=False, catch_stderr=False, async=False, timeout=60, config_dir=None): # pylint: disable=W8606 ''' Execute salt-run ''' arg_str = '-c {0}{async_flag} -t {timeout} {1}'.format(config_dir or self.get_config_dir(), arg_str, timeout=timeout, - async_flag=' --async' if async else '') + async_flag=' --async' if async else '') # pylint: disable=W8606 return self.run_script('salt-run', arg_str, with_retcode=with_retcode, From 4702e223454a6fcbaff703e54a792d0c18239815 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 12 Feb 2019 18:01:52 +0000 Subject: [PATCH 008/120] Wait for minions to be pingable before starting tests --- tests/integration/__init__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index b7214aa60b0c..012ba090d634 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -181,7 +181,7 @@ class TestDaemon(object): ''' Set up the master and minion daemons, and run related cases ''' - MINIONS_CONNECT_TIMEOUT = MINIONS_SYNC_TIMEOUT = 120 + MINIONS_CONNECT_TIMEOUT = MINIONS_SYNC_TIMEOUT = 300 def __init__(self, parser): self.parser = parser @@ -217,6 +217,8 @@ def __enter__(self): if getattr(self.parser.options, 'ssh', False): self.prep_ssh() + self.wait_for_minions(time.time(), self.MINIONS_CONNECT_TIMEOUT) + if self.parser.options.sysinfo: try: print_header( @@ -1321,3 +1323,20 @@ def sync_minion_modules(self, targets, timeout=None): def sync_minion_grains(self, targets, timeout=None): salt.utils.appendproctitle('SyncMinionGrains') self.sync_minion_modules_('grains', targets, timeout=timeout) + + def wait_for_minions(self, start, timeout, sleep=5): + ''' + Ensure all minions and masters (including sub-masters) are connected. + ''' + while True: + try: + ret = self.client.run_job('*', 'test.ping') + except salt.exceptions.SaltClientError: + ret = None + if ret and 'minions' not in ret: + continue + if ret and sorted(ret['minions']) == ['minion', 'sub_minion']: + break + if time.time() - start >= timeout: + raise RuntimeError("Ping Minions Failed") + time.sleep(sleep) From c55359fe458226d52b3878301c31cebc011ee76a Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Tue, 12 Feb 2019 11:13:42 -0700 Subject: [PATCH 009/120] fix linter --- tests/integration/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 012ba090d634..e12a82b9bf17 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -1335,7 +1335,7 @@ def wait_for_minions(self, start, timeout, sleep=5): ret = None if ret and 'minions' not in ret: continue - if ret and sorted(ret['minions']) == ['minion', 'sub_minion']: + if ret and sorted(ret['minions']) == ['minion', 'sub_minion']: break if time.time() - start >= timeout: raise RuntimeError("Ping Minions Failed") From 1da9cd9466d0d9a47b325743892ea61492b1316c Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Tue, 12 Feb 2019 18:08:06 -0500 Subject: [PATCH 010/120] Fix pylint on 2017.7 --- salt/_compat.py | 1 + salt/config/__init__.py | 1 + salt/engines/hipchat.py | 1 + salt/engines/logstash.py | 1 + salt/engines/redis_sentinel.py | 1 + salt/engines/slack.py | 1 + salt/log/setup.py | 1 + salt/modules/aptpkg.py | 1 + salt/modules/dig.py | 1 + salt/modules/dockermod.py | 2 ++ salt/modules/freebsdpkg.py | 2 ++ salt/modules/git.py | 1 + salt/modules/heat.py | 4 ++++ salt/modules/incron.py | 2 ++ salt/modules/ipset.py | 1 + salt/modules/keystone.py | 1 + salt/modules/lxc.py | 5 ++++- salt/modules/mac_brew.py | 1 + salt/modules/mac_ports.py | 1 + salt/modules/memcached.py | 2 ++ salt/modules/network.py | 2 ++ salt/modules/nspawn.py | 3 +++ salt/modules/pacman.py | 1 + salt/modules/pkgng.py | 2 ++ salt/modules/pkgutil.py | 1 + salt/modules/saltutil.py | 2 ++ salt/modules/solarisips.py | 1 + salt/modules/solarispkg.py | 1 + salt/modules/testinframod.py | 1 + salt/modules/win_file.py | 1 + salt/modules/win_lgpo.py | 2 +- salt/modules/win_network.py | 3 +++ salt/modules/win_status.py | 1 + salt/modules/yumpkg.py | 4 ++++ salt/modules/zenoss.py | 1 + salt/modules/zypper.py | 1 + salt/netapi/__init__.py | 1 + salt/netapi/rest_cherrypy/wsgi.py | 1 + salt/pillar/mongo.py | 1 + salt/returners/highstate_return.py | 1 + salt/runners/state.py | 1 + salt/serializers/yaml.py | 2 ++ salt/serializers/yamlex.py | 1 + salt/states/heat.py | 4 ++++ salt/states/module.py | 2 ++ salt/states/stateconf.py | 1 + salt/states/virtualenv_mod.py | 1 + salt/states/win_system.py | 1 + salt/tops/mongo.py | 1 + salt/utils/extend.py | 1 + salt/utils/find.py | 1 + salt/utils/master.py | 1 + salt/utils/schema.py | 1 + salt/utils/yamlloader.py | 1 + 54 files changed, 79 insertions(+), 2 deletions(-) diff --git a/salt/_compat.py b/salt/_compat.py index 9b10646ace79..6b7f7e1a1312 100644 --- a/salt/_compat.py +++ b/salt/_compat.py @@ -133,6 +133,7 @@ def string_io(data=None): # cStringIO can't handle unicode except (UnicodeEncodeError, TypeError): return StringIO(data) + if PY3: import ipaddress else: diff --git a/salt/config/__init__.py b/salt/config/__init__.py index a7e58bd5fa81..b272af65f50c 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -95,6 +95,7 @@ def _gather_buffer_space(): # Return the higher number between 5% of the system memory and 10MiB return max([total_mem * 0.05, 10 << 20]) + # For the time being this will be a fixed calculation # TODO: Allow user configuration _DFLT_IPC_WBUFFER = _gather_buffer_space() * .5 diff --git a/salt/engines/hipchat.py b/salt/engines/hipchat.py index 705a5b693e39..1acd518e06b9 100644 --- a/salt/engines/hipchat.py +++ b/salt/engines/hipchat.py @@ -60,6 +60,7 @@ def __virtual__(): return HAS_HYPCHAT + log = logging.getLogger(__name__) _DEFAULT_API_URL = 'https://api.hipchat.com' diff --git a/salt/engines/logstash.py b/salt/engines/logstash.py index d56db4d951d6..b9416592e76c 100644 --- a/salt/engines/logstash.py +++ b/salt/engines/logstash.py @@ -41,6 +41,7 @@ def __virtual__(): else: return True + log = logging.getLogger(__name__) diff --git a/salt/engines/redis_sentinel.py b/salt/engines/redis_sentinel.py index 596f610d38f8..ab729615bdd7 100644 --- a/salt/engines/redis_sentinel.py +++ b/salt/engines/redis_sentinel.py @@ -48,6 +48,7 @@ def __virtual__(): else: return True + log = logging.getLogger(__name__) diff --git a/salt/engines/slack.py b/salt/engines/slack.py index 751b85a2c80c..d805e3bfe25c 100644 --- a/salt/engines/slack.py +++ b/salt/engines/slack.py @@ -84,6 +84,7 @@ def __virtual__(): return HAS_SLACKCLIENT + log = logging.getLogger(__name__) diff --git a/salt/log/setup.py b/salt/log/setup.py index cd85ed599554..65b5099b9ae1 100644 --- a/salt/log/setup.py +++ b/salt/log/setup.py @@ -163,6 +163,7 @@ def is_mp_logging_configured(): def is_extended_logging_configured(): return __EXTERNAL_LOGGERS_CONFIGURED + # Store a reference to the temporary queue logging handler LOGGING_NULL_HANDLER = __NullLoggingHandler(logging.WARNING) diff --git a/salt/modules/aptpkg.py b/salt/modules/aptpkg.py index 7f66dfb2366f..09558ce87483 100644 --- a/salt/modules/aptpkg.py +++ b/salt/modules/aptpkg.py @@ -312,6 +312,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') diff --git a/salt/modules/dig.py b/salt/modules/dig.py index 397bf6538ba4..c4f04727a2c8 100644 --- a/salt/modules/dig.py +++ b/salt/modules/dig.py @@ -301,6 +301,7 @@ def TXT(host, nameserver=None): return [i for i in cmd['stdout'].split('\n')] + # Let lowercase work, since that is the convention for Salt functions a = A aaaa = AAAA diff --git a/salt/modules/dockermod.py b/salt/modules/dockermod.py index 1bac50680bbd..c925c6a67d76 100644 --- a/salt/modules/dockermod.py +++ b/salt/modules/dockermod.py @@ -4379,6 +4379,7 @@ def pause(name): .format(name))} return _change_state(name, 'pause', 'paused') + freeze = salt.utils.alias_function(pause, 'freeze') @@ -4586,6 +4587,7 @@ def unpause(name): .format(name))} return _change_state(name, 'unpause', 'running') + unfreeze = salt.utils.alias_function(unpause, 'unfreeze') diff --git a/salt/modules/freebsdpkg.py b/salt/modules/freebsdpkg.py index 8d9241a77a79..0a4535d13ca0 100644 --- a/salt/modules/freebsdpkg.py +++ b/salt/modules/freebsdpkg.py @@ -198,6 +198,7 @@ def latest_version(*names, **kwargs): ''' return '' if len(names) == 1 else dict((x, '') for x in names) + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') @@ -484,6 +485,7 @@ def remove(name=None, pkgs=None, **kwargs): return ret + # Support pkg.delete to remove packages to more closely match pkg_delete delete = salt.utils.alias_function(remove, 'delete') # No equivalent to purge packages, use remove instead diff --git a/salt/modules/git.py b/salt/modules/git.py index 19a3f0095988..323a02104aba 100644 --- a/salt/modules/git.py +++ b/salt/modules/git.py @@ -1264,6 +1264,7 @@ def config_get_regexp(key, ret.setdefault(param, []).append(value) return ret + config_get_regex = salt.utils.alias_function(config_get_regexp, 'config_get_regex') diff --git a/salt/modules/heat.py b/salt/modules/heat.py index 92f2e6a25152..21683df57257 100644 --- a/salt/modules/heat.py +++ b/salt/modules/heat.py @@ -91,6 +91,8 @@ def _represent_yaml_str(self, node): Represent for yaml ''' return self.represent_scalar(node) + + YamlDumper.add_representer(u'tag:yaml.org,2002:str', _represent_yaml_str) YamlDumper.add_representer(u'tag:yaml.org,2002:timestamp', @@ -102,6 +104,8 @@ def _construct_yaml_str(self, node): Construct for yaml ''' return self.construct_scalar(node) + + YamlLoader.add_constructor(u'tag:yaml.org,2002:timestamp', _construct_yaml_str) diff --git a/salt/modules/incron.py b/salt/modules/incron.py index bec92b79b1b9..1aebd65326a1 100644 --- a/salt/modules/incron.py +++ b/salt/modules/incron.py @@ -210,6 +210,7 @@ def list_tab(user): ret['pre'].append(line) return ret + # For consistency's sake ls = salt.utils.alias_function(list_tab, 'ls') @@ -315,4 +316,5 @@ def rm_job(user, return ret + rm = salt.utils.alias_function(rm_job, 'rm') diff --git a/salt/modules/ipset.py b/salt/modules/ipset.py index 11c45ba845fc..bfcf419bf700 100644 --- a/salt/modules/ipset.py +++ b/salt/modules/ipset.py @@ -29,6 +29,7 @@ def long_range(start, end): yield start start += 1 + _IPSET_FAMILIES = { 'ipv4': 'inet', 'ip4': 'inet', diff --git a/salt/modules/keystone.py b/salt/modules/keystone.py index 02765f0546d9..4692d87eb8a4 100644 --- a/salt/modules/keystone.py +++ b/salt/modules/keystone.py @@ -85,6 +85,7 @@ def __virtual__(): return 'keystone' return (False, 'keystone execution module cannot be loaded: keystoneclient python library not available.') + __opts__ = {} diff --git a/salt/modules/lxc.py b/salt/modules/lxc.py index d11273287aea..fec23fff01b1 100644 --- a/salt/modules/lxc.py +++ b/salt/modules/lxc.py @@ -2601,6 +2601,7 @@ def destroy(name, stop=False, path=None): ) return _change_state('lxc-destroy', name, None, path=path) + # Compatibility between LXC and nspawn remove = salt.utils.alias_function(destroy, 'remove') @@ -2945,6 +2946,7 @@ def _bad_user_input(): ) return True + set_pass = salt.utils.alias_function(set_password, 'set_pass') @@ -4214,6 +4216,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False, path=None): overwrite=overwrite, makedirs=makedirs) + cp = salt.utils.alias_function(copy_to, 'cp') @@ -4694,7 +4697,7 @@ def get_pid(name, path=None): if name not in list_(limit='running', path=path): raise CommandExecutionError('Container {0} is not running, can\'t determine PID'.format(name)) info = __salt__['cmd.run']('lxc-info -n {0}'.format(name)).split("\n") - pid = [line.split(':')[1].strip() for line in info if re.match(r'\s*PID', line) != None][0] + pid = [line.split(':')[1].strip() for line in info if re.match(r'\s*PID', line) is not None][0] return pid diff --git a/salt/modules/mac_brew.py b/salt/modules/mac_brew.py index 541d538b9283..24619d09757d 100644 --- a/salt/modules/mac_brew.py +++ b/salt/modules/mac_brew.py @@ -186,6 +186,7 @@ def get_version(pkg_info): else: return versions_dict + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') diff --git a/salt/modules/mac_ports.py b/salt/modules/mac_ports.py index d3c75769e555..b22c92fccf3e 100644 --- a/salt/modules/mac_ports.py +++ b/salt/modules/mac_ports.py @@ -175,6 +175,7 @@ def latest_version(*names, **kwargs): return ret + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') diff --git a/salt/modules/memcached.py b/salt/modules/memcached.py index 2849ce84d28b..36a85918c8bb 100644 --- a/salt/modules/memcached.py +++ b/salt/modules/memcached.py @@ -238,6 +238,7 @@ def increment(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT): except ValueError: raise SaltInvocationError('Delta value must be an integer') + incr = salt.utils.alias_function(increment, 'incr') @@ -269,4 +270,5 @@ def decrement(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT): except ValueError: raise SaltInvocationError('Delta value must be an integer') + decr = salt.utils.alias_function(decrement, 'decr') diff --git a/salt/modules/network.py b/salt/modules/network.py index 53fd1a36fd19..0ff9e7b513e0 100644 --- a/salt/modules/network.py +++ b/salt/modules/network.py @@ -1033,6 +1033,7 @@ def hw_addr(iface): ''' return salt.utils.network.hw_addr(iface) + # Alias hwaddr to preserve backward compat hwaddr = salt.utils.alias_function(hw_addr, 'hwaddr') @@ -1211,6 +1212,7 @@ def ip_addrs6(interface=None, include_loopback=False, cidr=None): else: return addrs + ipaddrs6 = salt.utils.alias_function(ip_addrs6, 'ipaddrs6') diff --git a/salt/modules/nspawn.py b/salt/modules/nspawn.py index 9fcca78d4202..40f53f941e92 100644 --- a/salt/modules/nspawn.py +++ b/salt/modules/nspawn.py @@ -886,6 +886,7 @@ def list_running(): pass return sorted(ret) + # 'machinectl list' shows only running containers, so allow this to work as an # alias to nspawn.list_running list_ = salt.utils.alias_function(list_running, 'list_') @@ -1317,6 +1318,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False): overwrite=overwrite, makedirs=makedirs) + cp = salt.utils.alias_function(copy_to, 'cp') @@ -1482,4 +1484,5 @@ def pull_dkr(url, name, index): ''' return _pull_image('dkr', url, name, index=index) + pull_docker = salt.utils.alias_function(pull_dkr, 'pull_docker') diff --git a/salt/modules/pacman.py b/salt/modules/pacman.py index 754925f8d60a..d815d37a96ee 100644 --- a/salt/modules/pacman.py +++ b/salt/modules/pacman.py @@ -105,6 +105,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') diff --git a/salt/modules/pkgng.py b/salt/modules/pkgng.py index 59463ead9930..c081e4320edb 100644 --- a/salt/modules/pkgng.py +++ b/salt/modules/pkgng.py @@ -212,6 +212,7 @@ def version(*names, **kwargs): for x, y in six.iteritems(ret) ]) + # Support pkg.info get version info, since this is the CLI usage info = salt.utils.alias_function(version, 'info') @@ -1074,6 +1075,7 @@ def remove(name=None, return ret + # Support pkg.delete to remove packages, since this is the CLI usage delete = salt.utils.alias_function(remove, 'delete') # No equivalent to purge packages, use remove instead diff --git a/salt/modules/pkgutil.py b/salt/modules/pkgutil.py index 9dd294b7e03f..1c419d0952cd 100644 --- a/salt/modules/pkgutil.py +++ b/salt/modules/pkgutil.py @@ -238,6 +238,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') diff --git a/salt/modules/saltutil.py b/salt/modules/saltutil.py index f460749f7df6..793df5ed36e3 100644 --- a/salt/modules/saltutil.py +++ b/salt/modules/saltutil.py @@ -617,6 +617,7 @@ def sync_output(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blackl refresh_modules() return ret + sync_outputters = salt.utils.alias_function(sync_output, 'sync_outputters') @@ -903,6 +904,7 @@ def refresh_pillar(): ret = False # Effectively a no-op, since we can't really return without an event system return ret + pillar_refresh = salt.utils.alias_function(refresh_pillar, 'pillar_refresh') diff --git a/salt/modules/solarisips.py b/salt/modules/solarisips.py index b3f48a61cdad..128655de4149 100644 --- a/salt/modules/solarisips.py +++ b/salt/modules/solarisips.py @@ -332,6 +332,7 @@ def latest_version(name, **kwargs): return ret return '' + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') diff --git a/salt/modules/solarispkg.py b/salt/modules/solarispkg.py index f51667b6eb1b..2763b6cc4ce6 100644 --- a/salt/modules/solarispkg.py +++ b/salt/modules/solarispkg.py @@ -160,6 +160,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') diff --git a/salt/modules/testinframod.py b/salt/modules/testinframod.py index 074237012cc5..3c1055516bdb 100644 --- a/salt/modules/testinframod.py +++ b/salt/modules/testinframod.py @@ -302,5 +302,6 @@ def _register_functions(): __all__.append(mod_name) globals()[mod_name] = mod_func + if TESTINFRA_PRESENT: _register_functions() diff --git a/salt/modules/win_file.py b/salt/modules/win_file.py index 95f69269d345..78ba48d5a17c 100644 --- a/salt/modules/win_file.py +++ b/salt/modules/win_file.py @@ -192,6 +192,7 @@ def __virtual__(): return __virtualname__ + __outputter__ = { 'touch': 'txt', 'append': 'txt', diff --git a/salt/modules/win_lgpo.py b/salt/modules/win_lgpo.py index 8e5ce01aae0d..7779de6046d0 100644 --- a/salt/modules/win_lgpo.py +++ b/salt/modules/win_lgpo.py @@ -4300,7 +4300,7 @@ def _writeAdminTemplateRegPolFile(admtemplate_data, adml_policy_resources=None, display_language='en-US', registry_class='Machine'): - u''' + r''' helper function to prep/write adm template data to the Registry.pol file each file begins with REGFILE_SIGNATURE (u'\u5250\u6765') and diff --git a/salt/modules/win_network.py b/salt/modules/win_network.py index 3ee8fc8c5d33..0013b28c07e7 100644 --- a/salt/modules/win_network.py +++ b/salt/modules/win_network.py @@ -317,6 +317,7 @@ def hw_addr(iface): ''' return salt.utils.network.hw_addr(iface) + # Alias hwaddr to preserve backward compat hwaddr = salt.utils.alias_function(hw_addr, 'hwaddr') @@ -362,6 +363,7 @@ def ip_addrs(interface=None, include_loopback=False): return salt.utils.network.ip_addrs(interface=interface, include_loopback=include_loopback) + ipaddrs = salt.utils.alias_function(ip_addrs, 'ipaddrs') @@ -380,6 +382,7 @@ def ip_addrs6(interface=None, include_loopback=False): return salt.utils.network.ip_addrs6(interface=interface, include_loopback=include_loopback) + ipaddrs6 = salt.utils.alias_function(ip_addrs6, 'ipaddrs6') diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 93ba21ecaec2..719099dd79c7 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -68,6 +68,7 @@ def __virtual__(): return __virtualname__ + __func_alias__ = { 'time_': 'time' } diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 96d512613e85..e2f28bc8836d 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -524,6 +524,7 @@ def _check_cur(pkg): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.alias_function(latest_version, 'available_version') @@ -917,6 +918,7 @@ def list_upgrades(refresh=True, **kwargs): return dict([(x.name, x.version) for x in _yum_pkginfo(out['stdout'])]) + # Preserve expected CLI usage (yum list updates) list_updates = salt.utils.alias_function(list_upgrades, 'list_updates') @@ -2109,6 +2111,7 @@ def list_holds(pattern=__HOLD_PATTERN, full=True): ret.append(match) return ret + get_locked_packages = salt.utils.alias_function(list_holds, 'get_locked_packages') @@ -2416,6 +2419,7 @@ def group_install(name, return install(pkgs=pkgs, **kwargs) + groupinstall = salt.utils.alias_function(group_install, 'groupinstall') diff --git a/salt/modules/zenoss.py b/salt/modules/zenoss.py index deeab114c0f4..e14bc0306c99 100644 --- a/salt/modules/zenoss.py +++ b/salt/modules/zenoss.py @@ -51,6 +51,7 @@ def __virtual__(): return False, 'The \'{0}\' module could not be loaded: ' \ '\'requests\' is not installed.'.format(__virtualname__) + ROUTERS = {'MessagingRouter': 'messaging', 'EventsRouter': 'evconsole', 'ProcessRouter': 'process', diff --git a/salt/modules/zypper.py b/salt/modules/zypper.py index 6a1e1c2e40c8..21c9b56432ca 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -431,6 +431,7 @@ def list_upgrades(refresh=True, **kwargs): return ret + # Provide a list_updates function for those used to using zypper list-updates list_updates = salt.utils.alias_function(list_upgrades, 'list_updates') diff --git a/salt/netapi/__init__.py b/salt/netapi/__init__.py index eabb9981a0df..03fd7dd3d0f2 100644 --- a/salt/netapi/__init__.py +++ b/salt/netapi/__init__.py @@ -199,6 +199,7 @@ def wheel_async(self, fun, **kwargs): wheel = salt.wheel.WheelClient(self.opts) return wheel.cmd_async(kwargs) + CLIENTS = [ name for name, _ in inspect.getmembers(NetapiClient, predicate=inspect.ismethod if six.PY2 else None) diff --git a/salt/netapi/rest_cherrypy/wsgi.py b/salt/netapi/rest_cherrypy/wsgi.py index 3a9bbc5cadc7..f2970905123c 100644 --- a/salt/netapi/rest_cherrypy/wsgi.py +++ b/salt/netapi/rest_cherrypy/wsgi.py @@ -80,4 +80,5 @@ def wsgi_app(environ, start_response): return wsgi_app + application = get_application() diff --git a/salt/pillar/mongo.py b/salt/pillar/mongo.py index 2c8700599d18..be71eec7a2ce 100644 --- a/salt/pillar/mongo.py +++ b/salt/pillar/mongo.py @@ -80,6 +80,7 @@ def __virtual__(): return False return 'mongo' + # Set up logging log = logging.getLogger(__name__) diff --git a/salt/returners/highstate_return.py b/salt/returners/highstate_return.py index c15cb23f7c9e..5e00a69ad0e3 100644 --- a/salt/returners/highstate_return.py +++ b/salt/returners/highstate_return.py @@ -134,6 +134,7 @@ def _get_options(ret): return _options + # # Most email readers to not support