def _update_project_members(self, request, data, project_id):
    users_to_add = 0
    try:
        available_roles = api.keystone.role_list(request)
        member_step = self.get_step(PROJECT_USER_MEMBER_SLUG)
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            role_list = data[field_name]
            users_to_add += len(role_list)
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            role_list = data[field_name]
            users_added = 0
            for user in role_list:
                api.keystone.add_tenant_user_role(request, project=project_id, user=user, role=role.id)
                users_added += 1
            users_to_add -= users_added
    except Exception:
        group_msg = _(', add project groups')
        exceptions.handle(request, (_('Failed to add %(users_to_add)s project members%(group_msg)s and set project quotas.') % {'users_to_add': users_to_add, 'group_msg': group_msg}))
def _update_project_members(self, request, data, project_id):
    users_to_add = 0
    try:
        available_roles = api.keystone.role_list(request)
        member_step = self.get_step(PROJECT_USER_MEMBER_SLUG)
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            role_list = data[field_name]
            users_to_add += len(role_list)
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            role_list = data[field_name]
            users_added = 0
            for user in role_list:
                api.keystone.add_tenant_user_role(request, project=project_id, user=user, role=role.id)
                users_added += 1
            users_to_add -= users_added
    except Exception:
        group_msg = _(', add project groups')
        exceptions.handle(request, (_('Failed to add %(users_to_add)s project members%(group_msg)s and set project quotas.') % {'users_to_add': users_to_add, 'group_msg': group_msg}))