From c7f3d71c5fce3352b95b94b9bb58c0206ee2a2bd Mon Sep 17 00:00:00 2001 From: Raphael Lima Date: Tue, 9 Apr 2024 13:16:36 -0300 Subject: [PATCH] Create a set_users_options method in openstack endpoint config This commit creates the set_users_options in openstack_config_endpoints.py, which is required in [1] in order to set the ignore_lockout_failure_attempts for both sysinv and admin users during the sysinv bootstrap process. [1]: https://review.opendev.org/c/starlingx/ansible-playbooks/+/913930 Test plan: Note that all of the test cases were performed with the changes from [1]. 1. PASS: Verify the openstack user, role, service and endpoints configuration for sysinv after bootstrap 2. PASS: Verify that both the admin and sysinv openstack users contain the ignore_lockout_failure_attempts option set to True. Story: 2011035 Task: 49844 Change-Id: I9c11e7305602d24f8170759f5f9363e4a6d012a4 Signed-off-by: Raphael Lima --- .../sysinv/common/openstack_config_endpoints.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sysinv/sysinv/sysinv/sysinv/common/openstack_config_endpoints.py b/sysinv/sysinv/sysinv/sysinv/common/openstack_config_endpoints.py index 1a7994a71b..a98ac3490b 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/openstack_config_endpoints.py +++ b/sysinv/sysinv/sysinv/sysinv/common/openstack_config_endpoints.py @@ -184,6 +184,23 @@ def create_users(keystone, users_to_create): LOG.info(f"User {username} successfully created") +@retry(stop_max_attempt_number=3, wait_fixed=1000) +def set_users_options(keystone, users_to_update, options): + """ + Set the options for a list of users + + :param keystone: keystone's client + :param users_to_update: list of user's names to update + :param options: a dictionary of options to set for the users + """ + + keystone_users = keystone.users.list() + + for user in keystone_users: + if user.name in users_to_update: + keystone.users.update(user.id, options=options) + + @retry(stop_max_attempt_number=3, wait_fixed=1000) def grant_admin_role(keystone, users_to_create, project_name): roles_dict = {role.name: role.id for role in keystone.roles.list()}