-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using show all slaves status
when using MariaDB to be consistent with MySQL
#602
Changes from 7 commits
a7de8f8
b2072a2
db4c50e
2de02bd
ed93655
6eec740
4c5e8f8
c66a5ac
3ef93e8
10660cf
fff53b4
690ac6f
aa7c5be
4a2a638
d61bb70
93e42bc
6ac515b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
DOCUMENTATION = r''' | ||
|
@@ -325,9 +326,10 @@ | |
5. add info about the new subset with an example to RETURN block | ||
""" | ||
|
||
def __init__(self, module, cursor): | ||
def __init__(self, module, cursor, server_implementation): | ||
self.module = module | ||
self.cursor = cursor | ||
self.server_implementation = server_implementation | ||
self.info = { | ||
'version': {}, | ||
'databases': {}, | ||
|
@@ -387,6 +389,18 @@ | |
self.__collect(exclude_fields, return_empty_dbs, set(self.info)) | ||
return self.info | ||
|
||
def is_mariadb(self): | ||
if self.server_implementation == "mariadb": | ||
return True | ||
else: | ||
return False | ||
|
||
def is_mysql(self): | ||
if self.server_implementation == "mysql": | ||
return True | ||
else: | ||
return False | ||
|
||
def __collect(self, exclude_fields, return_empty_dbs, wanted): | ||
"""Collect all possible subsets.""" | ||
if 'version' in wanted or 'settings' in wanted: | ||
|
@@ -497,7 +511,10 @@ | |
|
||
def __get_slave_status(self): | ||
"""Get slave status if the instance is a slave.""" | ||
res = self.__exec_sql('SHOW SLAVE STATUS') | ||
if self.is_mariadb(): | ||
res = self.__exec_sql('SHOW ALL SLAVES STATUS') | ||
else: | ||
res = self.__exec_sql('SHOW SLAVE STATUS') | ||
if res: | ||
for line in res: | ||
host = line['Master_Host'] | ||
|
@@ -738,10 +755,16 @@ | |
'Exception message: %s' % (connector_name, connector_version, config_file, to_native(e))) | ||
module.fail_json(msg) | ||
|
||
cursor.execute("SELECT VERSION()") | ||
if 'mariadb' in cursor.fetchone()["VERSION()"].lower(): | ||
server_implementation = "mariadb" | ||
else: | ||
server_implementation = "mysql" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just moved it to the |
||
############################### | ||
# Create object and do main job | ||
|
||
mysql = MySQL_Info(module, cursor) | ||
mysql = MySQL_Info(module, cursor, server_implementation) | ||
|
||
module.exit_json(changed=False, | ||
connector_name=connector_name, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be more at home in module_utils/mysql.py
And it's crazy to think we have a variable
db_engine
in the integrations tests but we don't have an equivalent in the modules. If we implement this in Python, we could then use it in the integrations tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moved it to the
module_utils/mysql.py