def _update_project_groups(self, request, data, project_id):
    groups_to_add = 0
    try:
        available_roles = api.keystone.role_list(request)
        member_step = self.get_step(PROJECT_GROUP_MEMBER_SLUG)
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            role_list = data[field_name]
            groups_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]
            groups_added = 0
            for group in role_list:
                api.keystone.add_group_role(request, role=role.id, group=group, project=project_id)
                groups_added += 1
            groups_to_add -= groups_added
    except Exception:
        exceptions.handle(request, (_('Failed to add %s project groups and update project quotas.') % groups_to_add))
def _update_project_groups(self, request, data, project_id):
    groups_to_add = 0
    try:
        available_roles = api.keystone.role_list(request)
        member_step = self.get_step(PROJECT_GROUP_MEMBER_SLUG)
        for role in available_roles:
            field_name = member_step.get_member_field_name(role.id)
            role_list = data[field_name]
            groups_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]
            groups_added = 0
            for group in role_list:
                api.keystone.add_group_role(request, role=role.id, group=group, project=project_id)
                groups_added += 1
            groups_to_add -= groups_added
    except Exception:
        exceptions.handle(request, (_('Failed to add %s project groups and update project quotas.') % groups_to_add))