Пример #1
0
def list_oozie_workflow(request, job_id, coordinator_job_id=None):
    oozie_workflow = check_job_access_permission(request, job_id)

    oozie_coordinator = None
    if coordinator_job_id is not None:
        oozie_coordinator = check_job_access_permission(
            request, coordinator_job_id)

    history = History.cross_reference_submission_history(
        request.user, job_id, coordinator_job_id)

    hue_coord = history and history.get_coordinator(
    ) or History.get_coordinator_from_config(oozie_workflow.conf_dict)
    hue_workflow = (hue_coord and hue_coord.workflow) or (
        history
        and history.get_workflow()) or History.get_workflow_from_config(
            oozie_workflow.conf_dict)

    if hue_coord:
        Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
    if hue_workflow:
        Job.objects.is_accessible_or_exception(request, hue_workflow.id)

    parameters = oozie_workflow.conf_dict.copy()

    return render(
        'dashboard/list_oozie_workflow.mako', request, {
            'history': history,
            'oozie_workflow': oozie_workflow,
            'oozie_coordinator': oozie_coordinator,
            'hue_workflow': hue_workflow,
            'hue_coord': hue_coord,
            'parameters': parameters,
            'has_job_edition_permission': has_job_edition_permission,
        })
Пример #2
0
def list_oozie_workflow(request, job_id, coordinator_job_id=None):
  oozie_workflow = check_access_and_get_oozie_job(request, job_id)

  oozie_coordinator = None
  if coordinator_job_id is not None:
    oozie_coordinator = check_access_and_get_oozie_job(request, coordinator_job_id)

  history = History.cross_reference_submission_history(request.user, job_id, coordinator_job_id)

  hue_coord = history and history.get_coordinator() or History.get_coordinator_from_config(oozie_workflow.conf_dict)
  hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or History.get_workflow_from_config(oozie_workflow.conf_dict)

  if hue_coord: Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
  if hue_workflow: Job.objects.is_accessible_or_exception(request, hue_workflow.id)

  # Add parameters from coordinator to workflow if possible
  parameters = {}
  if history and history.properties_dict:
    parameters = history.properties_dict
  elif hue_workflow is not None:
    for param in hue_workflow.find_parameters():
      if param in oozie_workflow.conf_dict:
        parameters[param] = oozie_workflow.conf_dict[param]


  return render('dashboard/list_oozie_workflow.mako', request, {
    'history': history,
    'oozie_workflow': oozie_workflow,
    'oozie_coordinator': oozie_coordinator,
    'hue_workflow': hue_workflow,
    'hue_coord': hue_coord,
    'parameters': parameters,
  })
Пример #3
0
def list_oozie_workflow(request, job_id, coordinator_job_id=None):
  oozie_workflow = check_job_access_permission(request, job_id)

  oozie_coordinator = None
  if coordinator_job_id is not None:
    oozie_coordinator = check_job_access_permission(request, coordinator_job_id)

  history = History.cross_reference_submission_history(request.user, job_id, coordinator_job_id)

  hue_coord = history and history.get_coordinator() or History.get_coordinator_from_config(oozie_workflow.conf_dict)
  hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or History.get_workflow_from_config(oozie_workflow.conf_dict)

  if hue_coord: Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
  if hue_workflow: Job.objects.is_accessible_or_exception(request, hue_workflow.id)

  parameters = oozie_workflow.conf_dict.copy()

  return render('dashboard/list_oozie_workflow.mako', request, {
    'history': history,
    'oozie_workflow': oozie_workflow,
    'oozie_coordinator': oozie_coordinator,
    'hue_workflow': hue_workflow,
    'hue_coord': hue_coord,
    'parameters': parameters,
    'has_job_edition_permission': has_job_edition_permission,
  })
Пример #4
0
def list_oozie_workflow(request, job_id, coordinator_job_id=None, bundle_job_id=None):
  oozie_workflow = check_job_access_permission(request, job_id)

  oozie_coordinator = None
  if coordinator_job_id is not None:
    oozie_coordinator = check_job_access_permission(request, coordinator_job_id)

  oozie_bundle = None
  if bundle_job_id is not None:
    oozie_bundle = check_job_access_permission(request, bundle_job_id)

  if oozie_coordinator is not None:
    setattr(oozie_workflow, 'oozie_coordinator', oozie_coordinator)
  if oozie_bundle is not None:
    setattr(oozie_workflow, 'oozie_bundle', oozie_bundle)

  history = History.cross_reference_submission_history(request.user, job_id, coordinator_job_id)

  hue_coord = history and history.get_coordinator() or History.get_coordinator_from_config(oozie_workflow.conf_dict)
  hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or History.get_workflow_from_config(oozie_workflow.conf_dict)

  if hue_coord: Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
  if hue_workflow: Job.objects.is_accessible_or_exception(request, hue_workflow.id)

  parameters = oozie_workflow.conf_dict.copy()
  for action in oozie_workflow.actions:
    action.oozie_coordinator = oozie_coordinator
    action.oozie_bundle = oozie_bundle

  if hue_workflow:
    workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
    full_node_list = hue_workflow.node_list
  else:
    workflow_graph, full_node_list = Workflow.gen_status_graph_from_xml(request.user, oozie_workflow)

  if request.GET.get('format') == 'json':
    return_obj = {
      'id': oozie_workflow.id,
      'status':  oozie_workflow.status,
      'progress': oozie_workflow.get_progress(full_node_list),
      'graph': workflow_graph,
      'log': oozie_workflow.log,
      'actions': massaged_workflow_actions_for_json(oozie_workflow.get_working_actions(), oozie_coordinator, oozie_bundle)
    }
    return HttpResponse(encode_json_for_js(return_obj), mimetype="application/json")

  return render('dashboard/list_oozie_workflow.mako', request, {
    'history': history,
    'oozie_workflow': oozie_workflow,
    'oozie_coordinator': oozie_coordinator,
    'oozie_bundle': oozie_bundle,
    'hue_workflow': hue_workflow,
    'hue_coord': hue_coord,
    'parameters': parameters,
    'has_job_edition_permission': has_job_edition_permission,
    'workflow_graph': workflow_graph
  })
Пример #5
0
def list_oozie_workflow(request, job_id, coordinator_job_id=None, bundle_job_id=None):
  oozie_workflow = check_job_access_permission(request, job_id)

  oozie_coordinator = None
  if coordinator_job_id is not None:
    oozie_coordinator = check_job_access_permission(request, coordinator_job_id)

  oozie_bundle = None
  if bundle_job_id is not None:
    oozie_bundle = check_job_access_permission(request, bundle_job_id)

  if oozie_coordinator is not None:
    setattr(oozie_workflow, 'oozie_coordinator', oozie_coordinator)
  if oozie_bundle is not None:
    setattr(oozie_workflow, 'oozie_bundle', oozie_bundle)

  history = History.cross_reference_submission_history(request.user, job_id, coordinator_job_id)

  hue_coord = history and history.get_coordinator() or History.get_coordinator_from_config(oozie_workflow.conf_dict)
  hue_workflow = (hue_coord and hue_coord.workflow) or (history and history.get_workflow()) or History.get_workflow_from_config(oozie_workflow.conf_dict)

  if hue_coord: Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
  if hue_workflow: Job.objects.is_accessible_or_exception(request, hue_workflow.id)

  parameters = oozie_workflow.conf_dict.copy()
  for action in oozie_workflow.actions:
    action.oozie_coordinator = oozie_coordinator
    action.oozie_bundle = oozie_bundle

  if hue_workflow:
    workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
    full_node_list = hue_workflow.node_list
  else:
    workflow_graph, full_node_list = Workflow.gen_status_graph_from_xml(request.user, oozie_workflow)

  if request.GET.get('format') == 'json':
    return_obj = {
      'id': oozie_workflow.id,
      'status':  oozie_workflow.status,
      'progress': oozie_workflow.get_progress(full_node_list),
      'graph': workflow_graph,
      'log': oozie_workflow.log,
      'actions': massaged_workflow_actions_for_json(oozie_workflow.get_working_actions(), oozie_coordinator, oozie_bundle)
    }
    return HttpResponse(encode_json_for_js(return_obj), mimetype="application/json")

  return render('dashboard/list_oozie_workflow.mako', request, {
    'history': history,
    'oozie_workflow': oozie_workflow,
    'oozie_coordinator': oozie_coordinator,
    'oozie_bundle': oozie_bundle,
    'hue_workflow': hue_workflow,
    'hue_coord': hue_coord,
    'parameters': parameters,
    'has_job_edition_permission': has_job_edition_permission,
    'workflow_graph': workflow_graph
  })
Пример #6
0
def list_oozie_workflow(request, job_id, coordinator_job_id=None):
    oozie_workflow = check_job_access_permission(request, job_id)

    oozie_coordinator = None
    if coordinator_job_id is not None:
        oozie_coordinator = check_job_access_permission(
            request, coordinator_job_id)

    history = History.cross_reference_submission_history(
        request.user, job_id, coordinator_job_id)

    hue_coord = history and history.get_coordinator(
    ) or History.get_coordinator_from_config(oozie_workflow.conf_dict)
    hue_workflow = (hue_coord and hue_coord.workflow) or (
        history
        and history.get_workflow()) or History.get_workflow_from_config(
            oozie_workflow.conf_dict)

    if hue_coord:
        Job.objects.is_accessible_or_exception(request, hue_coord.workflow.id)
    if hue_workflow:
        Job.objects.is_accessible_or_exception(request, hue_workflow.id)

    # Add parameters from coordinator to workflow if possible
    parameters = {}
    if history and history.properties_dict:
        parameters = history.properties_dict
    elif hue_workflow is not None:
        for param in hue_workflow.find_parameters():
            if param in oozie_workflow.conf_dict:
                parameters[param] = oozie_workflow.conf_dict[param]

    return render(
        'dashboard/list_oozie_workflow.mako', request, {
            'history': history,
            'oozie_workflow': oozie_workflow,
            'oozie_coordinator': oozie_coordinator,
            'hue_workflow': hue_workflow,
            'hue_coord': hue_coord,
            'parameters': parameters,
            'has_job_edition_permission': has_job_edition_permission,
        })
Пример #7
0
def list_oozie_coordinator(request, job_id):
    oozie_coordinator = check_job_access_permission(request, job_id)

    # Cross reference the submission history (if any)
    coordinator = History.get_coordinator_from_config(
        oozie_coordinator.conf_dict)
    #  try:
    #    coordinator = History.objects.get(oozie_job_id=job_id).job.get_full_node()
    #  except History.DoesNotExist:
    #    pass

    oozie_bundle = None
    if request.GET.get('bundle_job_id'):
        try:
            oozie_bundle = check_job_access_permission(
                request, request.GET.get('bundle_job_id'))
        except:
            pass

    show_all_actions = request.GET.get('show_all_actions') == 'true'

    if request.GET.get('format') == 'json':
        actions = massaged_coordinator_actions_for_json(
            oozie_coordinator, oozie_bundle)
        if not show_all_actions:
            actions = actions[:MAX_COORD_ACTIONS]

        return_obj = {
            'id': oozie_coordinator.id,
            'status': oozie_coordinator.status,
            'progress': oozie_coordinator.get_progress(),
            'nextTime': format_time(oozie_coordinator.nextMaterializedTime),
            'endTime': format_time(oozie_coordinator.endTime),
            'actions': actions,
            'show_all_actions': show_all_actions
        }
        return HttpResponse(encode_json_for_js(return_obj),
                            mimetype="application/json")

    oozie_slas = []
    if oozie_coordinator.has_sla:
        api = get_oozie(request.user, api_version="v2")
        params = {
            'id': oozie_coordinator.id,
            'parent_id': oozie_coordinator.id
        }
        oozie_slas = api.get_oozie_slas(**params)

    enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()

    return render(
        'dashboard/list_oozie_coordinator.mako', request, {
            'oozie_coordinator': oozie_coordinator,
            'oozie_slas': oozie_slas,
            'coordinator': coordinator,
            'oozie_bundle': oozie_bundle,
            'has_job_edition_permission': has_job_edition_permission,
            'show_all_actions': show_all_actions,
            'MAX_COORD_ACTIONS': MAX_COORD_ACTIONS,
            'enable_cron_scheduling': enable_cron_scheduling,
        })
Пример #8
0
def list_oozie_workflow(request, job_id):
    oozie_workflow = check_job_access_permission(request, job_id)

    oozie_coordinator = None
    if request.GET.get('coordinator_job_id'):
        oozie_coordinator = check_job_access_permission(
            request, request.GET.get('coordinator_job_id'))

    oozie_bundle = None
    if request.GET.get('bundle_job_id'):
        oozie_bundle = check_job_access_permission(
            request, request.GET.get('bundle_job_id'))

    if oozie_coordinator is not None:
        setattr(oozie_workflow, 'oozie_coordinator', oozie_coordinator)
    if oozie_bundle is not None:
        setattr(oozie_workflow, 'oozie_bundle', oozie_bundle)

    # To update with the new History document model
    hue_coord = History.get_coordinator_from_config(oozie_workflow.conf_dict)
    hue_workflow = (hue_coord and
                    hue_coord.workflow) or History.get_workflow_from_config(
                        oozie_workflow.conf_dict)

    if hue_coord and hue_coord.workflow:
        hue_coord.workflow.document.doc.get().can_read_or_exception(
            request.user)
    if hue_workflow:
        hue_workflow.document.doc.get().can_read_or_exception(request.user)

    parameters = oozie_workflow.conf_dict.copy()
    for action in oozie_workflow.actions:
        action.oozie_coordinator = oozie_coordinator
        action.oozie_bundle = oozie_bundle

    if hue_workflow:
        workflow_graph = hue_workflow.gen_status_graph(oozie_workflow)
        full_node_list = hue_workflow.nodes
    # If no saved workflow, we could try to parse the XML like: workflow_graph, full_node_list = Workflow.gen_status_graph_from_xml(request.user, oozie_workflow)

    if request.GET.get('format') == 'json':
        return_obj = {
            'id':
            oozie_workflow.id,
            'status':
            oozie_workflow.status,
            'progress':
            oozie_workflow.get_progress(full_node_list),
            'graph':
            workflow_graph,
            'actions':
            massaged_workflow_actions_for_json(
                oozie_workflow.get_working_actions(), oozie_coordinator,
                oozie_bundle)
        }
        return HttpResponse(encode_json_for_js(return_obj),
                            mimetype="application/json")

    oozie_slas = []
    if oozie_workflow.has_sla:
        api = get_oozie(request.user, api_version="v2")
        params = {'id': oozie_workflow.id, 'parent_id': oozie_workflow.id}
        oozie_slas = api.get_oozie_slas(**params)

    return render(
        'dashboard/list_oozie_workflow.mako', request, {
            'oozie_workflow': oozie_workflow,
            'oozie_coordinator': oozie_coordinator,
            'oozie_bundle': oozie_bundle,
            'oozie_slas': oozie_slas,
            'hue_workflow': hue_workflow,
            'hue_coord': hue_coord,
            'parameters': parameters,
            'has_job_edition_permission': has_job_edition_permission,
            'workflow_graph': workflow_graph
        })