Merge branch '2018.3' into add_whitelist

This commit is contained in:
Daniel Wozniak 2018-09-12 10:04:00 -06:00 committed by GitHub
commit f908cde7f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 199 additions and 108 deletions

View file

@ -223,8 +223,8 @@ $MAKE install
############################################################################
echo -n -e "\033]0;Build_Env: OpenSSL: download\007"
PKGURL="http://openssl.org/source/openssl-1.0.2n.tar.gz"
PKGDIR="openssl-1.0.2n"
PKGURL="http://openssl.org/source/openssl-1.0.2p.tar.gz"
PKGDIR="openssl-1.0.2p"
download $PKGURL

View file

@ -0,0 +1 @@
958c5a7c3324bbdc8f07dfb13e11329d9a1b4452c07cf41fbd2d42b5fe29c95679332a3476d24c2dc2b88be16e4a24744aba675a05a388c0905756c77a8a2f16 ./openssl-1.0.2p.tar.gz

View file

@ -113,8 +113,14 @@ if not %errorLevel%==0 (
:: Remove build and dist directories
@echo %0 :: Remove build and dist directories...
@echo ---------------------------------------------------------------------
rd /s /q "%SrcDir%\build"
rd /s /q "%SrcDir%\dist"
"%PyDir%\python.exe" "%SrcDir%\setup.py" clean --all
if not %errorLevel%==0 (
goto eof
)
If Exist "%SrcDir%\dist" (
@echo removing %SrcDir%\dist
rd /S /Q "%SrcDir%\dist"
)
@echo.
:: Install Current Version of salt

View file

@ -658,8 +658,6 @@ def _get_properties(path="", method="GET", forced_params=None):
props = sub['info'][method]['parameters']['properties'].keys()
except KeyError as exc:
log.error('method not found: "%s"', exc)
except:
raise
for prop in props:
numerical = re.match(r'(\w+)\[n\]', prop)
# generate (arbitrarily) 10 properties for duplicatable properties identified by:

View file

@ -201,7 +201,7 @@ def v4_int_to_packed(address):
"""
try:
return _int_to_bytes(address, 4, 'big')
except:
except Exception:
raise ValueError("Address negative or too large for IPv4")
@ -217,7 +217,7 @@ def v6_int_to_packed(address):
"""
try:
return _int_to_bytes(address, 16, 'big')
except:
except Exception:
raise ValueError("Address negative or too large for IPv6")

View file

@ -3332,11 +3332,11 @@ class Matcher(object):
try:
# Target is an address?
tgt = ipaddress.ip_address(tgt)
except: # pylint: disable=bare-except
except Exception:
try:
# Target is a network?
tgt = ipaddress.ip_network(tgt)
except: # pylint: disable=bare-except
except Exception:
log.error('Invalid IP/CIDR target: %s', tgt)
return []
proto = 'ipv{0}'.format(tgt.version)

View file

@ -75,7 +75,7 @@ def uuid(dev=None):
else:
# basename of the /sys/block/{dev}/bcache/cache symlink target
return os.path.basename(_bcsys(dev, 'cache'))
except: # pylint: disable=bare-except
except Exception:
return False
@ -492,7 +492,7 @@ def device(dev, stats=False, config=False, internals=False, superblock=False):
try:
result['dev'] = os.path.basename(_bcsys(dev, 'dev'))
except: # pylint: disable=bare-except
except Exception:
pass
result['bdev'] = _bdev(dev)
@ -604,10 +604,10 @@ def super_(dev):
try:
rval = int(rval)
except: # pylint: disable=bare-except
except Exception:
try:
rval = float(rval)
except: # pylint: disable=bare-except
except Exception:
if rval == 'yes':
rval = True
elif rval == 'no':
@ -800,10 +800,10 @@ def _sysfs_parse(path, base_attr=None, stats=False, config=False, internals=Fals
val = val.strip()
try:
val = int(val)
except: # pylint: disable=bare-except
except Exception:
try:
val = float(val)
except: # pylint: disable=bare-except
except Exception:
pass
listres[key.strip()] = val
result[strlist] = listres
@ -846,7 +846,7 @@ def _size_map(size):
size = 1024**2 * float(re.sub(r'[Mm]', '', size))
size = int(size)
return size
except: # pylint: disable=bare-except
except Exception:
return None

View file

@ -126,7 +126,7 @@ def _delete_resource(name, name_param, desc, res_type, wait=0, status_param=None
'''
try:
wait = int(wait)
except:
except Exception:
raise SaltInvocationError("Bad value ('{0}') passed for 'wait' param - must be an "
"int or boolean.".format(wait))
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -178,7 +178,7 @@ def _create_resource(name, name_param=None, desc=None, res_type=None, wait=0, st
**args):
try:
wait = int(wait)
except:
except Exception:
raise SaltInvocationError("Bad value ('{0}') passed for 'wait' param - must be an "
"int or boolean.".format(wait))
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -231,7 +231,7 @@ def _modify_resource(name, name_param=None, desc=None, res_type=None, wait=0, st
**args):
try:
wait = int(wait)
except:
except Exception:
raise SaltInvocationError("Bad value ('{0}') passed for 'wait' param - must be an "
"int or boolean.".format(wait))
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

View file

@ -594,7 +594,7 @@ def hdparms(disks, args=None):
try:
val = int(val)
rvals.append(val)
except: # pylint: disable=bare-except
except Exception:
if '=' in val:
deep_key, val = val.split('=', 1)
deep_key = deep_key.strip()
@ -661,7 +661,7 @@ def hpa(disks, size=None):
for disk, data in hpa_data.items():
try:
size = data['total'] - int(size)
except: # pylint: disable=bare-except
except Exception:
if '%' in size:
size = int(size.strip('%'))
size = (100 - size) * data['total']
@ -726,17 +726,17 @@ def smart_attributes(dev, attributes=None, values=None):
data = dict(zip(fields, line[1:]))
try:
del data['_']
except: # pylint: disable=bare-except
except Exception:
pass
for field in data:
val = data[field]
try:
val = int(val)
except: # pylint: disable=bare-except
except Exception:
try:
val = [int(value) for value in val.split(' ')]
except: # pylint: disable=bare-except
except Exception:
pass
data[field] = val

View file

@ -2404,7 +2404,7 @@ def replace(path,
except OSError:
os.remove(symlink_backup)
os.symlink(target_backup, symlink_backup)
except:
except Exception:
raise CommandExecutionError(
"Unable create backup symlink '{0}'. "
"Target was '{1}'. "
@ -6286,7 +6286,7 @@ def open_files(by_pid=False):
#try:
# fd_.append(os.path.realpath('{0}/task/{1}exe'.format(ppath, tid)))
#except:
#except Exception:
# pass
for fpath in os.listdir('{0}/fd'.format(ppath)):

View file

@ -271,8 +271,7 @@ def _dmi_cast(key, val, clean=True):
else:
try:
val = int(val)
# pylint: disable=bare-except
except:
except Exception:
pass
return val

View file

@ -70,7 +70,7 @@ def write(key, value):
salt.utils.stringutils.to_str('{0}\n'.format(value))
)
return True
except: # pylint: disable=bare-except
except Exception:
return False
@ -129,13 +129,13 @@ def read(key, root=''):
return False
try:
val = int(val)
except: # pylint: disable=bare-except
except Exception:
try:
val = float(val)
except: # pylint: disable=bare-except
except Exception:
pass
return val
except: # pylint: disable=bare-except
except Exception:
return False

View file

@ -31,7 +31,7 @@ from datetime import datetime
try:
from shlex import quote as _cmd_quote # pylint: disable=E0611
except: # pylint: disable=W0702
except Exception:
from pipes import quote as _cmd_quote
# Import Salt libs

View file

@ -123,7 +123,7 @@ def start():
backlog=mod_opts.get('backlog', 128),
)
http_server.start(mod_opts['num_processes'])
except:
except Exception:
log.error('Rest_tornado unable to bind to port %s', mod_opts['port'], exc_info=True)
raise SystemExit(1)

View file

@ -185,9 +185,8 @@ a return like::
.. |406| replace:: requested Content-Type not available
.. |500| replace:: internal server error
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import time
import fnmatch
import logging
@ -616,7 +615,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
'''
def get(self):
'''
All logins are done over post, this is a parked enpoint
All logins are done over post, this is a parked endpoint
.. http:get:: /login
@ -629,7 +628,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
curl -i localhost:8000/login
.. code-block:: http
.. code-block:: text
GET /login HTTP/1.1
Host: localhost:8000
@ -637,7 +636,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 401 Unauthorized
Content-Type: application/json
@ -656,7 +655,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
# TODO: make asynchronous? Underlying library isn't... and we ARE making disk calls :(
def post(self):
'''
:ref:`Authenticate <rest_tornado-auth>` against Salt's eauth system
:ref:`Authenticate <rest_tornado-auth>` against Salt's eauth system
.. http:post:: /login
@ -684,7 +683,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
-d password='saltpass' \\
-d eauth='pam'
.. code-block:: http
.. code-block:: text
POST / HTTP/1.1
Host: localhost:8000
@ -696,7 +695,7 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Type: application/json
@ -777,7 +776,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
'''
def get(self):
'''
An enpoint to determine salt-api capabilities
An endpoint to determine salt-api capabilities
.. http:get:: /
@ -793,7 +792,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
curl -i localhost:8000
.. code-block:: http
.. code-block:: text
GET / HTTP/1.1
Host: localhost:8000
@ -801,7 +800,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Type: application/json
@ -845,7 +844,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
-d fun='test.ping' \\
-d arg
.. code-block:: http
.. code-block:: text
POST / HTTP/1.1
Host: localhost:8000
@ -857,11 +856,12 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
fun=test.ping&arg&client=local&tgt=*
**Example response:**
Responses are an in-order list of the lowstate's return data. In the
event of an exception running a command the return will be a string
instead of a mapping.
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Length: 200
@ -876,10 +876,11 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
ms-4: true
.. admonition:: multiple commands
Note that if multiple :term:`lowstate` structures are sent, the Salt
API will execute them in serial, and will not stop execution upon failure
of a previous job. If you need to have commands executed in order and
stop on failure please use compount-command-execution.
stop on failure please use compound-command-execution.
'''
# if you aren't authenticated, redirect to login
@ -977,7 +978,8 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
is_finished)
def more_todo():
'''Check if there are any more minions we are waiting on returns from
'''
Check if there are any more minions we are waiting on returns from
'''
return any(x is False for x in six.itervalues(minions))
@ -1144,7 +1146,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
curl -i localhost:8000/minions/ms-3
.. code-block:: http
.. code-block:: text
GET /minions/ms-3 HTTP/1.1
Host: localhost:8000
@ -1152,7 +1154,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Length: 129005
@ -1205,7 +1207,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
-d tgt='*' \\
-d fun='status.diskusage'
.. code-block:: http
.. code-block:: text
POST /minions HTTP/1.1
Host: localhost:8000
@ -1217,7 +1219,7 @@ class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 202 Accepted
Content-Length: 86
@ -1272,7 +1274,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
curl -i localhost:8000/jobs
.. code-block:: http
.. code-block:: text
GET /jobs HTTP/1.1
Host: localhost:8000
@ -1280,7 +1282,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Length: 165
@ -1301,7 +1303,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
curl -i localhost:8000/jobs/20121130104633606931
.. code-block:: http
.. code-block:: text
GET /jobs/20121130104633606931 HTTP/1.1
Host: localhost:8000
@ -1309,7 +1311,7 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Length: 73
@ -1390,7 +1392,7 @@ class RunSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
-d password='saltdev' \\
-d eauth='pam'
.. code-block:: http
.. code-block:: text
POST /run HTTP/1.1
Host: localhost:8000
@ -1402,7 +1404,7 @@ class RunSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Length: 73
@ -1449,14 +1451,14 @@ class EventsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
curl -NsS localhost:8000/events
.. code-block:: http
.. code-block:: text
GET /events HTTP/1.1
Host: localhost:8000
**Example response:**
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Connection: keep-alive
@ -1604,7 +1606,7 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
curl -sS localhost:8000/hook -d foo='Foo!' -d bar='Bar!'
.. code-block:: http
.. code-block:: text
POST /hook HTTP/1.1
Host: localhost:8000
@ -1615,7 +1617,7 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
**Example response**:
.. code-block:: http
.. code-block:: text
HTTP/1.1 200 OK
Content-Length: 14
@ -1628,7 +1630,9 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
``http://localhost:8000/hook/mycompany/build/success`` which contains
the result of a build and the SHA of the version that was built as
JSON. That would then produce the following event in Salt that could be
used to kick off a deployment via Salt's Reactor::
used to kick off a deployment via Salt's Reactor:
.. code-block:: text
Event fired at Fri Feb 14 17:40:11 2014
*************************
@ -1653,7 +1657,7 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
And finally deploy the new build:
.. code-block:: yaml
.. code-block:: jinja
{% set secret_key = data.get('headers', {}).get('X-My-Secret-Key') %}
{% set build = data.get('post', {}) %}
@ -1708,9 +1712,9 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
def _check_cors_origin(origin, allowed_origins):
"""
'''
Check if an origin match cors allowed origins
"""
'''
if isinstance(allowed_origins, list):
if origin in allowed_origins:
return origin

View file

@ -178,7 +178,7 @@ class AsyncRemotePillar(RemotePillarMixin):
load,
dictkey='pillar',
)
except:
except Exception:
log.exception('Exception getting pillar:')
raise SaltClientError('Exception getting pillar.')

View file

@ -189,8 +189,6 @@ def ext_pillar(minion_id,
except boto.exception.AWSConnectionError as exc:
log.error('%s: invalid AWS credentials, %s', __name__, exc)
return {}
except:
raise
if conn is None:
log.error('%s: Could not connect to region %s', __name__, region)

View file

@ -515,7 +515,7 @@ def save_reg(data):
try:
with salt.utils.files.fopen(regfile, 'a') as fh_:
msgpack.dump(data, fh_)
except:
except Exception:
log.error('Could not write to msgpack file %s', __opts__['outdir'])
raise
@ -529,6 +529,6 @@ def load_reg():
try:
with salt.utils.files.fopen(regfile, 'r') as fh_:
return msgpack.load(fh_)
except:
except Exception:
log.error('Could not write to msgpack file %s', __opts__['outdir'])
raise

View file

@ -326,7 +326,7 @@ def save_load(jid, load, minions=None):
cur.execute(sql, (jid, salt.utils.json.dumps(load)))
except MySQLdb.IntegrityError:
# https://github.com/saltstack/salt/issues/22171
# Without this try:except: we get tons of duplicate entry errors
# Without this try/except we get tons of duplicate entry errors
# which result in job returns not being stored properly
pass

View file

@ -310,7 +310,7 @@ def save_load(jid, load, minions=None):
cur.execute(sql, (jid, psycopg2.extras.Json(load)))
except psycopg2.IntegrityError:
# https://github.com/saltstack/salt/issues/22171
# Without this try:except: we get tons of duplicate entry errors
# Without this try/except we get tons of duplicate entry errors
# which result in job returns not being stored properly
pass

View file

@ -274,7 +274,7 @@ def save_load(jid, load, minions=None): # pylint: disable=unused-argument
salt.utils.json.dumps(load)))
except psycopg2.IntegrityError:
# https://github.com/saltstack/salt/issues/22171
# Without this try:except: we get tons of duplicate entry errors
# Without this try/except we get tons of duplicate entry errors
# which result in job returns not being stored properly
pass

View file

@ -60,7 +60,7 @@ def returner(ret):
with salt.utils.files.flopen(opts['filename'], 'a') as logfile:
salt.utils.json.dump(ret, logfile)
logfile.write(str('\n')) # future lint: disable=blacklisted-function
except:
except Exception:
log.error('Could not write to rawdata_json file %s', opts['filename'])
raise
@ -79,6 +79,6 @@ def event_return(events):
for event in events:
salt.utils.json.dump(event, logfile)
logfile.write(str('\n')) # future lint: disable=blacklisted-function
except:
except Exception:
log.error('Could not write to rawdata_json file %s', opts['filename'])
raise

View file

@ -175,7 +175,7 @@ def _get_sk(**kwargs):
sk_file = config['sk_file']
if not key and sk_file:
with salt.utils.files.fopen(sk_file, 'rb') as keyf:
key = six.text_type(keyf.read()).rstrip('\n')
key = salt.utils.stringutils.to_unicode(keyf.read()).strip('\n')
if key is None:
raise Exception('no key or sk_file found')
return base64.b64decode(key)
@ -193,7 +193,7 @@ def _get_pk(**kwargs):
pubkey = six.text_type(keyf.read()).rstrip('\n')
if pubkey is None:
raise Exception('no pubkey or pk_file found')
pubkey = six.text_type(pubkey)
pubkey = salt.utils.stringutils.to_str(pubkey)
return base64.b64decode(pubkey)

View file

@ -271,7 +271,7 @@ class Loader(BaseLoader): # pylint: disable=W0232
def construct_sls_aggregate(self, node):
try:
tag, deep = self.resolve_sls_tag(node)
except:
except Exception:
raise ConstructorError('unable to build reset')
node = copy.copy(node)
@ -288,7 +288,7 @@ class Loader(BaseLoader): # pylint: disable=W0232
def construct_sls_reset(self, node):
try:
tag, deep = self.resolve_sls_tag(node)
except:
except Exception:
raise ConstructorError('unable to build reset')
node = copy.copy(node)

View file

@ -77,7 +77,7 @@ def cert(name,
window = None
try:
window = int(renew)
except: # pylint: disable=bare-except
except Exception:
pass
comment = 'Certificate {0} '.format(name)

View file

@ -803,7 +803,7 @@ class _Swagger(object):
method='')
self._lambda_funcname_format.format(**known_kwargs)
return True
except:
except Exception:
raise ValueError('Invalid lambda_funcname_format {0}. Please review '
'documentation for known substitutable keys'.format(self._lambda_funcname_format))

View file

@ -66,7 +66,7 @@ def present(name, acl_type, acl_name='', perms='', recurse=False):
ret['result'] = False
return ret
__current_perms = __salt__['acl.getfacl'](name)
__current_perms = __salt__['acl.getfacl'](name, recursive=recurse)
if acl_type.startswith(('d:', 'default:')):
_acl_type = ':'.join(acl_type.split(':')[1:])
@ -97,7 +97,18 @@ def present(name, acl_type, acl_name='', perms='', recurse=False):
user = None
if user:
if user[_search_name]['octal'] == sum([_octal.get(i, i) for i in perms]):
octal_sum = sum([_octal.get(i, i) for i in perms])
need_refresh = False
for path in __current_perms:
acl_found = False
for user_acl in __current_perms[path].get(_acl_type, []):
if _search_name in user_acl and user_acl[_search_name]['octal'] == octal_sum:
acl_found = True
break
if not acl_found:
need_refresh = True
break
if not need_refresh:
ret['comment'] = 'Permissions are in the desired state'
else:
changes = {'new': {'acl_name': acl_name,
@ -169,7 +180,7 @@ def absent(name, acl_type, acl_name='', perms='', recurse=False):
ret['result'] = False
return ret
__current_perms = __salt__['acl.getfacl'](name)
__current_perms = __salt__['acl.getfacl'](name, recursive=recurse)
if acl_type.startswith(('d:', 'default:')):
_acl_type = ':'.join(acl_type.split(':')[1:])
@ -199,7 +210,18 @@ def absent(name, acl_type, acl_name='', perms='', recurse=False):
except (AttributeError, IndexError, StopIteration, KeyError):
user = None
if user:
need_refresh = False
for path in __current_perms:
acl_found = False
for user_acl in __current_perms[path].get(_acl_type, []):
if _search_name in user_acl:
acl_found = True
break
if acl_found:
need_refresh = True
break
if user or need_refresh:
ret['comment'] = 'Removing permissions'
if __opts__['test']:

View file

@ -49,11 +49,9 @@ from __future__ import absolute_import, print_function, unicode_literals
import logging
try:
HAS_VARSTACK = False
import varstack
HAS_VARSTACK = True
except ImportError:
pass
varstack = None
# Set up logging
log = logging.getLogger(__name__)
@ -63,10 +61,7 @@ __virtualname__ = 'varstack'
def __virtual__():
if not HAS_VARSTACK:
log.error("Can't find varstack master_top")
return False
return __virtualname__
return (False, 'varstack not installed') if varstack is None else __virtualname__
def top(**kwargs):

View file

@ -881,7 +881,7 @@ class SaltEvent(object):
# shutdown-- where globals start going missing
try:
self.destroy()
except: # pylint: disable=W0702
except Exception:
pass

View file

@ -387,11 +387,11 @@ class CkMinions(object):
try:
# Target is an address?
tgt = ipaddress.ip_address(tgt)
except: # pylint: disable=bare-except
except Exception:
try:
# Target is a network?
tgt = ipaddress.ip_network(tgt)
except: # pylint: disable=bare-except
except Exception:
log.error('Invalid IP/CIDR target: %s', tgt)
return {'minions': [],
'missing': []}

View file

@ -1349,7 +1349,7 @@ def mac2eui64(mac, prefix=None):
net = ipaddress.ip_network(prefix, strict=False)
euil = int('0x{0}'.format(eui64), 16)
return '{0}/{1}'.format(net[euil], net.prefixlen)
except: # pylint: disable=bare-except
except Exception:
return

View file

@ -474,7 +474,7 @@ def render_mako_tmpl(tmplstr, context, tmplpath=None):
uri=context['sls'].replace('.', '/') if 'sls' in context else None,
lookup=lookup
).render(**context)
except:
except Exception:
raise SaltRenderError(mako.exceptions.text_error_template().render())

View file

@ -502,7 +502,7 @@ class Terminal(object):
if tty_fd >= 0:
os.close(tty_fd)
# which exception, shouldn't we catch explicitly .. ?
except: # pylint: disable=W0702
except Exception:
# Already disconnected. This happens if running inside cron
pass
@ -520,7 +520,7 @@ class Terminal(object):
'still possible to open /dev/tty.'
)
# which exception, shouldn't we catch explicitly .. ?
except: # pylint: disable=W0702
except Exception:
# Good! We are disconnected from a controlling tty.
pass

View file

@ -697,7 +697,8 @@ class GitModuleTest(ModuleCase):
second_rev = self.run_function(
'git.revision',
[self.repo],
rev=self.branches[1]
rev=self.branches[1],
timeout=120
)
# Make sure revision is a 40-char string
self.assertTrue(len(second_rev) == 40)

View file

@ -102,7 +102,7 @@ class UseraddModuleTestLinux(ModuleCase):
uid_info = self.run_function('user.info', [name])
self.assertIn(primary_group, uid_info['groups'])
except:
except Exception:
self.run_function('user.delete', [name])
raise

View file

@ -69,7 +69,7 @@ class NaclTest(ShellCase):
pk = ret['return']['pk']
sk = ret['return']['sk']
unencrypted_data = 'hello'
unencrypted_data = b'hello'
# Encrypt with pk
ret = self.run_run_plus(

View file

@ -51,6 +51,14 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
{name: {acl_type: [{}]}},
{name: {acl_type: [{}]}},
{name: {acl_type: [{}]}},
{
name: {acl_type: [{acl_name: {'octal': 7}}]},
name+"/foo": {acl_type: [{acl_name: {'octal': 'A'}}]}
},
{
name: {acl_type: [{acl_name: {'octal': 7}}]},
name+"/foo": {acl_type: [{acl_name: {'octal': 7}}]}
},
{name: {acl_type: ''}}])
mock_modfacl = MagicMock(return_value=True)
@ -146,6 +154,41 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
self.assertDictEqual(linux_acl.present(name, acl_type,
acl_name, perms),
ret)
# New - recurse true
with patch.dict(linux_acl.__salt__, {'acl.getfacl': mock}):
# Update - test=True
with patch.dict(linux_acl.__opts__, {'test': True}):
comt = ('Updated permissions will be applied for {0}: 7 -> {1}'
''.format(acl_name, perms))
ret = {'name': name,
'comment': comt,
'changes': {},
'pchanges': {'new': {'acl_name': acl_name,
'acl_type': acl_type,
'perms': perms},
'old': {'acl_name': acl_name,
'acl_type': acl_type,
'perms': '7'}},
'result': None}
self.assertDictEqual(linux_acl.present(name, acl_type, acl_name,
perms, recurse=False), ret)
# New - recurse true - nothing to do
with patch.dict(linux_acl.__salt__, {'acl.getfacl': mock}):
# Update - test=True
with patch.dict(linux_acl.__opts__, {'test': True}):
comt = ('Permissions are in the desired state')
ret = {'name': name,
'comment': comt,
'changes': {},
'pchanges': {},
'result': True}
self.assertDictEqual(linux_acl.present(name, acl_type, acl_name,
perms, recurse=True), ret)
# No acl type
comt = ('ACL Type does not exist')
ret = {'name': name, 'comment': comt, 'result': False,
@ -153,7 +196,7 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
self.assertDictEqual(linux_acl.present(name, acl_type, acl_name,
perms), ret)
# 'absent' function tests: 1
# 'absent' function tests: 2
def test_absent(self):
'''
@ -180,3 +223,26 @@ class LinuxAclTestCase(TestCase, LoaderModuleMockMixin):
comt = ('ACL Type does not exist')
ret.update({'comment': comt, 'result': False})
self.assertDictEqual(linux_acl.absent(name, acl_type, acl_name, perms), ret)
def test_absent_recursive(self):
'''
Test to ensure a Linux ACL does not exist
'''
name = '/root'
acl_type = 'users'
acl_name = 'damian'
perms = 'rwx'
ret = {'name': name,
'result': None,
'comment': '',
'changes': {}}
mock = MagicMock(side_effect=[
{name: {acl_type: [{acl_name: {'octal': 7}}]}, name+"/foo": {acl_type: [{acl_name: {'octal': 'A'}}]}}
])
with patch.dict(linux_acl.__salt__, {'acl.getfacl': mock}):
with patch.dict(linux_acl.__opts__, {'test': True}):
comt = ('Removing permissions')
ret.update({'comment': comt})
self.assertDictEqual(linux_acl.absent(name, acl_type, acl_name, perms, recurse=True), ret)

View file

@ -138,8 +138,8 @@ class JSONTestCase(TestCase):
Test dumping to and loading from a file handle
'''
with salt.utils.files.fopen(json_out, 'wb') as fp_:
fp_.write(salt.utils.to_bytes(salt.utils.json.dumps(self.data)))
fp_.write(salt.utils.stringutils.to_bytes(salt.utils.json.dumps(self.data)))
with salt.utils.files.fopen(json_out, 'rb') as fp_:
ret = salt.utils.json.loads(salt.utils.to_unicode(fp_.read()))
ret = salt.utils.json.loads(salt.utils.stringutils.to_unicode(fp_.read()))
# Loading should be equal to the original data
self.assertEqual(ret, self.data)

View file

@ -67,6 +67,7 @@ integration.runners.test_fileserver
integration.runners.test_jobs
integration.runners.test_manage
integration.runners.test_runner_returns
integration.runners.test_nacl
integration.runners.test_salt
integration.sdb.test_env
integration.states.test_host