mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
mysql_info: Add parameter for __collect method (#136)
* [Add] Add parameter for __collect method Add parameter for `__collect` method By default the class `MySQL_Info` get all MySQL instance information, add parameter for `__collect` to get only what wants to know(information) Feature Pull Request lib/ansible/modules/database/mysql/mysql_info.py * typo * [add] add changelog - bugfixes: - mysql_info - add parameter for __collect to get only what are wanted (https://github.com/ansible-collections/community.general/pull/136).
This commit is contained in:
parent
eb485c5f6f
commit
5fbe8a1f9d
2 changed files with 32 additions and 10 deletions
2
changelogs/fragments/mysql_info_add_parameter.yml
Normal file
2
changelogs/fragments/mysql_info_add_parameter.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- mysql_info - add parameter for __collect to get only what are wanted (https://github.com/ansible-collections/community.general/pull/136).
|
|
@ -257,7 +257,6 @@ class MySQL_Info(object):
|
||||||
filter_ (list): List of collected subsets (e.g., databases, users, etc.),
|
filter_ (list): List of collected subsets (e.g., databases, users, etc.),
|
||||||
when it is empty, return all available information.
|
when it is empty, return all available information.
|
||||||
"""
|
"""
|
||||||
self.__collect(exclude_fields, return_empty_dbs)
|
|
||||||
|
|
||||||
inc_list = []
|
inc_list = []
|
||||||
exc_list = []
|
exc_list = []
|
||||||
|
@ -277,11 +276,16 @@ class MySQL_Info(object):
|
||||||
inc_list.append(fi)
|
inc_list.append(fi)
|
||||||
|
|
||||||
if inc_list:
|
if inc_list:
|
||||||
|
self.__collect(exclude_fields, return_empty_dbs, set(inc_list))
|
||||||
|
|
||||||
for i in self.info:
|
for i in self.info:
|
||||||
if i in inc_list:
|
if i in inc_list:
|
||||||
partial_info[i] = self.info[i]
|
partial_info[i] = self.info[i]
|
||||||
|
|
||||||
else:
|
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:
|
for i in self.info:
|
||||||
if i not in exc_list:
|
if i not in exc_list:
|
||||||
partial_info[i] = self.info[i]
|
partial_info[i] = self.info[i]
|
||||||
|
@ -289,17 +293,33 @@ class MySQL_Info(object):
|
||||||
return partial_info
|
return partial_info
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
self.__collect(exclude_fields, return_empty_dbs, set(self.info))
|
||||||
return 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."""
|
"""Collect all possible subsets."""
|
||||||
self.__get_databases(exclude_fields, return_empty_dbs)
|
if 'version' in wanted or 'settings' in wanted:
|
||||||
self.__get_global_variables()
|
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()
|
self.__get_global_status()
|
||||||
|
|
||||||
|
if 'engines' in wanted:
|
||||||
self.__get_engines()
|
self.__get_engines()
|
||||||
|
|
||||||
|
if 'users' in wanted:
|
||||||
self.__get_users()
|
self.__get_users()
|
||||||
|
|
||||||
|
if 'master_status' in wanted:
|
||||||
self.__get_master_status()
|
self.__get_master_status()
|
||||||
|
|
||||||
|
if 'slave_status' in wanted:
|
||||||
self.__get_slave_status()
|
self.__get_slave_status()
|
||||||
|
|
||||||
|
if 'slave_hosts' in wanted:
|
||||||
self.__get_slaves()
|
self.__get_slaves()
|
||||||
|
|
||||||
def __get_engines(self):
|
def __get_engines(self):
|
||||||
|
|
Loading…
Reference in a new issue