Skip to content
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

mysql_info: Add parameter for __collect method #136

Merged
merged 3 commits into from
Apr 11, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions plugins/modules/database/mysql/mysql_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def get_info(self, filter_, exclude_fields, return_empty_dbs):
filter_ (list): List of collected subsets (e.g., databases, users, etc.),
when it is empty, return all available information.
"""
self.__collect(exclude_fields, return_empty_dbs)

inc_list = []
exc_list = []
Expand All @@ -277,30 +276,51 @@ def get_info(self, filter_, exclude_fields, return_empty_dbs):
inc_list.append(fi)

if inc_list:
self.__collect(exclude_fields, return_empty_dbs, set(inc_list))

for i in self.info:
if i in inc_list:
partial_info[i] = self.info[i]

else:
not_in_exc_list = list(set(self.info) - set(exc_list))
self.__collect(exclude_fields, return_empty_dbs, set(not_in_exc_list))

for i in self.info:
if i not in exc_list:
partial_info[i] = self.info[i]

return partial_info

else:
self.__collect(exclude_fields, return_empty_dbs, set(self.info))
return self.info

def __collect(self, exclude_fields, return_empty_dbs):
def __collect(self, exclude_fields, return_empty_dbs, wanted):
"""Collect all possible subsets."""
self.__get_databases(exclude_fields, return_empty_dbs)
self.__get_global_variables()
self.__get_global_status()
self.__get_engines()
self.__get_users()
self.__get_master_status()
self.__get_slave_status()
self.__get_slaves()
if 'version' in wanted or 'settings' in wanted:
self.__get_global_variables()

if 'databases' in wanted:
self.__get_databases(exclude_fields, return_empty_dbs)

if 'global_status' in wanted:
self.__get_global_status()

if 'engines' in wanted:
self.__get_engines()

if 'users' in wanted:
self.__get_users()

if 'master_status' in wanted:
self.__get_master_status()

if 'slave_status' in wanted:
self.__get_slave_status()

if 'slave_hosts' in wanted:
self.__get_slaves()

def __get_engines(self):
"""Get storage engines info."""
Expand Down