def get_nodes_by_lease(db, lease_id):
    """Get node ids of hosts in a lease."""
    sql = '''\
    SELECT ch.hypervisor_hostname AS node_id
    FROM blazar.leases AS l
    JOIN blazar.reservations AS r ON l.id = r.lease_id
    JOIN blazar.computehost_allocations AS ca ON ca.reservation_id = r.id
    JOIN blazar.computehosts AS ch ON ca.compute_host_id = ch.id
    WHERE l.id = %s
    '''

    return db.query(sql, (lease_id,), limit=None)