From 0d4b799969e19227addd56bf5114d3db085ae55e Mon Sep 17 00:00:00 2001 From: twangboy Date: Thu, 8 Nov 2018 11:10:08 -0700 Subject: [PATCH 01/26] Upgrade requests to 2.20.1 --- pkg/osx/req.txt | 2 +- pkg/windows/req.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/osx/req.txt b/pkg/osx/req.txt index 38b2f275a1..ab5549cd4a 100644 --- a/pkg/osx/req.txt +++ b/pkg/osx/req.txt @@ -23,7 +23,7 @@ python-dateutil==2.6.1 python-gnupg==0.4.1 PyYAML==3.12 pyzmq==17.0.0 -requests==2.18.4 +requests==2.20.1 singledispatch==3.4.0.3 six==1.11.0 smmap==0.9.0 diff --git a/pkg/windows/req.txt b/pkg/windows/req.txt index 16b4f447bc..f597c8e978 100644 --- a/pkg/windows/req.txt +++ b/pkg/windows/req.txt @@ -31,7 +31,7 @@ pythonnet==2.3.0 pywin32==223 PyYAML==3.12 pyzmq==16.0.3 -requests==2.18.4 +requests==2.20.1 singledispatch==3.4.0.3 smmap==0.9.0 timelib==0.2.4 From b85c5bf6d99b0ece6e5648231a0fd823f68c9ad0 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Fri, 14 Dec 2018 09:16:09 -0800 Subject: [PATCH 02/26] Adding a test to ensure exception handling is correct. --- tests/unit/modules/test_mysql.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/unit/modules/test_mysql.py b/tests/unit/modules/test_mysql.py index af11d461dd..25d45a0de8 100644 --- a/tests/unit/modules/test_mysql.py +++ b/tests/unit/modules/test_mysql.py @@ -282,6 +282,23 @@ class MySQLTestCase(TestCase, LoaderModuleMockMixin): def test_query(self): self._test_call(mysql.query, 'SELECT * FROM testdb', 'testdb', 'SELECT * FROM testdb') + def test_query_error(self): + def mock_execute(cur, query): + ''' + Mock of info method + ''' + raise MySQLdb.OperationalError(9999, 'Something Went Wrong') + + connect_mock = MagicMock() + with patch.object(mysql, '_connect', connect_mock): + with patch.dict(mysql.__salt__, {'config.option': MagicMock()}): + with patch.object(mysql, '_execute') as execute_mock: + execute_mock.side_effect = mock_execute + mysql.query('testdb', 'SELECT * FROM testdb') + self.assertIn('mysql.error', mysql.__context__) + expected = 'MySQL Error 9999: Something Went Wrong' + self.assertEqual(mysql.__context__['mysql.error'], expected) + def _test_call(self, function, expected_sql, *args, **kwargs): connect_mock = MagicMock() with patch.object(mysql, '_connect', connect_mock): From af3e1459c3472d0394e536723299d97761507b57 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Fri, 14 Dec 2018 09:28:44 -0800 Subject: [PATCH 03/26] Cleanup. --- tests/unit/modules/test_mysql.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/unit/modules/test_mysql.py b/tests/unit/modules/test_mysql.py index 25d45a0de8..43bad1954c 100644 --- a/tests/unit/modules/test_mysql.py +++ b/tests/unit/modules/test_mysql.py @@ -283,17 +283,11 @@ class MySQLTestCase(TestCase, LoaderModuleMockMixin): self._test_call(mysql.query, 'SELECT * FROM testdb', 'testdb', 'SELECT * FROM testdb') def test_query_error(self): - def mock_execute(cur, query): - ''' - Mock of info method - ''' - raise MySQLdb.OperationalError(9999, 'Something Went Wrong') - connect_mock = MagicMock() with patch.object(mysql, '_connect', connect_mock): with patch.dict(mysql.__salt__, {'config.option': MagicMock()}): - with patch.object(mysql, '_execute') as execute_mock: - execute_mock.side_effect = mock_execute + side_effect = MySQLdb.OperationalError(9999, 'Something Went Wrong') + with patch.object(mysql, '_execute', MagicMock(side_effect=side_effect)): mysql.query('testdb', 'SELECT * FROM testdb') self.assertIn('mysql.error', mysql.__context__) expected = 'MySQL Error 9999: Something Went Wrong' From fc9c64b6227bfc6301eb067cfc754d2b5708b68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Jouannet?= Date: Fri, 14 Dec 2018 12:38:14 +0100 Subject: [PATCH 04/26] fix typo in file.managed documentation --- salt/states/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/file.py b/salt/states/file.py index 35b4bcb456..1b94239929 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -1995,7 +1995,7 @@ def managed(name, contents_pillar .. versionadded:: 0.17.0 - .. versionchanged: 2016.11.0 + .. versionchanged:: 2016.11.0 contents_pillar can also be a list, and the pillars will be concatinated together to form one file. From fd73f86c75575ff3af96cb9fe323a087964892d1 Mon Sep 17 00:00:00 2001 From: Massimiliano Torromeo Date: Tue, 4 Dec 2018 16:09:52 +0100 Subject: [PATCH 05/26] Catch UnicodeDecodeErrors in id verification Do not crash if the id cannot be decoded. An invalid id provided by an untrusted client can DOS the master. --- salt/utils/verify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/utils/verify.py b/salt/utils/verify.py index 802b37339c..88d2efe0aa 100644 --- a/salt/utils/verify.py +++ b/salt/utils/verify.py @@ -490,7 +490,7 @@ def valid_id(opts, id_): if any(x in id_ for x in ('/', '\\', '\0')): return False return bool(clean_path(opts['pki_dir'], id_)) - except (AttributeError, KeyError, TypeError): + except (AttributeError, KeyError, TypeError, UnicodeDecodeError): return False From 676a12ac553ce157caecc37dcf2021d8c92e76a1 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Fri, 14 Dec 2018 16:03:59 -0600 Subject: [PATCH 06/26] Fix compound matching in eauth The auth validation functions were using flawed logic to validate the expressions configured for a given eauth plugin. To "expand" the expression, it would use `salt.utils.minions.parse_target()` to analyze the expression. However, this function was intended to be used on individual words in a compound expression, not on a compound expression as a whole. This means that any multi-word compound expression would fail to validate. By assuming that the euth expression is compound and using `check_minions()` to get the list of minions that match the expression, we ensure that it is properly validated. --- salt/utils/minions.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/salt/utils/minions.py b/salt/utils/minions.py index 6c9504ec91..77bbf25288 100644 --- a/salt/utils/minions.py +++ b/salt/utils/minions.py @@ -661,26 +661,6 @@ class CkMinions(object): minions = [] return minions - def _expand_matching(self, auth_entry): - ref = {'G': 'grain', - 'P': 'grain_pcre', - 'I': 'pillar', - 'J': 'pillar_pcre', - 'L': 'list', - 'S': 'ipcidr', - 'E': 'pcre', - 'N': 'node', - None: 'compound'} - - target_info = parse_target(auth_entry) - if not target_info: - log.error('Failed to parse valid target "{0}"'.format(auth_entry)) - - v_matcher = ref.get(target_info['engine']) - v_expr = target_info['pattern'] - - return set(self.check_minions(v_expr, v_matcher)) - def validate_tgt(self, valid, expr, tgt_type, minions=None, expr_form=None): ''' Return a Bool. This function returns if the expression sent in is @@ -697,7 +677,7 @@ class CkMinions(object): ) tgt_type = expr_form - v_minions = self._expand_matching(valid) + v_minions = set(self.check_minions(valid, 'compound')) if minions is None: minions = set(self.check_minions(expr, tgt_type)) else: @@ -824,7 +804,7 @@ class CkMinions(object): continue allowed_minions.update(set(auth_list_entry.keys())) for key in auth_list_entry: - for match in self._expand_matching(key): + for match in set(self.check_minions(key, 'compound')): if match in auth_dictionary: auth_dictionary[match].extend(auth_list_entry[key]) else: @@ -832,7 +812,7 @@ class CkMinions(object): allowed_minions_from_auth_list = set() for next_entry in allowed_minions: - allowed_minions_from_auth_list.update(self._expand_matching(next_entry)) + allowed_minions_from_auth_list.update(set(self.check_minions(next_entry, 'compound'))) # 'minions' here are all the names of minions matched by the target # if we take out all the allowed minions, and there are any left, then # the target includes minions that are not allowed by eauth From ed2bed3e86664628849a4b05fba9fcc76434096d Mon Sep 17 00:00:00 2001 From: angeloudy Date: Wed, 12 Sep 2018 16:14:35 +1000 Subject: [PATCH 07/26] fix command line options --- salt/modules/archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/archive.py b/salt/modules/archive.py index 76cd3eeb97..7f44f506c0 100644 --- a/salt/modules/archive.py +++ b/salt/modules/archive.py @@ -922,7 +922,7 @@ def cmd_unzip(zip_file, if password: cmd.extend(['-P', password]) if options: - cmd.append('{0}'.format(options)) + cmd = cmd + options.split() cmd.extend(['{0}'.format(zip_file), '-d', '{0}'.format(dest)]) if excludes is not None: From 925a9c905cb1913e2c6339c3d700373ea1ada04d Mon Sep 17 00:00:00 2001 From: Tao ZHOU Date: Fri, 19 Oct 2018 16:08:31 +1100 Subject: [PATCH 08/26] Update archive.py --- salt/modules/archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/archive.py b/salt/modules/archive.py index 7f44f506c0..209c04356f 100644 --- a/salt/modules/archive.py +++ b/salt/modules/archive.py @@ -922,7 +922,7 @@ def cmd_unzip(zip_file, if password: cmd.extend(['-P', password]) if options: - cmd = cmd + options.split() + cmd = cmd.extend(shlex.split(options)) cmd.extend(['{0}'.format(zip_file), '-d', '{0}'.format(dest)]) if excludes is not None: From c93dbfaa38d184df7ea8ef9d5a500b69474be700 Mon Sep 17 00:00:00 2001 From: Tao ZHOU Date: Mon, 17 Dec 2018 14:25:59 +1100 Subject: [PATCH 09/26] Update archive.py --- salt/modules/archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/archive.py b/salt/modules/archive.py index 209c04356f..bd414379f4 100644 --- a/salt/modules/archive.py +++ b/salt/modules/archive.py @@ -922,7 +922,7 @@ def cmd_unzip(zip_file, if password: cmd.extend(['-P', password]) if options: - cmd = cmd.extend(shlex.split(options)) + cmd.extend(shlex.split(options)) cmd.extend(['{0}'.format(zip_file), '-d', '{0}'.format(dest)]) if excludes is not None: From da1fc3288fa6656017d73062874c226f92cb9ac2 Mon Sep 17 00:00:00 2001 From: Damon Atkins Date: Wed, 19 Dec 2018 18:31:16 +1100 Subject: [PATCH 10/26] change params.CHANGE_BRANCH to env.CHANGE_BRANCH --- .ci/lint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/lint b/.ci/lint index 2ee375f195..c9f4100a6b 100644 --- a/.ci/lint +++ b/.ci/lint @@ -98,7 +98,7 @@ pipeline { stage('linting all') { // perform a full linit if this is a merge forward and the change only lint passed. when { - expression { return params.CHANGE_BRANCH =~ /(?i)^merge[._-]/ } + expression { return env.CHANGE_BRANCH =~ /(?i)^merge[._-]/ } } parallel { stage('setup full') { From 45f363b152b1f4906d4e1d79f5ffd950c31f1075 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Thu, 20 Dec 2018 16:19:01 -0800 Subject: [PATCH 11/26] Fixing various lint errors. --- salt/daemons/test/__init__.py | 1 + salt/daemons/test/test_minion.py | 1 + salt/daemons/test/test_saltkeep.py | 1 + salt/engines/hipchat.py | 1 + salt/engines/logstash_engine.py | 1 + salt/engines/redis_sentinel.py | 1 + salt/log/setup.py | 1 + salt/modules/capirca_acl.py | 1 + salt/modules/cron.py | 1 + salt/modules/dig.py | 1 + salt/modules/freebsdpkg.py | 2 ++ salt/modules/git.py | 1 + salt/modules/incron.py | 2 ++ salt/modules/ipset.py | 1 + salt/modules/keystone.py | 1 + salt/modules/lxc.py | 3 +++ 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/pillar.py | 1 + salt/modules/pkgng.py | 2 ++ salt/modules/pkgutil.py | 1 + salt/modules/saltutil.py | 1 + salt/modules/solarisips.py | 1 + salt/modules/solarispkg.py | 1 + salt/modules/testinframod.py | 1 + salt/modules/win_file.py | 1 + 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 | 4 ++++ salt/serializers/yaml.py | 1 + salt/serializers/yamlex.py | 1 + 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/schema.py | 1 + salt/utils/yamlloader.py | 1 + tests/committer_parser.py | 1 + tests/integration/cloud/clouds/test_dimensiondata.py | 1 + tests/integration/cloud/clouds/test_ec2.py | 2 -- tests/integration/cloud/test_cloud.py | 1 + tests/integration/modules/test_mac_user.py | 1 + tests/jenkins.py | 1 + tests/kitchen/test_kitchen.py | 1 + tests/minionswarm.py | 1 + tests/salt-tcpdump.py | 1 + tests/support/copyartifacts.py | 1 + tests/support/runtests.py | 1 + tests/unit/modules/test_boto_cloudtrail.py | 1 + tests/unit/modules/test_boto_s3_bucket.py | 1 + tests/unit/modules/test_glusterfs.py | 1 + tests/unit/modules/test_mod_random.py | 1 + tests/unit/modules/test_napalm_yang_mod.py | 1 + tests/unit/modules/test_uptime.py | 1 + tests/unit/states/test_boto_cloudtrail.py | 1 + tests/unit/states/test_boto_iot.py | 1 + tests/unit/states/test_boto_s3_bucket.py | 1 + 71 files changed, 88 insertions(+), 2 deletions(-) diff --git a/salt/daemons/test/__init__.py b/salt/daemons/test/__init__.py index 9abffccfef..f98b8fd42f 100644 --- a/salt/daemons/test/__init__.py +++ b/salt/daemons/test/__init__.py @@ -41,5 +41,6 @@ def run(start=None): suite = loader.discover(start, 'test_*.py', top) unittest.TextTestRunner(verbosity=2).run(suite) + if __name__ == "__main__": run() diff --git a/salt/daemons/test/test_minion.py b/salt/daemons/test/test_minion.py index ac7d5460b8..dbb48282c9 100644 --- a/salt/daemons/test/test_minion.py +++ b/salt/daemons/test/test_minion.py @@ -78,6 +78,7 @@ def test(): minion = salt.daemons.flo.IofloMinion(opts=opts) minion.start(behaviors=['raet.flo.behaving']) + if __name__ == '__main__': console.reinit(verbosity=console.Wordage.concise) test() diff --git a/salt/daemons/test/test_saltkeep.py b/salt/daemons/test/test_saltkeep.py index e548eed93e..9cf2dc0bfc 100644 --- a/salt/daemons/test/test_saltkeep.py +++ b/salt/daemons/test/test_saltkeep.py @@ -2224,6 +2224,7 @@ def runAll(): unittest.TextTestRunner(verbosity=2).run(suite) + if __name__ == '__main__' and __package__ is None: #console.reinit(verbosity=console.Wordage.concise) diff --git a/salt/engines/hipchat.py b/salt/engines/hipchat.py index c96fed6f43..753db04f31 100644 --- a/salt/engines/hipchat.py +++ b/salt/engines/hipchat.py @@ -63,6 +63,7 @@ from salt.ext import six def __virtual__(): return HAS_HYPCHAT + log = logging.getLogger(__name__) _DEFAULT_API_URL = 'https://api.hipchat.com' diff --git a/salt/engines/logstash_engine.py b/salt/engines/logstash_engine.py index 901a71d205..28f537f5e4 100644 --- a/salt/engines/logstash_engine.py +++ b/salt/engines/logstash_engine.py @@ -41,6 +41,7 @@ def __virtual__(): if logstash is not None \ else (False, 'python-logstash not installed') + log = logging.getLogger(__name__) diff --git a/salt/engines/redis_sentinel.py b/salt/engines/redis_sentinel.py index e879ce0906..e197cb707a 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/log/setup.py b/salt/log/setup.py index 2710599d76..6ed30240c7 100644 --- a/salt/log/setup.py +++ b/salt/log/setup.py @@ -164,6 +164,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/capirca_acl.py b/salt/modules/capirca_acl.py index 94889e87ac..bd3e25654b 100644 --- a/salt/modules/capirca_acl.py +++ b/salt/modules/capirca_acl.py @@ -64,6 +64,7 @@ def __virtual__(): else: return (False, 'The capirca module (capirca_acl) cannot be loaded.') + # ------------------------------------------------------------------------------ # module globals # ------------------------------------------------------------------------------ diff --git a/salt/modules/cron.py b/salt/modules/cron.py index d996a74a55..c184bde6de 100644 --- a/salt/modules/cron.py +++ b/salt/modules/cron.py @@ -704,6 +704,7 @@ def rm_job(user, return comdat['stderr'] return ret + rm = salt.utils.functools.alias_function(rm_job, 'rm') diff --git a/salt/modules/dig.py b/salt/modules/dig.py index 7dcae2ddad..31af50ed38 100644 --- a/salt/modules/dig.py +++ b/salt/modules/dig.py @@ -302,6 +302,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/freebsdpkg.py b/salt/modules/freebsdpkg.py index e51a9359ad..43f127ef35 100644 --- a/salt/modules/freebsdpkg.py +++ b/salt/modules/freebsdpkg.py @@ -199,6 +199,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.functools.alias_function(latest_version, 'available_version') @@ -485,6 +486,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.functools.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 63d57f75b9..6bec20f8d5 100644 --- a/salt/modules/git.py +++ b/salt/modules/git.py @@ -1372,6 +1372,7 @@ def config_get_regexp(key, ret.setdefault(param, []).append(value) return ret + config_get_regex = salt.utils.functools.alias_function(config_get_regexp, 'config_get_regex') diff --git a/salt/modules/incron.py b/salt/modules/incron.py index 7950f1db64..b5a2dfeb6d 100644 --- a/salt/modules/incron.py +++ b/salt/modules/incron.py @@ -212,6 +212,7 @@ def list_tab(user): ret['pre'].append(line) return ret + # For consistency's sake ls = salt.utils.functools.alias_function(list_tab, 'ls') @@ -317,4 +318,5 @@ def rm_job(user, return ret + rm = salt.utils.functools.alias_function(rm_job, 'rm') diff --git a/salt/modules/ipset.py b/salt/modules/ipset.py index 1a0fa0044d..8d3a33b6d5 100644 --- a/salt/modules/ipset.py +++ b/salt/modules/ipset.py @@ -26,6 +26,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 0f71233433..2f39da5a63 100644 --- a/salt/modules/keystone.py +++ b/salt/modules/keystone.py @@ -87,6 +87,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 7e6ee984ce..e64811c08e 100644 --- a/salt/modules/lxc.py +++ b/salt/modules/lxc.py @@ -2599,6 +2599,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.functools.alias_function(destroy, 'remove') @@ -2943,6 +2944,7 @@ def set_password(name, users, password, encrypted=True, path=None): ) return True + set_pass = salt.utils.functools.alias_function(set_password, 'set_pass') @@ -4209,6 +4211,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False, path=None): overwrite=overwrite, makedirs=makedirs) + cp = salt.utils.functools.alias_function(copy_to, 'cp') diff --git a/salt/modules/mac_brew.py b/salt/modules/mac_brew.py index 7dcaf9c633..b95b2dab73 100644 --- a/salt/modules/mac_brew.py +++ b/salt/modules/mac_brew.py @@ -189,6 +189,7 @@ def latest_version(*names, **kwargs): else: return versions_dict + # available_version is being deprecated available_version = salt.utils.functools.alias_function(latest_version, 'available_version') diff --git a/salt/modules/mac_ports.py b/salt/modules/mac_ports.py index 9dafc5caa9..78a38d54a9 100644 --- a/salt/modules/mac_ports.py +++ b/salt/modules/mac_ports.py @@ -179,6 +179,7 @@ def latest_version(*names, **kwargs): return ret + # available_version is being deprecated available_version = salt.utils.functools.alias_function(latest_version, 'available_version') diff --git a/salt/modules/memcached.py b/salt/modules/memcached.py index 06cde0da6e..11fea04acc 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.functools.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.functools.alias_function(decrement, 'decr') diff --git a/salt/modules/network.py b/salt/modules/network.py index 360986e0f5..12105e84a2 100644 --- a/salt/modules/network.py +++ b/salt/modules/network.py @@ -1035,6 +1035,7 @@ def hw_addr(iface): ''' return salt.utils.network.hw_addr(iface) + # Alias hwaddr to preserve backward compat hwaddr = salt.utils.functools.alias_function(hw_addr, 'hwaddr') @@ -1213,6 +1214,7 @@ def ip_addrs6(interface=None, include_loopback=False, cidr=None): else: return addrs + ipaddrs6 = salt.utils.functools.alias_function(ip_addrs6, 'ipaddrs6') diff --git a/salt/modules/nspawn.py b/salt/modules/nspawn.py index 51186523fd..7f3d11ab9f 100644 --- a/salt/modules/nspawn.py +++ b/salt/modules/nspawn.py @@ -882,6 +882,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.functools.alias_function(list_running, 'list_') @@ -1313,6 +1314,7 @@ def copy_to(name, source, dest, overwrite=False, makedirs=False): overwrite=overwrite, makedirs=makedirs) + cp = salt.utils.functools.alias_function(copy_to, 'cp') @@ -1478,4 +1480,5 @@ def pull_dkr(url, name, index): ''' return _pull_image('dkr', url, name, index=index) + pull_docker = salt.utils.functools.alias_function(pull_dkr, 'pull_docker') diff --git a/salt/modules/pacman.py b/salt/modules/pacman.py index a38a132f46..e30296e8c8 100644 --- a/salt/modules/pacman.py +++ b/salt/modules/pacman.py @@ -106,6 +106,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.functools.alias_function(latest_version, 'available_version') diff --git a/salt/modules/pillar.py b/salt/modules/pillar.py index c85669d645..c4151b0b60 100644 --- a/salt/modules/pillar.py +++ b/salt/modules/pillar.py @@ -277,6 +277,7 @@ def items(*args, **kwargs): return pillar.compile_pillar() + # Allow pillar.data to also be used to return pillar data data = salt.utils.functools.alias_function(items, 'data') diff --git a/salt/modules/pkgng.py b/salt/modules/pkgng.py index 765401d80d..503c7e39fd 100644 --- a/salt/modules/pkgng.py +++ b/salt/modules/pkgng.py @@ -218,6 +218,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.functools.alias_function(version, 'info') @@ -1080,6 +1081,7 @@ def remove(name=None, return ret + # Support pkg.delete to remove packages, since this is the CLI usage delete = salt.utils.functools.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 aef7d46a67..510feaa146 100644 --- a/salt/modules/pkgutil.py +++ b/salt/modules/pkgutil.py @@ -240,6 +240,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.functools.alias_function(latest_version, 'available_version') diff --git a/salt/modules/saltutil.py b/salt/modules/saltutil.py index 2c152e3ff1..daf2f5142b 100644 --- a/salt/modules/saltutil.py +++ b/salt/modules/saltutil.py @@ -660,6 +660,7 @@ def sync_output(saltenv=None, refresh=True, extmod_whitelist=None, extmod_blackl refresh_modules() return ret + sync_outputters = salt.utils.functools.alias_function(sync_output, 'sync_outputters') diff --git a/salt/modules/solarisips.py b/salt/modules/solarisips.py index e907895905..30016ecf93 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.functools.alias_function(latest_version, 'available_version') diff --git a/salt/modules/solarispkg.py b/salt/modules/solarispkg.py index 6908db4c39..2a828f6e9c 100644 --- a/salt/modules/solarispkg.py +++ b/salt/modules/solarispkg.py @@ -164,6 +164,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.functools.alias_function(latest_version, 'available_version') diff --git a/salt/modules/testinframod.py b/salt/modules/testinframod.py index 9a81a372d0..da91217873 100644 --- a/salt/modules/testinframod.py +++ b/salt/modules/testinframod.py @@ -307,5 +307,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 bf82f47473..6a03ee325a 100644 --- a/salt/modules/win_file.py +++ b/salt/modules/win_file.py @@ -198,6 +198,7 @@ def __virtual__(): return __virtualname__ + __outputter__ = { 'touch': 'txt', 'append': 'txt', diff --git a/salt/modules/win_network.py b/salt/modules/win_network.py index 40e68d22a3..449d4f746c 100644 --- a/salt/modules/win_network.py +++ b/salt/modules/win_network.py @@ -314,6 +314,7 @@ def hw_addr(iface): ''' return salt.utils.network.hw_addr(iface) + # Alias hwaddr to preserve backward compat hwaddr = salt.utils.functools.alias_function(hw_addr, 'hwaddr') @@ -359,6 +360,7 @@ def ip_addrs(interface=None, include_loopback=False): return salt.utils.network.ip_addrs(interface=interface, include_loopback=include_loopback) + ipaddrs = salt.utils.functools.alias_function(ip_addrs, 'ipaddrs') @@ -377,6 +379,7 @@ def ip_addrs6(interface=None, include_loopback=False): return salt.utils.network.ip_addrs6(interface=interface, include_loopback=include_loopback) + ipaddrs6 = salt.utils.functools.alias_function(ip_addrs6, 'ipaddrs6') diff --git a/salt/modules/win_status.py b/salt/modules/win_status.py index 0dc7816846..1df8529018 100644 --- a/salt/modules/win_status.py +++ b/salt/modules/win_status.py @@ -72,6 +72,7 @@ def __virtual__(): return __virtualname__ + __func_alias__ = { 'time_': 'time' } diff --git a/salt/modules/yumpkg.py b/salt/modules/yumpkg.py index 9ee4d80c49..43e2d12b9a 100644 --- a/salt/modules/yumpkg.py +++ b/salt/modules/yumpkg.py @@ -531,6 +531,7 @@ def latest_version(*names, **kwargs): return ret[names[0]] return ret + # available_version is being deprecated available_version = salt.utils.functools.alias_function(latest_version, 'available_version') @@ -962,6 +963,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.functools.alias_function(list_upgrades, 'list_updates') @@ -2240,6 +2242,7 @@ def list_holds(pattern=__HOLD_PATTERN, full=True): ret.append(match) return ret + get_locked_packages = salt.utils.functools.alias_function(list_holds, 'get_locked_packages') @@ -2547,6 +2550,7 @@ def group_install(name, return install(pkgs=pkgs, **kwargs) + groupinstall = salt.utils.functools.alias_function(group_install, 'groupinstall') diff --git a/salt/modules/zenoss.py b/salt/modules/zenoss.py index bca710faea..50711f34cd 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 d901326754..0dd7b9deef 100644 --- a/salt/modules/zypper.py +++ b/salt/modules/zypper.py @@ -469,6 +469,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.functools.alias_function(list_upgrades, 'list_updates') diff --git a/salt/netapi/__init__.py b/salt/netapi/__init__.py index 0c080df72a..ce7003005a 100644 --- a/salt/netapi/__init__.py +++ b/salt/netapi/__init__.py @@ -199,6 +199,7 @@ class NetapiClient(object): 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 fec3609c60..799f1ed0b5 100644 --- a/salt/netapi/rest_cherrypy/wsgi.py +++ b/salt/netapi/rest_cherrypy/wsgi.py @@ -81,4 +81,5 @@ def get_application(*args): return wsgi_app + application = get_application() diff --git a/salt/pillar/mongo.py b/salt/pillar/mongo.py index 577308cbe9..9d07c773c4 100644 --- a/salt/pillar/mongo.py +++ b/salt/pillar/mongo.py @@ -81,6 +81,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 54e501b079..c13f51655c 100644 --- a/salt/returners/highstate_return.py +++ b/salt/returners/highstate_return.py @@ -135,6 +135,7 @@ def _get_options(ret): return _options + # # Most email readers to not support