Skip to content

Commit

Permalink
Fix to support different versions (#10)
Browse files Browse the repository at this point in the history
* Fix to support different versions

* Fix to support different versions

---------

Co-authored-by: aleksvagachev <aleksvagachev@yandex.ru>
  • Loading branch information
aleksvagachev and aleksvagachev authored Jan 26, 2024
1 parent 13712fb commit 624fdc9
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions plugins/modules/clickhouse_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def get_databases(module, client):
Returns a dictionary with database names as keys.
"""
query = "SELECT name, engine, data_path, uuid, comment FROM system.databases"
query = "SELECT name, engine, data_path, uuid FROM system.databases"
result = execute_query(module, client, query)

if result == PRIV_ERR_CODE:
Expand All @@ -205,7 +205,6 @@ def get_databases(module, client):
"engine": row[1],
"data_path": row[2],
"uuid": str(row[3]),
"comment": row[4],
}

return db_info
Expand All @@ -218,9 +217,7 @@ def get_clusters(module, client):
"""
query = ("SELECT cluster, shard_num, shard_weight, replica_num, host_name, "
"host_address, port, is_local, user, default_database, errors_count, "
"slowdowns_count, estimated_recovery_time, database_shard_name, "
"database_replica_name, is_active "
"FROM system.clusters")
"estimated_recovery_time FROM system.clusters")
result = execute_query(module, client, query)

if result == PRIV_ERR_CODE:
Expand All @@ -240,11 +237,7 @@ def get_clusters(module, client):
user = row[8]
default_database = row[9]
errors_count = row[10]
slowdowns_count = row[11]
estimated_recovery_time = row[12]
database_shard_name = row[13]
database_replica_name = row[14]
is_active = row[15]
estimated_recovery_time = row[11]

# Add cluster if not already there
if cluster not in cluster_info:
Expand All @@ -267,11 +260,7 @@ def get_clusters(module, client):
"user": user,
"default_database": default_database,
"errors_count": errors_count,
"slowdowns_count": slowdowns_count,
"estimated_recovery_time": estimated_recovery_time,
"database_shard_name": database_shard_name,
"database_replica_name": database_replica_name,
"is_active": is_active,
}

return cluster_info
Expand Down Expand Up @@ -303,8 +292,8 @@ def get_settings(module, client):
Returns a dictionary with settings names as keys.
"""
query = ("SELECT name, value, changed, description, min, max, readonly, default, "
"is_obsolete FROM system.settings")
query = ("SELECT name, value, changed, description, min, max, readonly, "
"type FROM system.settings")
result = execute_query(module, client, query)

if result == PRIV_ERR_CODE:
Expand All @@ -319,8 +308,7 @@ def get_settings(module, client):
"min": row[4],
"max": row[5],
"readonly": row[6],
"default": row[7],
"is_obsolete": row[8],
"type": row[7],
}

return settings_info
Expand Down

0 comments on commit 624fdc9

Please sign in to comment.