Refactor function arguments to handle any query shape

local_integrationtest
Laurent Indermuehle 11 months ago
parent a37ca7fc00
commit 5684823ed9
  1. 22
      plugins/module_utils/mysql.py
  2. 4
      plugins/modules/proxysql_backend_servers.py
  3. 4
      plugins/modules/proxysql_global_variables.py
  4. 4
      plugins/modules/proxysql_mysql_users.py
  5. 4
      plugins/modules/proxysql_query_rules.py
  6. 4
      plugins/modules/proxysql_query_rules_fast_routing.py
  7. 4
      plugins/modules/proxysql_replication_hostgroups.py
  8. 4
      plugins/modules/proxysql_scheduler.py

@ -143,17 +143,27 @@ def proxysql_common_argument_spec():
)
def save_config_to_disk(cursor, variable=None):
def save_config_to_disk(cursor, save_what, variable=None):
if variable and variable.startswith("admin"):
cursor.execute("SAVE ADMIN VARIABLES TO DISK")
config_type = "ADMIN"
elif save_what == "SCHEDULER":
config_type = ""
else:
cursor.execute("SAVE MYSQL VARIABLES TO DISK")
config_type = "MYSQL"
cursor.execute("SAVE {0} {1} TO DISK".format(config_type, save_what))
return True
def load_config_to_runtime(cursor, variable=None):
def load_config_to_runtime(cursor, save_what, variable=None):
if variable and variable.startswith("admin"):
cursor.execute("LOAD ADMIN VARIABLES TO RUNTIME")
config_type = "ADMIN"
elif save_what == "SCHEDULER":
config_type = ""
else:
cursor.execute("LOAD MYSQL VARIABLES TO RUNTIME")
config_type = "MYSQL"
cursor.execute("LOAD {0} {1} TO RUNTIME".format(config_type, save_what))
return True

@ -353,9 +353,9 @@ class ProxySQLServer(object):
def manage_config(self, cursor, state):
if state:
if self.save_to_disk:
save_config_to_disk(cursor)
save_config_to_disk(cursor, "SERVERS")
if self.load_to_runtime:
load_config_to_runtime(cursor)
load_config_to_runtime(cursor, "SERVERS")
def create_server(self, check_mode, result, cursor):
if not check_mode:

@ -142,9 +142,9 @@ def set_config(variable, value, cursor):
def manage_config(variable, save_to_disk, load_to_runtime, cursor, state):
if state:
if save_to_disk:
save_config_to_disk(cursor, variable)
save_config_to_disk(cursor, "VARIABLES", variable)
if load_to_runtime:
load_config_to_runtime(cursor, variable)
load_config_to_runtime(cursor, "VARIABLES", variable)
# ===========================================
# Module execution.

@ -349,9 +349,9 @@ class ProxySQLUser(object):
def manage_config(self, cursor, state):
if state:
if self.save_to_disk:
save_config_to_disk(cursor)
save_config_to_disk(cursor, "USERS")
if self.load_to_runtime:
load_config_to_runtime(cursor)
load_config_to_runtime(cursor, "USERS")
def create_user(self, check_mode, result, cursor):
if not check_mode:

@ -560,9 +560,9 @@ class ProxyQueryRule(object):
def manage_config(self, cursor, state):
if state:
if self.save_to_disk:
save_config_to_disk(cursor)
save_config_to_disk(cursor, "QUERY RULES")
if self.load_to_runtime:
load_config_to_runtime(cursor)
load_config_to_runtime(cursor, "QUERY RULES")
def create_rule(self, check_mode, result, cursor):
if not check_mode:

@ -284,9 +284,9 @@ class ProxyQueryRuleFastRouting(object):
return
if self.save_to_disk:
save_config_to_disk(cursor)
save_config_to_disk(cursor, "QUERY RULES")
if self.load_to_runtime:
load_config_to_runtime(cursor)
load_config_to_runtime(cursor, "QUERY RULES")
def create_rule(self, check_mode, result, cursor):
if not check_mode:

@ -221,9 +221,9 @@ class ProxySQLReplicationHostgroup(object):
def manage_config(self, cursor, state):
if state and not self.check_mode:
if self.save_to_disk:
save_config_to_disk(cursor)
save_config_to_disk(cursor, "SERVERS")
if self.load_to_runtime:
load_config_to_runtime(cursor)
load_config_to_runtime(cursor, "SERVERS")
def create_repl_group(self, result, cursor):
if not self.check_mode:

@ -275,9 +275,9 @@ class ProxySQLSchedule(object):
def manage_config(self, cursor, state):
if state:
if self.save_to_disk:
save_config_to_disk(cursor)
save_config_to_disk(cursor, "SCHEDULER")
if self.load_to_runtime:
load_config_to_runtime(cursor)
load_config_to_runtime(cursor, "SCHEDULER")
def create_schedule(self, check_mode, result, cursor):
if not check_mode:

Loading…
Cancel
Save