diff --git a/module_utils/kafka_lib_user.py b/module_utils/kafka_lib_user.py index e8801887..2ad54d0b 100644 --- a/module_utils/kafka_lib_user.py +++ b/module_utils/kafka_lib_user.py @@ -5,7 +5,7 @@ from kafka.errors import KafkaError -from ansible.module_utils import kafka_scram +from ansible.module_utils.kafka_scram import get_mechanism_from_int from ansible.module_utils.pycompat24 import get_exception from ansible.module_utils.kafka_lib_commons import ( get_manager_from_params, @@ -84,7 +84,7 @@ def run_module_users(manager, module, params): current_users = collections.defaultdict(dict) for username, err_c, err_m, cred_infos, ts in describe_results: for mechanism, iterations, tags in cred_infos: - mechanism_name = kafka_scram.get_mechanism_from_int(mechanism).name + mechanism_name = get_mechanism_from_int(mechanism).name current_users[username][mechanism_name] = iterations users_to_create = [] diff --git a/module_utils/kafka_manager.py b/module_utils/kafka_manager.py index 100ea167..b629eb15 100644 --- a/module_utils/kafka_manager.py +++ b/module_utils/kafka_manager.py @@ -55,7 +55,12 @@ UnableToRefreshState, MissingConfiguration, ZookeeperBroken ) -from ansible.module_utils import kafka_scram +from ansible.module_utils.kafka_scram import ( + get_mechanism_from_name, + create_random_salt, + create_salted_password, + get_mechanism_from_int +) class KafkaManager: @@ -322,18 +327,18 @@ def describe_scram_credentials(self): @staticmethod def _convert_user_to_request_upsertion(user): mechanism = user['mechanism'] - m = kafka_scram.get_mechanism_from_name(mechanism) + m = get_mechanism_from_name(mechanism) mechanism_int = m.int_representation - salt = kafka_scram.create_random_salt() + salt = create_random_salt() salted_pass, salt, iterations = \ - kafka_scram.create_salted_password( + create_salted_password( mechanism, user['password'], salt, user['iterations']) return user['name'], mechanism_int, iterations, salt, salted_pass, {} @staticmethod def _convert_user_to_request_deletion(user): - mechanism = kafka_scram.get_mechanism_from_name(user['mechanism']) + mechanism = get_mechanism_from_name(user['mechanism']) return (user['name'], mechanism.int_representation, {}) def alter_scram_users(self, users_to_be_deleted, users_to_be_created): @@ -1429,7 +1434,7 @@ def _convert_describe_scram_credentials_to_user_resource(results): users = collections.defaultdict(list) for username, err_code, err_message, credential_infos, tags in results: for mechanism, iterations, tags in credential_infos: - m = kafka_scram.get_mechanism_from_int(mechanism) + m = get_mechanism_from_int(mechanism) users[username].append({ 'mechanism': m.name, 'iterations': iterations