import random


def pick_ports(cfg_facts):
    """
    Selects ports to bounce by sampling the interface and port channel lists.

    Args:
        cfg_facts: The ansible_facts for the asic.

    Returns:
        intfs: A merged dictionary of ethernet and portchannel interfaces.
        intfs_to_test: A list of the chosen interfaces names.

    """
    intfs = {}
    intfs.update(cfg_facts.get('INTERFACE', {}))
    if "PORTCHANNEL_INTERFACE" in cfg_facts:
        intfs.update(cfg_facts['PORTCHANNEL_INTERFACE'])

    eths = [intf for intf in intfs if "ethernet" in intf.lower()]
    pos = [intf for intf in intfs if "portchannel" in intf.lower()]

    intfs_to_test = []
    if len(eths) > 0:
        intfs_to_test.extend(random.sample(eths, 1))

    if len(pos) > 0:
        intfs_to_test.extend(random.sample(pos, 1))

    return intfs, intfs_to_test