def _update_project_members(self, request, data, project_id):
    users_to_modify = 0
    member_step = self.get_step(PROJECT_USER_MEMBER_SLUG)
    try:
        available_roles = self._get_available_roles(request)
        users_roles = api.keystone.get_project_users_roles(request, project=project_id)
        users_to_modify = len(users_roles)
        all_users = api.keystone.user_list(request, domain=data['domain_id'])
        users_dict = {user.id: user.name for user in all_users}
        for user_id in users_roles:
            if (user_id not in users_dict):
                users_to_modify -= 1
                continue
            current_role_ids = list(users_roles[user_id])
            modified_role_ids = self._add_roles_to_users(request, data, project_id, user_id, current_role_ids, available_roles)
            removing_admin = self._is_removing_self_admin_role(request, project_id, user_id, available_roles, modified_role_ids)
            if (not removing_admin):
                self._remove_roles_from_user(request, project_id, user_id, modified_role_ids)
            users_to_modify -= 1
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            users_to_modify += len(data[field_name])
        for role in available_roles:
            users_added = 0
            field_name = member_step.get_member_field_name(role.id)
            for user_id in data[field_name]:
                if (user_id not in users_roles):
                    api.keystone.add_tenant_user_role(request, project=project_id, user=user_id, role=role.id)
                users_added += 1
            users_to_modify -= users_added
        return True
    except Exception:
        group_msg = _(', update project groups')
        exceptions.handle(request, (_('Failed to modify %(users_to_modify)s project members%(group_msg)s and update project quotas.') % {'users_to_modify': users_to_modify, 'group_msg': group_msg}))
        return False
def _update_project_members(self, request, data, project_id):
    users_to_modify = 0
    member_step = self.get_step(PROJECT_USER_MEMBER_SLUG)
    try:
        available_roles = self._get_available_roles(request)
        users_roles = api.keystone.get_project_users_roles(request, project=project_id)
        users_to_modify = len(users_roles)
        all_users = api.keystone.user_list(request, domain=data['domain_id'])
        users_dict = {user.id: user.name for user in all_users}
        for user_id in users_roles:
            if (user_id not in users_dict):
                users_to_modify -= 1
                continue
            current_role_ids = list(users_roles[user_id])
            modified_role_ids = self._add_roles_to_users(request, data, project_id, user_id, current_role_ids, available_roles)
            removing_admin = self._is_removing_self_admin_role(request, project_id, user_id, available_roles, modified_role_ids)
            if (not removing_admin):
                self._remove_roles_from_user(request, project_id, user_id, modified_role_ids)
            users_to_modify -= 1
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            users_to_modify += len(data[field_name])
        for role in available_roles:
            users_added = 0
            field_name = member_step.get_member_field_name(role.id)
            for user_id in data[field_name]:
                if (user_id not in users_roles):
                    api.keystone.add_tenant_user_role(request, project=project_id, user=user_id, role=role.id)
                users_added += 1
            users_to_modify -= users_added
        return True
    except Exception:
        group_msg = _(', update project groups')
        exceptions.handle(request, (_('Failed to modify %(users_to_modify)s project members%(group_msg)s and update project quotas.') % {'users_to_modify': users_to_modify, 'group_msg': group_msg}))
        return False