예제 #1
0
def rerun_oozie_job(request, job_id, app_path):
    ParametersFormSet = formset_factory(ParameterForm, extra=0)
    oozie_workflow = check_job_access_permission(request, job_id)
    check_job_edition_permission(oozie_workflow, request.user)

    if request.method == 'POST':
        rerun_form = RerunForm(request.POST, oozie_workflow=oozie_workflow)
        params_form = ParametersFormSet(request.POST)

        if sum([rerun_form.is_valid(), params_form.is_valid()]) == 2:
            args = {}

            if request.POST['rerun_form_choice'] == 'fail_nodes':
                args['fail_nodes'] = 'true'
            else:
                args['skip_nodes'] = ','.join(
                    rerun_form.cleaned_data['skip_nodes'])
            args['deployment_dir'] = app_path

            mapping = dict([(param['name'], param['value'])
                            for param in params_form.cleaned_data])

            _rerun_workflow(request, job_id, args, mapping)

            request.info(_('Workflow re-running.'))
            return redirect(
                reverse('oozie:list_oozie_workflow', kwargs={'job_id':
                                                             job_id}))
        else:
            request.error(
                _('Invalid submission form: %s %s' %
                  (rerun_form.errors, params_form.errors)))
    else:
        rerun_form = RerunForm(oozie_workflow=oozie_workflow)
        initial_params = ParameterForm.get_initial_params(
            oozie_workflow.conf_dict)
        params_form = ParametersFormSet(initial=initial_params)

    popup = render('dashboard/rerun_job_popup.mako',
                   request, {
                       'rerun_form':
                       rerun_form,
                       'params_form':
                       params_form,
                       'action':
                       reverse('oozie:rerun_oozie_job',
                               kwargs={
                                   'job_id': job_id,
                                   'app_path': app_path
                               }),
                   },
                   force_template=True).content

    return HttpResponse(json.dumps(popup), mimetype="application/json")
예제 #2
0
def rerun_oozie_job(request, job_id, app_path=None):
  ParametersFormSet = formset_factory(ParameterForm, extra=0)
  oozie_workflow = check_job_access_permission(request, job_id)
  check_job_edition_permission(oozie_workflow, request.user)
  if app_path is None:
    app_path = oozie_workflow.appPath
  else:
    app_path = urllib.unquote(app_path)
  return_json = request.GET.get('format') == 'json'

  if request.method == 'POST':
    rerun_form = RerunForm(request.POST, oozie_workflow=oozie_workflow)
    params_form = ParametersFormSet(request.POST)

    if sum([rerun_form.is_valid(), params_form.is_valid()]) == 2:
      args = {}

      if request.POST.get('rerun_form_choice') == 'fail_nodes':
        args['fail_nodes'] = 'true'
      else:
        args['skip_nodes'] = ','.join(rerun_form.cleaned_data['skip_nodes'])
      args['deployment_dir'] = app_path

      mapping = dict([(param['name'], param['value']) for param in params_form.cleaned_data])

      _rerun_workflow(request, job_id, args, mapping)

      if rerun_form.cleaned_data['return_json']:
        return JsonResponse({'status': 0, 'job_id': job_id}, safe=False)
      else:
        request.info(_('Workflow re-running.'))
        return redirect(reverse('oozie:list_oozie_workflow', kwargs={'job_id': job_id}))
    else:
      request.error(_('Invalid submission form: %s %s' % (rerun_form.errors, params_form.errors)))
  else:
    rerun_form = RerunForm(oozie_workflow=oozie_workflow, return_json=return_json)
    initial_params = ParameterForm.get_initial_params(oozie_workflow.conf_dict)
    params_form = ParametersFormSet(initial=initial_params)

    return render('dashboard/rerun_workflow_popup.mako', request, {
                   'rerun_form': rerun_form,
                   'params_form': params_form,
                   'action': reverse('oozie:rerun_oozie_job', kwargs={'job_id': job_id, 'app_path': urllib.quote(app_path.encode('utf-8'), safe=SAFE_CHARACTERS_URI_COMPONENTS) }),
                   'return_json': return_json,
                   'is_mini': request.GET.get('is_mini', False),
                 }, force_template=True)
예제 #3
0
파일: dashboard.py 프로젝트: cloudera/hue
def rerun_oozie_job(request, job_id, app_path=None):
  ParametersFormSet = formset_factory(ParameterForm, extra=0)
  oozie_workflow = check_job_access_permission(request, job_id)
  check_job_edition_permission(oozie_workflow, request.user)
  if app_path is None:
    app_path = oozie_workflow.appPath
  return_json = request.GET.get('format') == 'json'

  if request.method == 'POST':
    rerun_form = RerunForm(request.POST, oozie_workflow=oozie_workflow)
    params_form = ParametersFormSet(request.POST)

    if sum([rerun_form.is_valid(), params_form.is_valid()]) == 2:
      args = {}

      if request.POST.get('rerun_form_choice') == 'fail_nodes':
        args['fail_nodes'] = 'true'
      else:
        args['skip_nodes'] = ','.join(rerun_form.cleaned_data['skip_nodes'])
      args['deployment_dir'] = app_path

      mapping = dict([(param['name'], param['value']) for param in params_form.cleaned_data])

      _rerun_workflow(request, job_id, args, mapping)

      if rerun_form.cleaned_data['return_json']:
        return JsonResponse({'status': 0, 'job_id': job_id}, safe=False)
      else:
        request.info(_('Workflow re-running.'))
        return redirect(reverse('oozie:list_oozie_workflow', kwargs={'job_id': job_id}))
    else:
      request.error(_('Invalid submission form: %s %s' % (rerun_form.errors, params_form.errors)))
  else:
    rerun_form = RerunForm(oozie_workflow=oozie_workflow, return_json=return_json)
    initial_params = ParameterForm.get_initial_params(oozie_workflow.conf_dict)
    params_form = ParametersFormSet(initial=initial_params)

  popup = render('dashboard/rerun_workflow_popup.mako', request, {
                   'rerun_form': rerun_form,
                   'params_form': params_form,
                   'action': reverse('oozie:rerun_oozie_job', kwargs={'job_id': job_id, 'app_path': app_path}),
                   'return_json': return_json,
                   'is_mini': request.GET.get('is_mini', False),
                 }, force_template=True).content

  return JsonResponse(popup, safe=False)
예제 #4
0
파일: dashboard.py 프로젝트: shobull/hue
def rerun_oozie_job(request, job_id, app_path):
    ParametersFormSet = formset_factory(ParameterForm, extra=0)
    oozie_workflow = check_job_access_permission(request, job_id)
    check_job_edition_permission(oozie_workflow, request.user)

    if request.method == "POST":
        rerun_form = RerunForm(request.POST, oozie_workflow=oozie_workflow)
        params_form = ParametersFormSet(request.POST)

        if sum([rerun_form.is_valid(), params_form.is_valid()]) == 2:
            args = {}

            if request.POST["rerun_form_choice"] == "fail_nodes":
                args["fail_nodes"] = "true"
            else:
                args["skip_nodes"] = ",".join(rerun_form.cleaned_data["skip_nodes"])
            args["deployment_dir"] = app_path

            mapping = dict([(param["name"], param["value"]) for param in params_form.cleaned_data])

            _rerun_workflow(request, job_id, args, mapping)

            request.info(_("Workflow re-running."))
            return redirect(reverse("oozie:list_oozie_workflow", kwargs={"job_id": job_id}))
        else:
            request.error(_("Invalid submission form: %s %s" % (rerun_form.errors, params_form.errors)))
    else:
        rerun_form = RerunForm(oozie_workflow=oozie_workflow)
        initial_params = ParameterForm.get_initial_params(oozie_workflow.conf_dict)
        params_form = ParametersFormSet(initial=initial_params)

    popup = render(
        "dashboard/rerun_job_popup.mako",
        request,
        {
            "rerun_form": rerun_form,
            "params_form": params_form,
            "action": reverse("oozie:rerun_oozie_job", kwargs={"job_id": job_id, "app_path": app_path}),
        },
        force_template=True,
    ).content

    return JsonResponse(popup, safe=False)
예제 #5
0
파일: dashboard.py 프로젝트: blue68/hue
def rerun_oozie_job(request, job_id, app_path):
  ParametersFormSet = formset_factory(ParameterForm, extra=0)
  oozie_workflow = check_job_access_permission(request, job_id)
  check_job_edition_permission(oozie_workflow, request.user)

  if request.method == 'POST':
    rerun_form = RerunForm(request.POST, oozie_workflow=oozie_workflow)
    params_form = ParametersFormSet(request.POST)

    if sum([rerun_form.is_valid(), params_form.is_valid()]) == 2:
      args = {}

      if request.POST['rerun_form_choice'] == 'fail_nodes':
        args['fail_nodes'] = 'true'
      else:
        args['skip_nodes'] = ','.join(rerun_form.cleaned_data['skip_nodes'])
      args['deployment_dir'] = app_path

      mapping = dict([(param['name'], param['value']) for param in params_form.cleaned_data])

      _rerun_workflow(request, job_id, args, mapping)

      request.info(_('Workflow re-running!'))
      return redirect(reverse('oozie:list_oozie_workflow', kwargs={'job_id': job_id}))
    else:
      request.error(_('Invalid submission form: %s %s' % (rerun_form.errors, params_form.errors)))
  else:
    rerun_form = RerunForm(oozie_workflow=oozie_workflow)
    initial_params = ParameterForm.get_initial_params(oozie_workflow.conf_dict)
    params_form = ParametersFormSet(initial=initial_params)

  popup = render('dashboard/rerun_job_popup.mako', request, {
                   'rerun_form': rerun_form,
                   'params_form': params_form,
                   'action': reverse('oozie:rerun_oozie_job', kwargs={'job_id': job_id, 'app_path': app_path}),
                 }, force_template=True).content

  return HttpResponse(json.dumps(popup), mimetype="application/json")