'Check if the job is finished.'

def _is_job_finished(self, conn, job):

    jobInstanceName = job['Job']
    jobinstance = conn.GetInstance(jobInstanceName, LocalOnly=False)
    jobstate = jobinstance['JobState']
    LOG.debug('_is_job_finished,state:    %(state)s', {'state': jobstate})
    if (jobstate in [2, 3, 4]):
        job_finished = False
    else:
        job_finished = True
    LOG.debug('_is_job_finished,    finish:    %s.', job_finished)
    return job_finished
