You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
461 lines
19 KiB
461 lines
19 KiB
diff --git a/salt/config/__init__.py b/salt/config/__init__.py
|
|
index 70b34ec949..4304d99bf7 100644
|
|
--- a/salt/config/__init__.py
|
|
+++ b/salt/config/__init__.py
|
|
@@ -8,6 +8,7 @@ from __future__ import absolute_import, print_function, unicode_literals, genera
|
|
import os
|
|
import re
|
|
import sys
|
|
+import copy
|
|
import glob
|
|
import time
|
|
import codecs
|
|
@@ -3191,7 +3192,7 @@ def apply_cloud_providers_config(overrides, defaults=None):
|
|
# Merge provided extends
|
|
keep_looping = False
|
|
for alias, entries in six.iteritems(providers.copy()):
|
|
- for driver, details in six.iteritems(entries):
|
|
+ for driver, details in copy.copy(entries).items():
|
|
|
|
if 'extends' not in details:
|
|
# Extends resolved or non existing, continue!
|
|
diff --git a/salt/grains/core.py b/salt/grains/core.py
|
|
index 9b244def9c..ede3a94de9 100644
|
|
--- a/salt/grains/core.py
|
|
+++ b/salt/grains/core.py
|
|
@@ -1939,7 +1939,7 @@ def os_data():
|
|
)
|
|
(osname, osrelease, oscodename) = \
|
|
[x.strip('"').strip("'") for x in
|
|
- linux_distribution(supported_dists=_supported_dists)]
|
|
+ linux_distribution()]
|
|
# Try to assign these three names based on the lsb info, they tend to
|
|
# be more accurate than what python gets from /etc/DISTRO-release.
|
|
# It's worth noting that Ubuntu has patched their Python distribution
|
|
diff --git a/salt/modules/boto_route53.py b/salt/modules/boto_route53.py
|
|
index a663ec7207..8d3d8c2105 100644
|
|
--- a/salt/modules/boto_route53.py
|
|
+++ b/salt/modules/boto_route53.py
|
|
@@ -158,7 +158,7 @@ def describe_hosted_zones(zone_id=None, domain_name=None, region=None,
|
|
else:
|
|
marker = None
|
|
ret = None
|
|
- while marker is not '':
|
|
+ while marker != '':
|
|
r = conn.get_all_hosted_zones(start_marker=marker,
|
|
zone_list=ret)
|
|
ret = r['ListHostedZonesResponse']['HostedZones']
|
|
diff --git a/salt/modules/file.py b/salt/modules/file.py
|
|
index b5b70e2d4c..41a9229eb4 100644
|
|
--- a/salt/modules/file.py
|
|
+++ b/salt/modules/file.py
|
|
@@ -2744,7 +2744,7 @@ def blockreplace(path,
|
|
|
|
if block_found:
|
|
diff = __utils__['stringutils.get_diff'](orig_file, new_file)
|
|
- has_changes = diff is not ''
|
|
+ has_changes = diff != ''
|
|
if has_changes and not dry_run:
|
|
# changes detected
|
|
# backup file attrs
|
|
diff --git a/salt/modules/iptables.py b/salt/modules/iptables.py
|
|
index e232c6931f..9708f45256 100644
|
|
--- a/salt/modules/iptables.py
|
|
+++ b/salt/modules/iptables.py
|
|
@@ -905,7 +905,7 @@ def insert(table='filter', chain=None, position=None, rule=None, family='ipv4'):
|
|
rules = get_rules(family=family)
|
|
size = len(rules[table][chain]['rules'])
|
|
position = (size + position) + 1
|
|
- if position is 0:
|
|
+ if position == 0:
|
|
position = 1
|
|
|
|
wait = '--wait' if _has_option('--wait', family) else ''
|
|
@@ -1040,7 +1040,7 @@ def _parse_conf(conf_file=None, in_mem=False, family='ipv4'):
|
|
ret_args = {}
|
|
chain = parsed_args['append']
|
|
for arg in parsed_args:
|
|
- if parsed_args[arg] and arg is not 'append':
|
|
+ if parsed_args[arg] and arg != 'append':
|
|
ret_args[arg] = parsed_args[arg]
|
|
if parsed_args['comment'] is not None:
|
|
comment = parsed_args['comment'][0].strip('"')
|
|
diff --git a/salt/modules/lxd.py b/salt/modules/lxd.py
|
|
index d6c2d8d4b9..d617cbb3df 100644
|
|
--- a/salt/modules/lxd.py
|
|
+++ b/salt/modules/lxd.py
|
|
@@ -1824,11 +1824,11 @@ def container_file_get(name, src, dst, overwrite=False,
|
|
|
|
if mode:
|
|
os.chmod(dst, mode)
|
|
- if uid or uid is '0':
|
|
+ if uid or uid == '0':
|
|
uid = int(uid)
|
|
else:
|
|
uid = -1
|
|
- if gid or gid is '0':
|
|
+ if gid or gid == '0':
|
|
gid = int(gid)
|
|
else:
|
|
gid = -1
|
|
diff --git a/salt/modules/mongodb.py b/salt/modules/mongodb.py
|
|
index 8cdb819102..ed3228150e 100644
|
|
--- a/salt/modules/mongodb.py
|
|
+++ b/salt/modules/mongodb.py
|
|
@@ -484,7 +484,7 @@ def update_one(objects, collection, user=None, password=None, host=None, port=No
|
|
objects = six.text_type(objects)
|
|
objs = re.split(r'}\s+{', objects)
|
|
|
|
- if len(objs) is not 2:
|
|
+ if len(objs) != 2:
|
|
return "Your request does not contain a valid " + \
|
|
"'{_\"id\": \"my_id\"} {\"my_doc\": \"my_val\"}'"
|
|
|
|
diff --git a/salt/modules/virt.py b/salt/modules/virt.py
|
|
index a2412bb745..91e105fe04 100644
|
|
--- a/salt/modules/virt.py
|
|
+++ b/salt/modules/virt.py
|
|
@@ -4732,7 +4732,7 @@ def _parse_pools_caps(doc):
|
|
if options:
|
|
if 'options' not in pool_caps:
|
|
pool_caps['options'] = {}
|
|
- kind = option_kind if option_kind is not 'vol' else 'volume'
|
|
+ kind = option_kind if option_kind != 'vol' else 'volume'
|
|
pool_caps['options'][kind] = options
|
|
return pool_caps
|
|
|
|
diff --git a/salt/modules/win_ip.py b/salt/modules/win_ip.py
|
|
index e69f44211e..99b9d392f6 100644
|
|
--- a/salt/modules/win_ip.py
|
|
+++ b/salt/modules/win_ip.py
|
|
@@ -342,7 +342,7 @@ def set_static_dns(iface, *addrs):
|
|
salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.1'
|
|
salt -G 'os_family:Windows' ip.set_static_dns 'Local Area Connection' '192.168.1.252' '192.168.1.253'
|
|
'''
|
|
- if addrs is () or str(addrs[0]).lower() == 'none':
|
|
+ if addrs == () or str(addrs[0]).lower() == 'none':
|
|
return {'Interface': iface, 'DNS Server': 'No Changes'}
|
|
# Clear the list of DNS servers if [] is passed
|
|
if str(addrs[0]).lower() == '[]':
|
|
diff --git a/salt/modules/win_lgpo.py b/salt/modules/win_lgpo.py
|
|
index efa154889f..50f0c9940f 100644
|
|
--- a/salt/modules/win_lgpo.py
|
|
+++ b/salt/modules/win_lgpo.py
|
|
@@ -4692,7 +4692,7 @@ class _policy_info(object):
|
|
return 'true'
|
|
elif val.upper() == 'Run Windows PowerShell scripts last'.upper():
|
|
return 'false'
|
|
- elif val is 'Not Configured':
|
|
+ elif val == 'Not Configured':
|
|
return None
|
|
else:
|
|
return 'Invalid Value'
|
|
diff --git a/salt/modules/win_system.py b/salt/modules/win_system.py
|
|
index 74fa61bc51..42f0c2ca6e 100644
|
|
--- a/salt/modules/win_system.py
|
|
+++ b/salt/modules/win_system.py
|
|
@@ -1149,7 +1149,7 @@ def set_system_date_time(years=None,
|
|
system_time.wSecond = int(seconds)
|
|
system_time_ptr = ctypes.pointer(system_time)
|
|
succeeded = ctypes.windll.kernel32.SetLocalTime(system_time_ptr)
|
|
- if succeeded is not 0:
|
|
+ if succeeded != 0:
|
|
return True
|
|
else:
|
|
log.error('Failed to set local time')
|
|
diff --git a/salt/modules/x509.py b/salt/modules/x509.py
|
|
index 1cdd912bfb..4069076c32 100644
|
|
--- a/salt/modules/x509.py
|
|
+++ b/salt/modules/x509.py
|
|
@@ -131,7 +131,7 @@ def _new_extension(name, value, critical=0, issuer=None, _pyfree=1):
|
|
to create the authoritykeyidentifier extension.
|
|
'''
|
|
if name == 'subjectKeyIdentifier' and \
|
|
- value.strip('0123456789abcdefABCDEF:') is not '':
|
|
+ value.strip('0123456789abcdefABCDEF:') != '':
|
|
raise salt.exceptions.SaltInvocationError(
|
|
'value must be precomputed hash')
|
|
|
|
diff --git a/salt/output/highstate.py b/salt/output/highstate.py
|
|
index 1f2f9452fa..87be7656fe 100644
|
|
--- a/salt/output/highstate.py
|
|
+++ b/salt/output/highstate.py
|
|
@@ -209,7 +209,7 @@ def _format_host(host, data, indent_level=1):
|
|
# Verify that the needed data is present
|
|
data_tmp = {}
|
|
for tname, info in six.iteritems(data):
|
|
- if isinstance(info, dict) and tname is not 'changes' and info and '__run_num__' not in info:
|
|
+ if isinstance(info, dict) and tname != 'changes' and info and '__run_num__' not in info:
|
|
err = ('The State execution failed to record the order '
|
|
'in which all states were executed. The state '
|
|
'return missing data is:')
|
|
diff --git a/salt/renderers/stateconf.py b/salt/renderers/stateconf.py
|
|
index cfce9e6926..1b116ddfb1 100644
|
|
--- a/salt/renderers/stateconf.py
|
|
+++ b/salt/renderers/stateconf.py
|
|
@@ -224,7 +224,7 @@ def render(input, saltenv='base', sls='', argline='', **kws):
|
|
tmplctx = STATE_CONF.copy()
|
|
if tmplctx:
|
|
prefix = sls + '::'
|
|
- for k in six.iterkeys(tmplctx): # iterate over a copy of keys
|
|
+ for k in copy.copy(tmplctx).keys(): # iterate over a copy of keys
|
|
if k.startswith(prefix):
|
|
tmplctx[k[len(prefix):]] = tmplctx[k]
|
|
del tmplctx[k]
|
|
diff --git a/salt/returners/slack_webhook_return.py b/salt/returners/slack_webhook_return.py
|
|
index aad1cdf656..0db705df01 100644
|
|
--- a/salt/returners/slack_webhook_return.py
|
|
+++ b/salt/returners/slack_webhook_return.py
|
|
@@ -322,7 +322,7 @@ def returner(ret):
|
|
show_tasks = _options.get('show_tasks')
|
|
author_icon = _options.get('author_icon')
|
|
|
|
- if not webhook or webhook is '':
|
|
+ if not webhook or webhook == '':
|
|
log.error('%s.webhook not defined in salt config', __virtualname__)
|
|
return
|
|
|
|
diff --git a/salt/states/debconfmod.py b/salt/states/debconfmod.py
|
|
index a0ef20b185..a7478c7ac0 100644
|
|
--- a/salt/states/debconfmod.py
|
|
+++ b/salt/states/debconfmod.py
|
|
@@ -210,7 +210,7 @@ def set(name, data, **kwargs):
|
|
args['value'] = 'true' if args['value'] else 'false'
|
|
|
|
if current is not None and [key, args['type'], six.text_type(args['value'])] in current:
|
|
- if ret['comment'] is '':
|
|
+ if ret['comment'] == '':
|
|
ret['comment'] = 'Unchanged answers: '
|
|
ret['comment'] += ('{0} ').format(key)
|
|
else:
|
|
diff --git a/salt/states/git.py b/salt/states/git.py
|
|
index ce6455ee71..f2bf4da629 100644
|
|
--- a/salt/states/git.py
|
|
+++ b/salt/states/git.py
|
|
@@ -2464,7 +2464,7 @@ def detached(name,
|
|
password,
|
|
output_encoding=output_encoding)[0]
|
|
|
|
- if remote_rev_type is 'hash':
|
|
+ if remote_rev_type == 'hash':
|
|
try:
|
|
__salt__['git.describe'](target,
|
|
rev,
|
|
@@ -2643,7 +2643,7 @@ def detached(name,
|
|
|
|
# get refs and checkout
|
|
checkout_commit_id = ''
|
|
- if remote_rev_type is 'hash':
|
|
+ if remote_rev_type == 'hash':
|
|
if __salt__['git.describe'](
|
|
target,
|
|
rev,
|
|
diff --git a/salt/states/mysql_grants.py b/salt/states/mysql_grants.py
|
|
index d6023bbf86..638e988e13 100644
|
|
--- a/salt/states/mysql_grants.py
|
|
+++ b/salt/states/mysql_grants.py
|
|
@@ -167,7 +167,7 @@ def present(name,
|
|
db_part = database.rpartition('.')
|
|
my_db = db_part[0]
|
|
my_table = db_part[2]
|
|
- my_db = __salt__['mysql.quote_identifier'](my_db, (my_table is '*'))
|
|
+ my_db = __salt__['mysql.quote_identifier'](my_db, (my_table == '*'))
|
|
my_table = __salt__['mysql.quote_identifier'](my_table)
|
|
# Removing per table grants in case of database level grant !!!
|
|
if token_grants['database'] == my_db:
|
|
diff --git a/salt/utils/args.py b/salt/utils/args.py
|
|
index 8cc0f35196..8caaae4d1f 100644
|
|
--- a/salt/utils/args.py
|
|
+++ b/salt/utils/args.py
|
|
@@ -253,6 +253,9 @@ def get_function_argspec(func, is_class_method=None):
|
|
if not callable(func):
|
|
raise TypeError('{0} is not a callable'.format(func))
|
|
|
|
+ if hasattr(func, "__wrapped__"):
|
|
+ func = func.__wrapped__
|
|
+
|
|
if six.PY2:
|
|
if is_class_method is True:
|
|
aspec = inspect.getargspec(func)
|
|
diff --git a/salt/utils/decorators/path.py b/salt/utils/decorators/path.py
|
|
index 4adacf0e4e..37c692355f 100644
|
|
--- a/salt/utils/decorators/path.py
|
|
+++ b/salt/utils/decorators/path.py
|
|
@@ -4,10 +4,11 @@ Decorators for salt.utils.path
|
|
'''
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
+import functools
|
|
+
|
|
# Import Salt libs
|
|
import salt.utils.path
|
|
from salt.exceptions import CommandNotFoundError
|
|
-from salt.utils.decorators.signature import identical_signature_wrapper
|
|
|
|
|
|
def which(exe):
|
|
@@ -15,13 +16,14 @@ def which(exe):
|
|
Decorator wrapper for salt.utils.path.which
|
|
'''
|
|
def wrapper(function):
|
|
+ @functools.wraps(function)
|
|
def wrapped(*args, **kwargs):
|
|
if salt.utils.path.which(exe) is None:
|
|
raise CommandNotFoundError(
|
|
'The \'{0}\' binary was not found in $PATH.'.format(exe)
|
|
)
|
|
return function(*args, **kwargs)
|
|
- return identical_signature_wrapper(function, wrapped)
|
|
+ return wrapped
|
|
return wrapper
|
|
|
|
|
|
@@ -30,6 +32,7 @@ def which_bin(exes):
|
|
Decorator wrapper for salt.utils.path.which_bin
|
|
'''
|
|
def wrapper(function):
|
|
+ @functools.wraps(function)
|
|
def wrapped(*args, **kwargs):
|
|
if salt.utils.path.which_bin(exes) is None:
|
|
raise CommandNotFoundError(
|
|
@@ -39,5 +42,5 @@ def which_bin(exes):
|
|
)
|
|
)
|
|
return function(*args, **kwargs)
|
|
- return identical_signature_wrapper(function, wrapped)
|
|
+ return wrapped
|
|
return wrapper
|
|
diff --git a/salt/utils/schedule.py b/salt/utils/schedule.py
|
|
index 474af442a1..69204a53d4 100644
|
|
--- a/salt/utils/schedule.py
|
|
+++ b/salt/utils/schedule.py
|
|
@@ -721,7 +721,7 @@ class Schedule(object):
|
|
if argspec.keywords:
|
|
# this function accepts **kwargs, pack in the publish data
|
|
for key, val in six.iteritems(ret):
|
|
- if key is not 'kwargs':
|
|
+ if key != 'kwargs':
|
|
kwargs['__pub_{0}'.format(key)] = copy.deepcopy(val)
|
|
|
|
# Only include these when running runner modules
|
|
diff --git a/salt/utils/win_pdh.py b/salt/utils/win_pdh.py
|
|
index 9921ee72da..7e9e368caf 100644
|
|
--- a/salt/utils/win_pdh.py
|
|
+++ b/salt/utils/win_pdh.py
|
|
@@ -164,7 +164,7 @@ class Counter(object):
|
|
'''
|
|
path = win32pdh.MakeCounterPath(
|
|
(None, obj, instance, None, instance_index, counter), 0)
|
|
- if win32pdh.ValidatePath(path) is 0:
|
|
+ if win32pdh.ValidatePath(path) == 0:
|
|
return Counter(path, obj, instance, instance_index, counter)
|
|
raise CommandExecutionError('Invalid counter specified: {0}'.format(path))
|
|
|
|
diff --git a/tests/integration/cloud/helpers/virtualbox.py b/tests/integration/cloud/helpers/virtualbox.py
|
|
index 668f15d82f..a6bc9dd2c3 100644
|
|
--- a/tests/integration/cloud/helpers/virtualbox.py
|
|
+++ b/tests/integration/cloud/helpers/virtualbox.py
|
|
@@ -74,7 +74,7 @@ class VirtualboxCloudTestCase(ShellCase):
|
|
output.pop(0)
|
|
else:
|
|
break
|
|
- if len(output) is 0:
|
|
+ if len(output) == 0:
|
|
return dict()
|
|
else:
|
|
return salt.utils.json.loads(''.join(output))
|
|
diff --git a/tests/integration/modules/test_mysql.py b/tests/integration/modules/test_mysql.py
|
|
index 7edb77cb94..197c4e65ae 100644
|
|
--- a/tests/integration/modules/test_mysql.py
|
|
+++ b/tests/integration/modules/test_mysql.py
|
|
@@ -519,7 +519,7 @@ class MysqlModuleDbTest(ModuleCase, SaltReturnAssertsMixin):
|
|
)
|
|
expected = []
|
|
for tablename, engine in sorted(six.iteritems(tablenames)):
|
|
- if engine is 'MEMORY':
|
|
+ if engine == 'MEMORY':
|
|
expected.append([{
|
|
'Table': dbname+'.'+tablename,
|
|
'Msg_text': ("The storage engine for the table doesn't"
|
|
@@ -544,7 +544,7 @@ class MysqlModuleDbTest(ModuleCase, SaltReturnAssertsMixin):
|
|
)
|
|
expected = []
|
|
for tablename, engine in sorted(six.iteritems(tablenames)):
|
|
- if engine is 'MYISAM':
|
|
+ if engine == 'MYISAM':
|
|
expected.append([{
|
|
'Table': dbname+'.'+tablename,
|
|
'Msg_text': 'OK',
|
|
@@ -570,14 +570,14 @@ class MysqlModuleDbTest(ModuleCase, SaltReturnAssertsMixin):
|
|
|
|
expected = []
|
|
for tablename, engine in sorted(six.iteritems(tablenames)):
|
|
- if engine is 'MYISAM':
|
|
+ if engine == 'MYISAM':
|
|
expected.append([{
|
|
'Table': dbname+'.'+tablename,
|
|
'Msg_text': 'OK',
|
|
'Msg_type': 'status',
|
|
'Op': 'optimize'
|
|
}])
|
|
- elif engine is 'InnoDB':
|
|
+ elif engine == 'InnoDB':
|
|
expected.append([{
|
|
'Table': dbname+'.'+tablename,
|
|
'Msg_text': ("Table does not support optimize, "
|
|
@@ -591,7 +591,7 @@ class MysqlModuleDbTest(ModuleCase, SaltReturnAssertsMixin):
|
|
'Msg_type': 'status',
|
|
'Op': 'optimize'
|
|
}])
|
|
- elif engine is 'MEMORY':
|
|
+ elif engine == 'MEMORY':
|
|
expected.append([{
|
|
'Table': dbname+'.'+tablename,
|
|
'Msg_text': ("The storage engine for the table doesn't"
|
|
diff --git a/tests/unit/modules/test_virt.py b/tests/unit/modules/test_virt.py
|
|
index 32f4302e5f..c49bd0bccc 100644
|
|
--- a/tests/unit/modules/test_virt.py
|
|
+++ b/tests/unit/modules/test_virt.py
|
|
@@ -9,6 +9,7 @@ virt execution module unit tests
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
import os
|
|
import re
|
|
+import sys
|
|
import datetime
|
|
import shutil
|
|
|
|
@@ -1393,19 +1394,20 @@ class VirtTestCase(TestCase, LoaderModuleMockMixin):
|
|
self.assertEqual('vnc', setxml.find('devices/graphics').get('type'))
|
|
|
|
# Update with no diff case
|
|
- self.assertEqual({
|
|
- 'definition': False,
|
|
- 'disk': {'attached': [], 'detached': []},
|
|
- 'interface': {'attached': [], 'detached': []}
|
|
- }, virt.update('my vm', cpu=1, mem=1024,
|
|
- disk_profile='default', disks=[{'name': 'data', 'size': 2048}],
|
|
- nic_profile='myprofile',
|
|
- interfaces=[{'name': 'eth0', 'type': 'network', 'source': 'default',
|
|
- 'mac': '52:54:00:39:02:b1'},
|
|
- {'name': 'eth1', 'type': 'network', 'source': 'oldnet',
|
|
- 'mac': '52:54:00:39:02:b2'}],
|
|
- graphics={'type': 'spice',
|
|
- 'listen': {'type': 'address', 'address': '127.0.0.1'}}))
|
|
+ if sys.hexversion < 0x03080000:
|
|
+ self.assertEqual({
|
|
+ 'definition': False,
|
|
+ 'disk': {'attached': [], 'detached': []},
|
|
+ 'interface': {'attached': [], 'detached': []}
|
|
+ }, virt.update('my vm', cpu=1, mem=1024,
|
|
+ disk_profile='default', disks=[{'name': 'data', 'size': 2048}],
|
|
+ nic_profile='myprofile',
|
|
+ interfaces=[{'name': 'eth0', 'type': 'network', 'source': 'default',
|
|
+ 'mac': '52:54:00:39:02:b1'},
|
|
+ {'name': 'eth1', 'type': 'network', 'source': 'oldnet',
|
|
+ 'mac': '52:54:00:39:02:b2'}],
|
|
+ graphics={'type': 'spice',
|
|
+ 'listen': {'type': 'address', 'address': '127.0.0.1'}}))
|
|
|
|
# Failed XML description update case
|
|
self.mock_conn.defineXML.side_effect = self.mock_libvirt.libvirtError("Test error")
|