mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Exception handling in mysql module
This commit is contained in:
parent
d9ef3ca2cf
commit
ad07734c6d
@ -1572,9 +1572,13 @@ def grant_exists(grant,
|
|||||||
salt '*' mysql.grant_exists \
|
salt '*' mysql.grant_exists \
|
||||||
'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
|
'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
|
||||||
'''
|
'''
|
||||||
target = __grant_generate(
|
try:
|
||||||
grant, database, user, host, grant_option, escape
|
target = __grant_generate(
|
||||||
)
|
grant, database, user, host, grant_option, escape
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
log.error('Error during grant generation.')
|
||||||
|
return False
|
||||||
|
|
||||||
grants = user_grants(user, host, **connection_args)
|
grants = user_grants(user, host, **connection_args)
|
||||||
|
|
||||||
@ -1636,7 +1640,11 @@ def grant_add(grant,
|
|||||||
|
|
||||||
# Avoid spaces problems
|
# Avoid spaces problems
|
||||||
grant = grant.strip()
|
grant = grant.strip()
|
||||||
qry = __grant_generate(grant, database, user, host, grant_option, escape, ssl_option)
|
try:
|
||||||
|
qry = __grant_generate(grant, database, user, host, grant_option, escape, ssl_option)
|
||||||
|
except Exception:
|
||||||
|
log.error('Error during grant generation')
|
||||||
|
return False
|
||||||
try:
|
try:
|
||||||
_execute(cur, qry['qry'], qry['args'])
|
_execute(cur, qry['qry'], qry['args'])
|
||||||
except (MySQLdb.OperationalError, MySQLdb.ProgrammingError) as exc:
|
except (MySQLdb.OperationalError, MySQLdb.ProgrammingError) as exc:
|
||||||
|
Loading…
Reference in New Issue
Block a user