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 <Raphael.Lima@windriver.com>
This commit is contained in:
Raphael Lima 2024-04-09 13:16:36 -03:00
parent de9d380dc9
commit c7f3d71c5f
1 changed files with 17 additions and 0 deletions

View File

@ -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()}