def _get_compute_id(local_ips, id_to_node_ips):
    """
    Compute the instance ID of the local machine.

    Expectation is that our local IPs intersect with one (only) of the
    remote nodes' sets of IPs.

    :param set local_ips: The local machine's IPs.
    :param id_to_node_ips: Mapping from instance IDs to sets of IPs, as
        reported by OpenStack.

    :return: Instance ID of local machine.
    """
    matching_instances = []
    for server_id, api_addresses in id_to_node_ips.items():
        if api_addresses.intersection(local_ips):
            matching_instances.append(server_id)

    # If we've got this correct there should only be one matching instance.
    # But we don't currently test this directly. See FLOC-2281.
    if len(matching_instances) == 1 and matching_instances[0]:
        return matching_instances[0]
    raise KeyError("Couldn't find matching node.")