예제 #1
0
파일: dashboard.py 프로젝트: shobull/hue
def rerun_oozie_bundle(request, job_id, app_path):
    oozie_bundle = check_job_access_permission(request, job_id)
    check_job_edition_permission(oozie_bundle, request.user)
    ParametersFormSet = formset_factory(ParameterForm, extra=0)

    if request.method == "POST":
        params_form = ParametersFormSet(request.POST)
        rerun_form = RerunBundleForm(request.POST, oozie_bundle=oozie_bundle)

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

            params = {
                "coord-scope": ",".join(rerun_form.cleaned_data["coordinators"]),
                "refresh": rerun_form.cleaned_data["refresh"],
                "nocleanup": rerun_form.cleaned_data["nocleanup"],
            }

            if rerun_form.cleaned_data["start"] and rerun_form.cleaned_data["end"]:
                date = {
                    "date-scope": "%(start)s::%(end)s"
                    % {
                        "start": utc_datetime_format(rerun_form.cleaned_data["start"]),
                        "end": utc_datetime_format(rerun_form.cleaned_data["end"]),
                    }
                }
                params.update(date)

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

            _rerun_bundle(request, job_id, args, params, properties)

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

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

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

  if request.method == 'POST':
    params_form = ParametersFormSet(request.POST)
    rerun_form = RerunBundleForm(request.POST, oozie_bundle=oozie_bundle)

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

      params = {
        'coord-scope': ','.join(rerun_form.cleaned_data['coordinators']),
        'refresh': rerun_form.cleaned_data['refresh'],
        'nocleanup': rerun_form.cleaned_data['nocleanup'],
      }

      if rerun_form.cleaned_data['start'] and rerun_form.cleaned_data['end']:
        date = {
            'date-scope':
                '%(start)s::%(end)s' % {
                    'start': utc_datetime_format(rerun_form.cleaned_data['start']),
                    'end': utc_datetime_format(rerun_form.cleaned_data['end'])
                }
        }
        params.update(date)

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

      _rerun_bundle(request, job_id, args, params, properties)

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

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

  return JsonResponse(popup, safe=False)
예제 #3
0
def rerun_oozie_bundle(request, job_id, app_path):
  oozie_bundle = check_job_access_permission(request, job_id)
  check_job_edition_permission(oozie_bundle, request.user)
  ParametersFormSet = formset_factory(ParameterForm, extra=0)

  if request.method == 'POST':
    params_form = ParametersFormSet(request.POST)
    rerun_form = RerunBundleForm(request.POST, oozie_bundle=oozie_bundle)

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

      params = {
        'coord-scope': ','.join(rerun_form.cleaned_data['coordinators']),
        'refresh': rerun_form.cleaned_data['refresh'],
        'nocleanup': rerun_form.cleaned_data['nocleanup'],
      }

      if rerun_form.cleaned_data['start'] and rerun_form.cleaned_data['end']:
        date = {
            'date-scope':
                '%(start)s::%(end)s' % {
                    'start': utc_datetime_format(rerun_form.cleaned_data['start']),
                    'end': utc_datetime_format(rerun_form.cleaned_data['end'])
                }
        }
        params.update(date)

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

      _rerun_bundle(request, job_id, args, params, properties)

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

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

  return JsonResponse(popup, safe=False)