コード例 #1
0
ファイル: views.py プロジェクト: 15580056814/hue
def single_job(request, job):
  def cmp_exec_time(task1, task2):
    return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

  if job.applicationType == 'SPARK':
    return single_spark_job(request, job)

  failed_tasks = job.filter_tasks(task_states=('failed',))
  failed_tasks.sort(cmp_exec_time)
  recent_tasks = job.filter_tasks(task_states=('running', 'succeeded',))
  recent_tasks.sort(cmp_exec_time, reverse=True)

  if request.REQUEST.get('format') == 'json':
    json_failed_tasks = [massage_task_for_json(task) for task in failed_tasks]
    json_recent_tasks = [massage_task_for_json(task) for task in recent_tasks]
    json_job = {
      'job': massage_job_for_json(job, request),
      'failedTasks': json_failed_tasks,
      'recentTasks': json_recent_tasks
    }
    return HttpResponse(encode_json_for_js(json_job), mimetype="application/json")

  return render('job.mako', request, {
    'request': request,
    'job': job,
    'failed_tasks': failed_tasks and failed_tasks[:5] or [],
    'recent_tasks': recent_tasks and recent_tasks[:5] or [],
  })
コード例 #2
0
def list_oozie_workflows(request):
    kwargs = {
        'cnt': OOZIE_JOBS_COUNT.get(),
    }
    if not has_dashboard_jobs_access(request.user):
        kwargs['user'] = request.user.username
    oozie_api = get_oozie(request.user)

    if request.GET.get('format') == 'json':
        just_sla = request.GET.get('justsla') == 'true'
        if request.GET.get('type') in ('running', 'progress'):
            kwargs['filters'] = [('status', status)
                                 for status in OozieWorkflow.RUNNING_STATUSES]
        elif request.GET.get('type') == 'completed':
            kwargs['filters'] = [('status', status)
                                 for status in OozieWorkflow.FINISHED_STATUSES]

        json_jobs = oozie_api.get_workflows(**kwargs).jobs
        if request.GET.get('type') == 'progress':
            json_jobs = [oozie_api.get_job(job.id) for job in json_jobs]

        return HttpResponse(encode_json_for_js(
            massaged_oozie_jobs_for_json(json_jobs, request.user, just_sla)),
                            mimetype="application/json")

    return render(
        'dashboard/list_oozie_workflows.mako', request, {
            'user': request.user,
            'jobs': [],
            'has_job_edition_permission': has_job_edition_permission,
        })
コード例 #3
0
def jobs(request):
    user = request.GET.get('user', request.user.username)
    state = request.GET.get('state')
    text = request.GET.get('text')
    retired = request.GET.get('retired')

    if request.GET.get('format') == 'json':
        try:
            jobs = get_api(request.user,
                           request.jt).get_jobs(user=request.user,
                                                username=user,
                                                state=state,
                                                text=text,
                                                retired=retired)
        except Exception, ex:
            ex_message = str(ex)
            if 'Connection refused' in ex_message or 'standby RM' in ex_message:
                raise PopupException(
                    _('Resource Manager cannot be contacted or might be down.')
                )
            elif 'Could not connect to' in ex_message:
                raise PopupException(
                    _('Job Tracker cannot be contacted or might be down.'))
            else:
                raise ex
        json_jobs = [massage_job_for_json(job, request) for job in jobs]
        return HttpResponse(encode_json_for_js(json_jobs),
                            mimetype="application/json")
コード例 #4
0
def list_oozie_workflows(request):
    kwargs = {
        'cnt': OOZIE_JOBS_COUNT.get(),
    }
    if not has_dashboard_jobs_access(request.user):
        kwargs['user'] = request.user.username

    workflows = get_oozie(request.user).get_workflows(**kwargs)

    if request.GET.get('format') == 'json':
        json_jobs = workflows.jobs
        just_sla = request.GET.get('justsla') == 'true'
        if request.GET.get('type') == 'running':
            json_jobs = split_oozie_jobs(request.user,
                                         workflows.jobs)['running_jobs']
        if request.GET.get('type') == 'completed':
            json_jobs = split_oozie_jobs(request.user,
                                         workflows.jobs)['completed_jobs']
        return HttpResponse(encode_json_for_js(
            massaged_oozie_jobs_for_json(json_jobs, request.user, just_sla)),
                            mimetype="application/json")

    return render(
        'dashboard/list_oozie_workflows.mako', request, {
            'user': request.user,
            'jobs': split_oozie_jobs(request.user, workflows.jobs),
            'has_job_edition_permission': has_job_edition_permission,
        })
コード例 #5
0
ファイル: views.py プロジェクト: 15580056814/hue
def kill_job(request, job):
  if request.method != "POST":
    raise Exception(_("kill_job may only be invoked with a POST (got a %(method)s).") % {'method': request.method})

  if job.user != request.user.username and not request.user.is_superuser:
    access_warn(request, _('Insufficient permission'))
    raise MessageException(_("Permission denied.  User %(username)s cannot delete user %(user)s's job.") % {'username': request.user.username, 'user': job.user})

  job.kill()

  cur_time = time.time()
  api = get_api(request.user, request.jt)

  while time.time() - cur_time < 15:
    job = api.get_job(jobid=job.jobId)

    if job.status not in ["RUNNING", "QUEUED"]:
      if request.REQUEST.get("next"):
        return HttpResponseRedirect(request.REQUEST.get("next"))
      elif request.REQUEST.get("format") == "json":
        return HttpResponse(encode_json_for_js({'status': 0}), mimetype="application/json")
      else:
        raise MessageException("Job Killed")
    time.sleep(1)

  raise Exception(_("Job did not appear as killed within 15 seconds."))
コード例 #6
0
ファイル: dashboard.py プロジェクト: renchaorevee/hue
def list_oozie_coordinator(request, job_id, bundle_job_id=None):
  oozie_coordinator = check_job_access_permission(request, job_id)

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

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

  if request.GET.get('format') == 'json':
    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),
      'log': oozie_coordinator.log,
      'actions': massaged_coordinator_actions_for_json(oozie_coordinator, oozie_bundle)
    }
    return HttpResponse(encode_json_for_js(return_obj), mimetype="application/json")

  return render('dashboard/list_oozie_coordinator.mako', request, {
    'oozie_coordinator': oozie_coordinator,
    'coordinator': coordinator,
    'oozie_bundle': oozie_bundle,
    'has_job_edition_permission': has_job_edition_permission,
  })
コード例 #7
0
def single_job(request, job):
    def cmp_exec_time(task1, task2):
        return cmp(task1.execStartTimeMs, task2.execStartTimeMs)

    failed_tasks = job.filter_tasks(task_states=('failed', ))
    failed_tasks.sort(cmp_exec_time)
    recent_tasks = job.filter_tasks(task_states=(
        'running',
        'succeeded',
    ))
    recent_tasks.sort(cmp_exec_time, reverse=True)

    if request.REQUEST.get('format') == 'json':
        json_failed_tasks = [
            massage_task_for_json(task) for task in failed_tasks
        ]
        json_recent_tasks = [
            massage_task_for_json(task) for task in recent_tasks
        ]
        json_job = {
            'job': massage_job_for_json(job, request),
            'failedTasks': json_failed_tasks,
            'recentTasks': json_recent_tasks
        }
        return HttpResponse(encode_json_for_js(json_job),
                            mimetype="application/json")

    return render(
        'job.mako', request, {
            'request': request,
            'job': job,
            'failed_tasks': failed_tasks and failed_tasks[:5] or [],
            'recent_tasks': recent_tasks and recent_tasks[:5] or [],
        })
コード例 #8
0
ファイル: dashboard.py プロジェクト: dsc/hue
def list_oozie_coordinator(request, job_id, bundle_job_id=None):
  oozie_coordinator = check_job_access_permission(request, job_id)

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

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

  if request.GET.get('format') == 'json':
    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),
      'log': oozie_coordinator.log,
      'actions': massaged_coordinator_actions_for_json(oozie_coordinator, oozie_bundle)
    }
    return HttpResponse(encode_json_for_js(return_obj), mimetype="application/json")

  return render('dashboard/list_oozie_coordinator.mako', request, {
    'oozie_coordinator': oozie_coordinator,
    'coordinator': coordinator,
    'oozie_bundle': oozie_bundle,
    'has_job_edition_permission': has_job_edition_permission,
  })
コード例 #9
0
def kill_job(request, job):
    if request.method != "POST":
        raise Exception(
            _("kill_job may only be invoked with a POST (got a %(method)s).") %
            dict(method=request.method))

    if job.user != request.user.username and not request.user.is_superuser:
        access_warn(request, _('Insufficient permission'))
        raise MessageException(
            _("Permission denied.  User %(username)s cannot delete user %(user)s's job."
              ) % dict(username=request.user.username, user=job.user))

    job.kill()
    cur_time = time.time()
    while time.time() - cur_time < 15:
        job = Job.from_id(jt=request.jt, jobid=job.jobId)

        if job.status not in ["RUNNING", "QUEUED"]:
            if request.REQUEST.get("next"):
                return HttpResponseRedirect(request.REQUEST.get("next"))
            elif request.REQUEST.get("format") == "json":
                return HttpResponse(encode_json_for_js({'status': 0}),
                                    mimetype="application/json")
            else:
                raise MessageException("Job Killed")
        time.sleep(1)
        job = Job.from_id(jt=request.jt, jobid=job.jobId)

    raise Exception(_("Job did not appear as killed within 15 seconds."))
コード例 #10
0
def single_spark_job(request, job):
    if request.REQUEST.get('format') == 'json':
        json_job = {'job': massage_job_for_json(job, request)}
        return HttpResponse(encode_json_for_js(json_job),
                            mimetype="application/json")
    else:
        return render('job.mako', request, {'request': request, 'job': job})
コード例 #11
0
def jobs(request):
    user = request.GET.get('user', request.user.username)
    state = request.GET.get('state')
    text = request.GET.get('text')
    retired = request.GET.get('retired')

    if request.GET.get('format') == 'json':
        jobs = get_api(request.user, request.jt).get_jobs(user=request.user,
                                                          username=user,
                                                          state=state,
                                                          text=text,
                                                          retired=retired)
        json_jobs = [massage_job_for_json(job, request) for job in jobs]
        return HttpResponse(encode_json_for_js(json_jobs),
                            mimetype="application/json")

    return render(
        'jobs.mako', request, {
            'request': request,
            'state_filter': state,
            'user_filter': user,
            'text_filter': text,
            'retired': retired,
            'filtered': not (state == 'all' and user == '' and text == '')
        })
コード例 #12
0
ファイル: dashboard.py プロジェクト: MarvinWang/hue
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
  })
コード例 #13
0
ファイル: dashboard.py プロジェクト: renchaorevee/hue
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
  })
コード例 #14
0
ファイル: dashboard.py プロジェクト: jxsdzht2010/hue
def list_oozie_coordinator(request, job_id):
  oozie_coordinator = check_job_access_permission(request, job_id)

  # Cross reference the submission history (if any)
  coordinator = None
  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,
  })
コード例 #15
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 = None
    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'):
        oozie_bundle = check_job_access_permission(
            request, request.GET.get('bundle_job_id'))

    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),
            'log': oozie_coordinator.log,
            '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)

    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
        })
コード例 #16
0
ファイル: dashboard.py プロジェクト: jxsdzht2010/hue
def get_oozie_job_log(request, job_id):
  oozie_job = check_job_access_permission(request, job_id)

  return_obj = {
    'id': oozie_job.id,
    'status':  oozie_job.status,
    'log': oozie_job.log,
  }

  return HttpResponse(encode_json_for_js(return_obj), mimetype="application/json")
コード例 #17
0
def get_oozie_job_log(request, job_id):
  oozie_job = check_job_access_permission(request, job_id)

  return_obj = {
    'id': oozie_job.id,
    'status':  oozie_job.status,
    'log': oozie_job.log,
  }

  return HttpResponse(encode_json_for_js(return_obj), mimetype="application/json")
コード例 #18
0
ファイル: views.py プロジェクト: 15580056814/hue
def single_spark_job(request, job):
  if request.REQUEST.get('format') == 'json':
    json_job = {
      'job': massage_job_for_json(job, request)
    }
    return HttpResponse(encode_json_for_js(json_job), mimetype="application/json")
  else:
    return render('job.mako', request, {
      'request': request,
      'job': job
    })
コード例 #19
0
ファイル: views.py プロジェクト: 9629831527/hue
def jobs(request):
  user = request.GET.get('user', request.user.username)
  state = request.GET.get('state')
  text = request.GET.get('text')
  retired = request.GET.get('retired')

  if request.GET.get('format') == 'json':
    try:
      jobs = get_api(request.user, request.jt).get_jobs(user=request.user, username=user, state=state, text=text, retired=retired)
    except Exception, ex:
      ex_message = str(ex)
      if 'Connection refused' in ex_message or 'standby RM' in ex_message:
        raise PopupException(_('Resource Manager cannot be contacted or might be down.'))
      elif 'Could not connect to' in ex_message:
        raise PopupException(_('Job Tracker cannot be contacted or might be down.'))
      else:
        raise ex
    json_jobs  = [massage_job_for_json(job, request) for job in jobs]
    return HttpResponse(encode_json_for_js(json_jobs), mimetype="application/json")
コード例 #20
0
ファイル: views.py プロジェクト: chiehwen/hue
def jobs(request):
  user = request.GET.get('user', request.user.username)
  state = request.GET.get('state')
  text = request.GET.get('text')
  retired = request.GET.get('retired')

  if request.GET.get('format') == 'json':
    jobs = get_api(request.user, request.jt).get_jobs(user=request.user, username=user, state=state, text=text, retired=retired)
    json_jobs  = [massage_job_for_json(job, request) for job in jobs]
    return HttpResponse(encode_json_for_js(json_jobs), mimetype="application/json")

  return render('jobs.mako', request, {
    'request': request,
    'state_filter': state,
    'user_filter': user,
    'text_filter': text,
    'retired': retired,
    'filtered': not (state == 'all' and user == '' and text == '')
  })
コード例 #21
0
ファイル: dashboard.py プロジェクト: dsc/hue
def list_oozie_workflows(request):
  kwargs = {'cnt': OOZIE_JOBS_COUNT.get(),}
  if not has_dashboard_jobs_access(request.user):
    kwargs['user'] = request.user.username

  workflows = get_oozie().get_workflows(**kwargs)

  if request.GET.get('format') == 'json':
    json_jobs = workflows.jobs
    if request.GET.get('type') == 'running':
      json_jobs = split_oozie_jobs(workflows.jobs)['running_jobs']
    if request.GET.get('type') == 'completed':
      json_jobs = split_oozie_jobs(workflows.jobs)['completed_jobs']
    return HttpResponse(encode_json_for_js(massaged_oozie_jobs_for_json(json_jobs, request.user)), mimetype="application/json")

  return render('dashboard/list_oozie_workflows.mako', request, {
    'user': request.user,
    'jobs': split_oozie_jobs(workflows.jobs),
    'has_job_edition_permission':  has_job_edition_permission,
  })
コード例 #22
0
ファイル: dashboard.py プロジェクト: jxsdzht2010/hue
def list_oozie_workflows(request):
  kwargs = {'cnt': OOZIE_JOBS_COUNT.get(),}
  if not has_dashboard_jobs_access(request.user):
    kwargs['user'] = request.user.username
  oozie_api = get_oozie(request.user)

  if request.GET.get('format') == 'json':
    just_sla = request.GET.get('justsla') == 'true'
    if request.GET.get('type') in ('running', 'progress'):
      kwargs['filters'] = [('status', status) for status in OozieWorkflow.RUNNING_STATUSES]
    elif request.GET.get('type') == 'completed':
      kwargs['filters'] = [('status', status) for status in OozieWorkflow.FINISHED_STATUSES]

    json_jobs = oozie_api.get_workflows(**kwargs).jobs
    if request.GET.get('type') == 'progress':
      json_jobs = [oozie_api.get_job(job.id) for job in json_jobs]

    return HttpResponse(encode_json_for_js(massaged_oozie_jobs_for_json(json_jobs, request.user, just_sla)), mimetype="application/json")

  return render('dashboard/list_oozie_workflows.mako', request, {
    'user': request.user,
    'jobs': [],
    'has_job_edition_permission':  has_job_edition_permission,
  })
コード例 #23
0
    return wraps(view_func)(decorate)


def job_not_assigned(request, jobid, path):
    if request.GET.get('format') == 'json':
        result = {'status': -1, 'message': ''}

        try:
            get_api(request.user, request.jt).get_job(jobid=jobid)
            result['status'] = 0
        except ApplicationNotRunning, e:
            result['status'] = 1
        except Exception, e:
            result['message'] = _('Error polling job %s: %s') % (jobid, e)

        return HttpResponse(encode_json_for_js(result),
                            mimetype="application/json")
    else:
        return render('job_not_assigned.mako', request, {
            'jobid': jobid,
            'path': path
        })


def jobs(request):
    user = request.GET.get('user', request.user.username)
    state = request.GET.get('state')
    text = request.GET.get('text')
    retired = request.GET.get('retired')

    if request.GET.get('format') == 'json':
コード例 #24
0
  return wraps(view_func)(decorate)


def job_not_assigned(request, jobid, path):
  if request.GET.get('format') == 'json':
    result = {'status': -1, 'message': ''}

    try:
      get_api(request.user, request.jt).get_job(jobid=jobid)
      result['status'] = 0
    except ApplicationNotRunning, e:
      result['status'] = 1
    except Exception, e:
      result['message'] = _('Error polling job %s: e') % (jobid, e)

    return HttpResponse(encode_json_for_js(result), mimetype="application/json")
  else:
    return render('job_not_assigned.mako', request, {'jobid': jobid, 'path': path})


def jobs(request):
  user = request.GET.get('user', request.user.username)
  state = request.GET.get('state')
  text = request.GET.get('text')
  retired = request.GET.get('retired')

  if request.GET.get('format') == 'json':
    jobs = get_api(request.user, request.jt).get_jobs(user=request.user, username=user, state=state, text=text, retired=retired)
    json_jobs  = [massage_job_for_json(job, request) for job in jobs]
    return HttpResponse(encode_json_for_js(json_jobs), mimetype="application/json")
コード例 #25
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
        })
コード例 #26
0
ファイル: views.py プロジェクト: 15580056814/hue
  return wraps(view_func)(decorate)


def job_not_assigned(request, jobid, path):
  if request.GET.get('format') == 'json':
    result = {'status': -1, 'message': ''}

    try:
      get_api(request.user, request.jt).get_job(jobid=jobid)
      result['status'] = 0
    except ApplicationNotRunning, e:
      result['status'] = 1
    except Exception, e:
      result['message'] = _('Error polling job %s: %s') % (jobid, e)

    return HttpResponse(encode_json_for_js(result), mimetype="application/json")
  else:
    return render('job_not_assigned.mako', request, {'jobid': jobid, 'path': path})


def jobs(request):
  user = request.GET.get('user', request.user.username)
  state = request.GET.get('state')
  text = request.GET.get('text')
  retired = request.GET.get('retired')

  if request.GET.get('format') == 'json':
    jobs = get_api(request.user, request.jt).get_jobs(user=request.user, username=user, state=state, text=text, retired=retired)
    json_jobs  = [massage_job_for_json(job, request) for job in jobs]
    return HttpResponse(encode_json_for_js(json_jobs), mimetype="application/json")