diff --git a/sahara_dashboard/api/sahara.py b/sahara_dashboard/api/sahara.py index 2a3e5237..8e26c179 100644 --- a/sahara_dashboard/api/sahara.py +++ b/sahara_dashboard/api/sahara.py @@ -696,11 +696,17 @@ def job_execution_list(request, search_opts=None, marker=None, limit=None): job_dict = {j.id: j for j in _job_list(new_request)} cluster_dict = {c.id: c for c in _cluster_list(new_request)} + def _find_jt_id(jex_obj): + try: + return jex_obj.job_template_id # typical APIv2 + except AttributeError: + return jex_obj.job_id # APIv1.1, older APIv2 + resolved_job_execution_list = [ _resolve_job_execution_names( job_execution, cluster_dict.get(job_execution.cluster_id), - job_dict.get(job_execution.job_id)) + job_dict.get(_find_jt_id(job_execution))) for job_execution in job_execution_list ] @@ -719,7 +725,11 @@ def job_execution_get(request, jex_id): jex = getattr(sahara, je_manager).get(obj_id=jex_id) cluster = safe_call(client(request).clusters.get, jex.cluster_id) - job = safe_call(getattr(sahara, jt_manager).get, jex.job_id) + try: + jt_id = jex.job_template_id # typical APIv2 + except AttributeError: + jt_id = jex.job_id # APIv1.1, older APIv2 + job = safe_call(getattr(sahara, jt_manager).get, jt_id) return _resolve_job_execution_names(jex, cluster, job) diff --git a/sahara_dashboard/content/data_processing/jobs/job_templates/workflows/launch.py b/sahara_dashboard/content/data_processing/jobs/job_templates/workflows/launch.py index 89c32fd6..9bde870e 100644 --- a/sahara_dashboard/content/data_processing/jobs/job_templates/workflows/launch.py +++ b/sahara_dashboard/content/data_processing/jobs/job_templates/workflows/launch.py @@ -239,7 +239,11 @@ class JobConfigAction(workflows.Action): job_ex_id = req.get("job_execution_id") if job_ex_id is not None: job_ex = saharaclient.job_execution_get(request, job_ex_id) - job = saharaclient.job_get(request, job_ex.job_id) + try: + jt_id = job_ex.job_template_id # typical APIv2 + except AttributeError: + jt_id = job_ex.job_id # APIv1.1, older APIv2 + job = saharaclient.job_get(request, jt_id) job_configs, interface_args = _merge_interface_with_configs( job.interface, job_ex.job_configs) edp_configs = {} @@ -466,7 +470,11 @@ class JobExecutionInterfaceConfigAction(workflows.Action): job_ex_id = req.get("job_execution_id") if job_ex_id is not None: job_ex = saharaclient.job_execution_get(request, job_ex_id) - job = saharaclient.job_get(request, job_ex.job_id) + try: + jt_id = job_ex.job_template_id # typical APIv2 + except AttributeError: + jt_id = job_ex.job_id # APIv1.1, older APIv2 + job = saharaclient.job_get(request, jt_id) job_configs, interface_args = _merge_interface_with_configs( job.interface, job_ex.job_configs) diff --git a/sahara_dashboard/content/data_processing/jobs/jobs/tables.py b/sahara_dashboard/content/data_processing/jobs/jobs/tables.py index 952b322c..bdfede5b 100644 --- a/sahara_dashboard/content/data_processing/jobs/jobs/tables.py +++ b/sahara_dashboard/content/data_processing/jobs/jobs/tables.py @@ -92,7 +92,11 @@ class ReLaunchJobExistingCluster(j_t.ChoosePlugin): def get_link_url(self, datum): base_url = reverse(self.url) - params = http.urlencode({'job_id': datum.job_id, + try: + job_template_id = datum.job_template_id # typical APIv2 + except AttributeError: + job_template_id = datum.job_id # APIv1.1, older APIv2 + params = http.urlencode({'job_id': job_template_id, 'job_execution_id': datum.id}) return "?".join([base_url, params]) @@ -164,9 +168,13 @@ class JobsTable(sahara_table.SaharaPaginateTabbedTable): @staticmethod def link(job_execution): if job_execution.job_name: + try: + job_template_id = job_execution.job_template_id # typical APIv2 + except AttributeError: + job_template_id = job_execution.job_id # APIv1.1, older APIv2 return reverse("horizon:project:data_processing." "jobs:jt-details", - args=(http.urlquote(job_execution.job_id),)) + args=(http.urlquote(job_template_id),)) else: # No link should be generated for a deleted Job. return None diff --git a/sahara_dashboard/content/data_processing/jobs/jobs/tabs.py b/sahara_dashboard/content/data_processing/jobs/jobs/tabs.py index 420aa76e..c2017553 100644 --- a/sahara_dashboard/content/data_processing/jobs/jobs/tabs.py +++ b/sahara_dashboard/content/data_processing/jobs/jobs/tabs.py @@ -95,14 +95,24 @@ class GeneralTab(tabs.Tab): job_execution_engine_job_id = getattr(job_execution, job_execution_engine_job_attr) + try: + job_template_id = job_execution.job_template_id # typical APIv2 + except AttributeError: + job_template_id = job_execution.job_id # APIv1.1, older APIv2 + return {"job_execution": job_execution, "object_names": object_names, + "job_execution_job_template_id": job_template_id, "job_execution_engine_job_id": job_execution_engine_job_id, "job_execution_engine_job_attr_pretty": job_execution_engine_job_attr_pretty} def get_object_names(self, job_ex, request): object_names = {} + try: + job_template_id = job_ex.job_template_id # typical APIv2 + except AttributeError: + job_template_id = job_ex.job_id # APIv1.1, older APIv2 obj_names_map = {'input_name': {'obj': 'data_source_get', 'obj_id': job_ex.input_id}, 'output_name': {'obj': 'data_source_get', @@ -110,7 +120,7 @@ class GeneralTab(tabs.Tab): 'cluster_name': {'obj': 'cluster_get', 'obj_id': job_ex.cluster_id}, 'job_name': {'obj': 'job_get', - 'obj_id': job_ex.job_id}} + 'obj_id': job_template_id}} for item in obj_names_map: object_names[item] = ( self.get_object_name(obj_names_map[item]['obj_id'], diff --git a/sahara_dashboard/content/data_processing/jobs/templates/jobs/_details.html b/sahara_dashboard/content/data_processing/jobs/templates/jobs/_details.html index 237ba7ec..7fd40581 100644 --- a/sahara_dashboard/content/data_processing/jobs/templates/jobs/_details.html +++ b/sahara_dashboard/content/data_processing/jobs/templates/jobs/_details.html @@ -9,7 +9,7 @@
{% trans "Project ID" %}
{{ job_execution.tenant_id }}
{% trans "Job Template" %}
-
{{ object_names.job_name }}
+
{{ object_names.job_name }}
{% trans "Public" %}
{{ job_execution.is_public|yesno }}
{% trans "Protected" %}