import re


def parse_diag_dump_lacp_basic_interfaces(raw_result):
    """
    Parse the 'diag-dump lacp basic' command raw output related to LACP
    interfaces.

    :param str raw_result: vtysh raw result string.
    :rtype: dict
    :return: The parsed result of the getlacpinterfaces in a dictionary of the
             form:

     ::

         {
            'lag':
                {'configured_members': [1, 2],
                 'eligible_members': [1, 2],
                 'participant_members': [1, 2],
                }
        }
    """

    getlacpcounters_re = (
        r'Port lag(?P<lag_number>\d+):\s*'
        r'configured_members\s+:[ ]?(?P<configured_interfaces>[\w \-]*)\s*'
        r'eligible_members\s+:[ ]?(?P<eligible_interfaces>[\w \-]*)\s*'
        r'participant_members\s+:[ ]?(?P<participant_interfaces>[\w \-]*)\s*'
    )
    result = {}

    for re_partial in re.finditer(getlacpcounters_re, raw_result):
        lag = re_partial.groupdict()
        lag_id = lag['lag_number']
        del lag['lag_number']
        lag['configured_interfaces'] = lag['configured_interfaces'].split()
        lag['eligible_interfaces'] = lag['eligible_interfaces'].split()
        lag['participant_interfaces'] = lag['participant_interfaces'].split()
        result[lag_id] = lag
    return result