diff --git a/sahara/api/v2/jobs.py b/sahara/api/v2/jobs.py index b6e89d16..34a2e6c6 100644 --- a/sahara/api/v2/jobs.py +++ b/sahara/api/v2/jobs.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import six from sahara.api import acl from sahara.service.api.v2 import jobs as api @@ -52,17 +53,11 @@ def jobs_execute(data): @acl.enforce("data-processing:job-executions:get") @v.check_exists(api.get_job_execution, id='job_id') def jobs_get(job_id): - result = u.to_wrapped_dict_no_render(api.get_job_execution, job_id) - result['engine_job_id'] = result['oozie_job_id'] - del result['oozie_job_id'] - return u.render(result) - - -@rest.get('/jobs//refresh-status') -@acl.enforce("data-processing:job-executions:refresh_status") -@v.check_exists(api.get_job_execution, id='job_id') -def jobs_status(job_id): - result = u.to_wrapped_dict_no_render(api.get_job_execution_status, job_id) + data = u.get_request_args() + refresh_status = six.text_type( + data.get('refresh_status', 'false')).lower() == 'true' + result = u.to_wrapped_dict_no_render( + api.get_job_execution, job_id, refresh_status) result['engine_job_id'] = result['oozie_job_id'] del result['oozie_job_id'] return u.render(result) diff --git a/sahara/service/api/v2/jobs.py b/sahara/service/api/v2/jobs.py index fc09855d..b4b58b27 100644 --- a/sahara/service/api/v2/jobs.py +++ b/sahara/service/api/v2/jobs.py @@ -71,17 +71,16 @@ def execute_job(data): return job_execution -def get_job_execution_status(id): - return manager.get_job_status(id) - - def job_execution_list(**kwargs): return conductor.job_execution_get_all(context.ctx(), regex_search=True, **kwargs) -def get_job_execution(id): - return conductor.job_execution_get(context.ctx(), id) +def get_job_execution(id, refresh_status=False): + if refresh_status: + return manager.get_job_status(id) + else: + return conductor.job_execution_get(context.ctx(), id) def cancel_job_execution(id):