def is_driver_compatible(context, driver, interface, host_agent_types):
    """True if the driver is compatible with interface and host_agent_types.

    There may be edge cases where a stale view or the deployment may make the
    following test fail to detect the right driver in charge of the bound port.
    """
    is_interface_compatible = driver.is_interface_compatible(interface)
    if not driver.agent_type:
        return is_interface_compatible
    return is_interface_compatible and driver.agent_type in host_agent_types
