Skip to content

Commit

Permalink
Fix ansible collection imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ryarnyah authored Oct 17, 2022
1 parent c22d252 commit ed314e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions module_utils/kafka_lib_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = []
Expand Down
17 changes: 11 additions & 6 deletions module_utils/kafka_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed314e7

Please sign in to comment.