mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-08 03:30:33 -07:00
Move version check for resource_limits to implementations
This commit is contained in:
parent
424b33d1f8
commit
97604477c6
3 changed files with 13 additions and 28 deletions
|
@ -17,3 +17,9 @@ def use_old_user_mgmt(cursor):
|
||||||
|
|
||||||
def supports_identified_by_password(cursor):
|
def supports_identified_by_password(cursor):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def server_supports_alter_user(cursor):
|
||||||
|
version = get_server_version(cursor)
|
||||||
|
|
||||||
|
return LooseVersion(version) >= LooseVersion("10.2")
|
||||||
|
|
|
@ -18,3 +18,9 @@ def use_old_user_mgmt(cursor):
|
||||||
def supports_identified_by_password(cursor):
|
def supports_identified_by_password(cursor):
|
||||||
version = get_server_version(cursor)
|
version = get_server_version(cursor)
|
||||||
return LooseVersion(version) < LooseVersion("8")
|
return LooseVersion(version) < LooseVersion("8")
|
||||||
|
|
||||||
|
|
||||||
|
def server_supports_alter_user(cursor):
|
||||||
|
version = get_server_version(cursor)
|
||||||
|
|
||||||
|
return LooseVersion(version) >= LooseVersion("5.6")
|
||||||
|
|
|
@ -753,33 +753,6 @@ def convert_priv_dict_to_str(priv):
|
||||||
return '/'.join(priv_list)
|
return '/'.join(priv_list)
|
||||||
|
|
||||||
|
|
||||||
# Alter user is supported since MySQL 5.6 and MariaDB 10.2.0
|
|
||||||
def server_supports_alter_user(cursor):
|
|
||||||
"""Check if the server supports ALTER USER statement or doesn't.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
cursor (cursor): DB driver cursor object.
|
|
||||||
|
|
||||||
Returns: True if supports, False otherwise.
|
|
||||||
"""
|
|
||||||
cursor.execute("SELECT VERSION()")
|
|
||||||
version_str = cursor.fetchone()[0]
|
|
||||||
version = version_str.split('.')
|
|
||||||
|
|
||||||
if 'mariadb' in version_str.lower():
|
|
||||||
# MariaDB 10.2 and later
|
|
||||||
if int(version[0]) * 1000 + int(version[1]) >= 10002:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
# MySQL 5.6 and later
|
|
||||||
if int(version[0]) * 1000 + int(version[1]) >= 5006:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def get_resource_limits(cursor, user, host):
|
def get_resource_limits(cursor, user, host):
|
||||||
"""Get user resource limits.
|
"""Get user resource limits.
|
||||||
|
|
||||||
|
@ -869,7 +842,7 @@ def limit_resources(module, cursor, user, host, resource_limits, check_mode):
|
||||||
|
|
||||||
Returns: True, if changed, False otherwise.
|
Returns: True, if changed, False otherwise.
|
||||||
"""
|
"""
|
||||||
if not server_supports_alter_user(cursor):
|
if not impl.server_supports_alter_user(cursor):
|
||||||
module.fail_json(msg="The server version does not match the requirements "
|
module.fail_json(msg="The server version does not match the requirements "
|
||||||
"for resource_limits parameter. See module's documentation.")
|
"for resource_limits parameter. See module's documentation.")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue