def _get_real_instance_if_mismatch(vpc_info, ipaddr, instance, eni):
    """
    Return the real instance for the given IP address, if that instance is
    different than the passed in instance or has a different eni.

    If the ipaddr belongs to the same instance and eni that was passed in then
    this returns None.

    """
    # Careful! A route may be a black-hole route, which still has instance and
    # ENI information for an instance that doesn't exist anymore. If a host was
    # terminated and a new host got the same IP then this route won't be
    # updated and will keep pointing to a non-existing node. So we find the
    # instance by IP and check that the route really points to this instance.
    inst_id = instance.id if instance else ""
    eni_id  = eni.id if eni else ""
    if ipaddr:
        real_instance, real_eni = \
                        find_instance_and_eni_by_ip(vpc_info, ipaddr)
        if real_instance.id != inst_id  or real_eni.id != eni_id:
            return real_instance
    return None
def _get_real_instance_if_mismatch ( vpc_info , ipaddr , instance , eni ) : inst_id = instance . id if instance else "" eni_id = eni . id if eni else "" if ipaddr : real_instance , real_eni = find_instance_and_eni_by_ip ( vpc_info , ipaddr ) if real_instance . id != inst_id or real_eni . id != eni_id : return real_instance return None
Return the real instance for the given IP address, if that instance is
    different than the passed in instance or has a different eni.

    If the ipaddr belongs to the same instance and eni that was passed in then
    this returns None.