'Given the job wait for it to complete.
:param job: the job dict
:param extra_specs: the extra_specs dict.
:returns: rc -- int, result -- string, status -- string,
task -- list of dicts detailing tasks in the job
:raises: VolumeBackendAPIException'

def wait_for_job_complete(self, job, extra_specs):

    (res, tasks) = (None, None)
    if (job['status'].lower == CREATED):
        try:
            (res, tasks) = (job['result'], job['task'])
        except KeyError:
            pass
        return (0, res, job['status'], tasks)
    def _wait_for_job_complete():
        result = None
        retries = kwargs['retries']
        try:
            kwargs['retries'] = (retries + 1)
            if (not kwargs['wait_for_job_called']):
                (is_complete, result, rc, status, task) = self._is_job_finished(job_id)
                if (is_complete is True):
                    kwargs['wait_for_job_called'] = True
                    (kwargs['rc'], kwargs['status']) = (rc, status)
                    (kwargs['result'], kwargs['task']) = (result, task)
        except Exception:
            exception_message = _('Issue    encountered    waiting    for    job.')
            LOG.exception(exception_message)
            raise exception.VolumeBackendAPIException(data=exception_message)
        if (retries > int(extra_specs[utils.RETRIES])):
            LOG.error('_wait_for_job_complete    failed    after    %(retries)d    tries.', {'retries': retries})
            (kwargs['rc'], kwargs['result']) = ((-1), result)
            raise loopingcall.LoopingCallDone()
        if kwargs['wait_for_job_called']:
            raise loopingcall.LoopingCallDone()
    job_id = job['jobId']
    kwargs = {'retries': 0, 'wait_for_job_called': False, 'rc': 0, 'result': None}
    timer = loopingcall.FixedIntervalLoopingCall(_wait_for_job_complete)
    timer.start(interval=int(extra_specs[utils.INTERVAL])).wait()
    LOG.debug('Return    code    is:    %(rc)lu.    Result    is    %(res)s.', {'rc': kwargs['rc'], 'res': kwargs['result']})
    return (kwargs['rc'], kwargs['result'], kwargs['status'], kwargs['task'])
