@pytest.fixture(scope='module')
def setup(duthosts, ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo, ptfadapter):
    'Gather all required test information from DUT and tbinfo.\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        tbinfo: A fixture to gather information about the testbed.\n\n    Yields:\n        A Dictionary with required test information.\n\n    '
    mg_facts = rand_selected_dut.get_extended_minigraph_facts(tbinfo)
    topo = tbinfo['topo']['type']
    vlan_ports = []
    vlan_mac = None
    if (topo == 't0'):
        vlan_ports = [mg_facts['minigraph_ptf_indices'][ifname] for ifname in mg_facts['minigraph_vlans'].values()[0]['members']]
        config_facts = rand_selected_dut.get_running_config_facts()
        vlan_table = config_facts['VLAN']
        vlan_name = list(vlan_table.keys())[0]
        if ('mac' in vlan_table[vlan_name]):
            vlan_mac = vlan_table[vlan_name]['mac']
    downstream_ports = defaultdict(list)
    upstream_ports = defaultdict(list)
    downstream_port_ids = []
    upstream_port_ids = []
    upstream_port_id_to_router_mac_map = {}
    downstream_port_id_to_router_mac_map = {}
    downlink_dst_mac = (vlan_mac if (vlan_mac is not None) else rand_selected_dut.facts['router_mac'])
    for (interface, neighbor) in mg_facts['minigraph_neighbors'].items():
        port_id = mg_facts['minigraph_ptf_indices'][interface]
        if (((topo == 't1') and ('T0' in neighbor['name'])) or ((topo == 't0') and ('Server' in neighbor['name']))):
            downstream_ports[neighbor['namespace']].append(interface)
            downstream_port_ids.append(port_id)
            downstream_port_id_to_router_mac_map[port_id] = downlink_dst_mac
        elif (((topo == 't1') and ('T2' in neighbor['name'])) or ((topo == 't0') and ('T1' in neighbor['name']))):
            upstream_ports[neighbor['namespace']].append(interface)
            upstream_port_ids.append(port_id)
            upstream_port_id_to_router_mac_map[port_id] = rand_selected_dut.facts['router_mac']
    if ('dualtor' not in tbinfo['topo']['name']):
        logging.info('Stopping GARP service on single tor')
        ptfhost.shell('supervisorctl stop garp_service', module_ignore_errors=True)
    if (('dualtor' in tbinfo['topo']['name']) and (rand_unselected_dut is not None)):
        peer_mg_facts = rand_unselected_dut.get_extended_minigraph_facts(tbinfo)
        for (interface, neighbor) in peer_mg_facts['minigraph_neighbors'].items():
            if (((topo == 't1') and ('T2' in neighbor['name'])) or ((topo == 't0') and ('T1' in neighbor['name']))):
                port_id = peer_mg_facts['minigraph_ptf_indices'][interface]
                upstream_port_ids.append(port_id)
                upstream_port_id_to_router_mac_map[port_id] = rand_unselected_dut.facts['router_mac']
    port_channels = mg_facts['minigraph_portchannels']
    acl_table_ports = defaultdict(list)
    if ((topo == 't0') or (tbinfo['topo']['name'] in ('t1', 't1-lag'))):
        for (namespace, port) in downstream_ports.iteritems():
            acl_table_ports[namespace] += port
            if namespace:
                acl_table_ports[''] += port
    if ((topo == 't0') or (tbinfo['topo']['name'] in ('t1-lag', 't1-64-lag', 't1-64-lag-clet'))):
        for (k, v) in port_channels.iteritems():
            acl_table_ports[v['namespace']].append(k)
            if v['namespace']:
                acl_table_ports[''].append(k)
    else:
        for (namespace, port) in upstream_ports.iteritems():
            acl_table_ports[namespace] += port
            if namespace:
                acl_table_ports[''] += port
    dest_mac_mapping = {'downlink->uplink': downstream_port_id_to_router_mac_map, 'uplink->downlink': upstream_port_id_to_router_mac_map}
    setup_information = {'destination_mac': dest_mac_mapping, 'downstream_port_ids': downstream_port_ids, 'upstream_port_ids': upstream_port_ids, 'acl_table_ports': acl_table_ports, 'vlan_ports': vlan_ports, 'topo': topo, 'vlan_mac': vlan_mac}
    logger.info('Gathered variables for ACL test:\n{}'.format(pprint.pformat(setup_information)))
    logger.info('Creating temporary folder "{}" for ACL test'.format(DUT_TMP_DIR))
    for duthost in duthosts:
        duthost.command('mkdir -p {}'.format(DUT_TMP_DIR))
    (yield setup_information)
    logger.info('Removing temporary directory "{}"'.format(DUT_TMP_DIR))
    for duthost in duthosts:
        duthost.command('rm -rf {}'.format(DUT_TMP_DIR))
Gather all required test information from DUT and tbinfo.

Args:
    duthosts: All DUTs belong to the testbed.
    rand_one_dut_hostname: hostname of a random chosen dut to run test.
    tbinfo: A fixture to gather information about the testbed.

Yields:
    A Dictionary with required test information.
@pytest.fixture(scope='module')
def setup(duthosts, ptfhost, rand_selected_dut, rand_unselected_dut, tbinfo, ptfadapter):
    'Gather all required test information from DUT and tbinfo.\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        tbinfo: A fixture to gather information about the testbed.\n\n    Yields:\n        A Dictionary with required test information.\n\n    '
    mg_facts = rand_selected_dut.get_extended_minigraph_facts(tbinfo)
    topo = tbinfo['topo']['type']
    vlan_ports = []
    vlan_mac = None
    if (topo == 't0'):
        vlan_ports = [mg_facts['minigraph_ptf_indices'][ifname] for ifname in mg_facts['minigraph_vlans'].values()[0]['members']]
        config_facts = rand_selected_dut.get_running_config_facts()
        vlan_table = config_facts['VLAN']
        vlan_name = list(vlan_table.keys())[0]
        if ('mac' in vlan_table[vlan_name]):
            vlan_mac = vlan_table[vlan_name]['mac']
    downstream_ports = defaultdict(list)
    upstream_ports = defaultdict(list)
    downstream_port_ids = []
    upstream_port_ids = []
    upstream_port_id_to_router_mac_map = {}
    downstream_port_id_to_router_mac_map = {}
    downlink_dst_mac = (vlan_mac if (vlan_mac is not None) else rand_selected_dut.facts['router_mac'])
    for (interface, neighbor) in mg_facts['minigraph_neighbors'].items():
        port_id = mg_facts['minigraph_ptf_indices'][interface]
        if (((topo == 't1') and ('T0' in neighbor['name'])) or ((topo == 't0') and ('Server' in neighbor['name']))):
            downstream_ports[neighbor['namespace']].append(interface)
            downstream_port_ids.append(port_id)
            downstream_port_id_to_router_mac_map[port_id] = downlink_dst_mac
        elif (((topo == 't1') and ('T2' in neighbor['name'])) or ((topo == 't0') and ('T1' in neighbor['name']))):
            upstream_ports[neighbor['namespace']].append(interface)
            upstream_port_ids.append(port_id)
            upstream_port_id_to_router_mac_map[port_id] = rand_selected_dut.facts['router_mac']
    if ('dualtor' not in tbinfo['topo']['name']):
        logging.info('Stopping GARP service on single tor')
        ptfhost.shell('supervisorctl stop garp_service', module_ignore_errors=True)
    if (('dualtor' in tbinfo['topo']['name']) and (rand_unselected_dut is not None)):
        peer_mg_facts = rand_unselected_dut.get_extended_minigraph_facts(tbinfo)
        for (interface, neighbor) in peer_mg_facts['minigraph_neighbors'].items():
            if (((topo == 't1') and ('T2' in neighbor['name'])) or ((topo == 't0') and ('T1' in neighbor['name']))):
                port_id = peer_mg_facts['minigraph_ptf_indices'][interface]
                upstream_port_ids.append(port_id)
                upstream_port_id_to_router_mac_map[port_id] = rand_unselected_dut.facts['router_mac']
    port_channels = mg_facts['minigraph_portchannels']
    acl_table_ports = defaultdict(list)
    if ((topo == 't0') or (tbinfo['topo']['name'] in ('t1', 't1-lag'))):
        for (namespace, port) in downstream_ports.iteritems():
            acl_table_ports[namespace] += port
            if namespace:
                acl_table_ports[] += port
    if ((topo == 't0') or (tbinfo['topo']['name'] in ('t1-lag', 't1-64-lag', 't1-64-lag-clet'))):
        for (k, v) in port_channels.iteritems():
            acl_table_ports[v['namespace']].append(k)
            if v['namespace']:
                acl_table_ports[].append(k)
    else:
        for (namespace, port) in upstream_ports.iteritems():
            acl_table_ports[namespace] += port
            if namespace:
                acl_table_ports[] += port
    dest_mac_mapping = {'downlink->uplink': downstream_port_id_to_router_mac_map, 'uplink->downlink': upstream_port_id_to_router_mac_map}
    setup_information = {'destination_mac': dest_mac_mapping, 'downstream_port_ids': downstream_port_ids, 'upstream_port_ids': upstream_port_ids, 'acl_table_ports': acl_table_ports, 'vlan_ports': vlan_ports, 'topo': topo, 'vlan_mac': vlan_mac}
    logger.info('Gathered variables for ACL test:\n{}'.format(pprint.pformat(setup_information)))
    logger.info('Creating temporary folder "{}" for ACL test'.format(DUT_TMP_DIR))
    for duthost in duthosts:
        duthost.command('mkdir -p {}'.format(DUT_TMP_DIR))
    (yield setup_information)
    logger.info('Removing temporary directory "{}"'.format(DUT_TMP_DIR))
    for duthost in duthosts:
        duthost.command('rm -rf {}'.format(DUT_TMP_DIR))