def blazar_find_old_host_alloc(db):
    """Find computehost allocations tied to expired leases"""
    sql = '''\
    SELECT ca.id, l.id AS lid, ch.hypervisor_hostname
    FROM blazar.computehost_allocations ca
    JOIN blazar.reservations r
    ON ca.reservation_id=r.id
    JOIN blazar.leases l
    ON r.lease_id=l.id
    JOIN blazar.computehosts ch
    ON ca.compute_host_id=ch.id
    WHERE ca.deleted is Null
       AND l.end_date < curdate()
    '''
    return db.query(sql, limit=None)