@pytest.fixture(scope='module')
def acl_table(duthosts, rand_one_dut_hostname, setup, stage, ip_version):
    'Apply ACL table configuration and remove after tests.\n\n    Args:\n        duthosts: All DUTs belong to the testbed.\n        rand_one_dut_hostname: hostname of a random chosen dut to run test.\n        setup: Parameters for the ACL tests.\n        stage: The ACL stage under test.\n        ip_version: The IP version under test\n\n    Yields:\n        The ACL table configuration.\n\n    '
    table_name = 'DATA_{}_{}_TEST'.format(stage.upper(), ip_version.upper())
    acl_table_config = {'table_name': table_name, 'table_ports': ','.join(setup['acl_table_ports']['']), 'table_stage': stage, 'table_type': ('L3' if (ip_version == 'ipv4') else 'L3V6')}
    logger.info('Generated ACL table configuration:\n{}'.format(pprint.pformat(acl_table_config)))
    dut_to_analyzer_map = {}
    for duthost in duthosts:
        loganalyzer = LogAnalyzer(ansible_host=duthost, marker_prefix='acl')
        loganalyzer.load_common_config()
        dut_to_analyzer_map[duthost] = loganalyzer
        try:
            loganalyzer.expect_regex = [LOG_EXPECT_ACL_TABLE_CREATE_RE]
            with loganalyzer:
                create_or_remove_acl_table(duthost, acl_table_config, setup, 'add')
        except LogAnalyzerError as err:
            logger.error('ACL table creation failed, attempting to clean-up...')
            create_or_remove_acl_table(duthost, acl_table_config, setup, 'remove')
            raise err
    try:
        (yield acl_table_config)
    finally:
        for (duthost, loganalyzer) in dut_to_analyzer_map.items():
            loganalyzer.expect_regex = [LOG_EXPECT_ACL_TABLE_REMOVE_RE]
            with loganalyzer:
                create_or_remove_acl_table(duthost, acl_table_config, setup, 'remove')
Apply ACL table configuration and remove after tests.

Args:
    duthosts: All DUTs belong to the testbed.
    rand_one_dut_hostname: hostname of a random chosen dut to run test.
    setup: Parameters for the ACL tests.
    stage: The ACL stage under test.
    ip_version: The IP version under test

Yields:
    The ACL table configuration.
@pytest.fixture(scope='module')
def acl_table(duthosts, rand_one_dut_hostname, setup, stage, ip_version):
    'Apply ACL table configuration and remove after tests.\n\n    Args:\n        duthosts: All DUTs belong to the testbed.\n        rand_one_dut_hostname: hostname of a random chosen dut to run test.\n        setup: Parameters for the ACL tests.\n        stage: The ACL stage under test.\n        ip_version: The IP version under test\n\n    Yields:\n        The ACL table configuration.\n\n    '
    table_name = 'DATA_{}_{}_TEST'.format(stage.upper(), ip_version.upper())
    acl_table_config = {'table_name': table_name, 'table_ports': ','.join(setup['acl_table_ports'][]), 'table_stage': stage, 'table_type': ('L3' if (ip_version == 'ipv4') else 'L3V6')}
    logger.info('Generated ACL table configuration:\n{}'.format(pprint.pformat(acl_table_config)))
    dut_to_analyzer_map = {}
    for duthost in duthosts:
        loganalyzer = LogAnalyzer(ansible_host=duthost, marker_prefix='acl')
        loganalyzer.load_common_config()
        dut_to_analyzer_map[duthost] = loganalyzer
        try:
            loganalyzer.expect_regex = [LOG_EXPECT_ACL_TABLE_CREATE_RE]
            with loganalyzer:
                create_or_remove_acl_table(duthost, acl_table_config, setup, 'add')
        except LogAnalyzerError as err:
            logger.error('ACL table creation failed, attempting to clean-up...')
            create_or_remove_acl_table(duthost, acl_table_config, setup, 'remove')
            raise err
    try:
        (yield acl_table_config)
    finally:
        for (duthost, loganalyzer) in dut_to_analyzer_map.items():
            loganalyzer.expect_regex = [LOG_EXPECT_ACL_TABLE_REMOVE_RE]
            with loganalyzer:
                create_or_remove_acl_table(duthost, acl_table_config, setup, 'remove')