def submit_external_job(request, application_path): ParametersFormSet = formset_factory(ParameterForm, extra=0) if request.method == 'POST': params_form = ParametersFormSet(request.POST) if params_form.is_valid(): mapping = dict([(param['name'], param['value']) for param in params_form.cleaned_data]) application_name = os.path.basename(application_path) application_class = Bundle if application_name == 'bundle.xml' else Coordinator if application_name == 'coordinator.xml' else get_workflow() mapping[application_class.get_application_path_key()] = application_path try: submission = Submission(request.user, fs=request.fs, jt=request.jt, properties=mapping) job_id = submission.run(application_path) except RestException, ex: detail = ex._headers.get('oozie-error-message', ex) if 'Max retries exceeded with url' in str(detail): detail = '%s: %s' % (_('The Oozie server is not running'), detail) LOG.exception(smart_str(detail)) raise PopupException(_("Error submitting job %s") % (application_path,), detail=detail) request.info(_('Oozie job submitted')) view = 'list_oozie_bundle' if application_name == 'bundle.xml' else 'list_oozie_coordinator' if application_name == 'coordinator.xml' else 'list_oozie_workflow' return redirect(reverse('oozie:%s' % view, kwargs={'job_id': job_id})) else: request.error(_('Invalid submission form: %s' % params_form.errors))
def _submit_workflow(request, workflow, mapping): try: submission = Submission(request.user, workflow, request.fs, mapping) job_id = submission.run() History.objects.create_from_submission(submission) return job_id except RestException, ex: raise PopupException(_("Error submitting workflow %s") % (workflow,), detail=ex._headers.get('oozie-error-message', ex))
def _submit_workflow(user, fs, workflow, mapping): try: submission = Submission(user, workflow, fs, mapping) job_id = submission.run() History.objects.create_from_submission(submission) return job_id except RestException, ex: detail = ex._headers.get('oozie-error-message', ex) if 'urlopen error' in str(detail): detail = '%s: %s' % (_('The Oozie server is not running'), detail) raise PopupException(_("Error submitting workflow %s") % (workflow,), detail=detail)
def _submit_workflow(request, workflow, mapping): try: submission = Submission(request.user, workflow, request.fs, mapping) job_id = submission.run() History.objects.create_from_submission(submission) return job_id except RestException, ex: detail = ex._headers.get("oozie-error-message", ex) if "urlopen error" in str(detail): detail = "%s: %s" % (_("The Oozie server is not running"), detail) raise PopupException(_("Error submitting workflow %s") % (workflow,), detail=detail)
def _submit_coordinator(request, coordinator, mapping): try: wf_dir = Submission(request.user, coordinator.workflow, request.fs, mapping).deploy() properties = {'wf_application_path': request.fs.get_hdfs_path(wf_dir)} properties.update(mapping) submission = Submission(request.user, coordinator, request.fs, properties=properties) job_id = submission.run() History.objects.create_from_submission(submission) return job_id except RestException, ex: raise PopupException(_("Error submitting coordinator %s") % (coordinator,), detail=ex._headers.get('oozie-error-message', ex))
def _submit_bundle(request, bundle, properties): try: deployment_dirs = {} for bundled in bundle.coordinators.all(): wf_dir = Submission(request.user, bundled.coordinator.workflow, request.fs, properties).deploy() deployment_dirs['wf_%s_dir' % bundled.coordinator.workflow.id] = request.fs.get_hdfs_path(wf_dir) coord_dir = Submission(request.user, bundled.coordinator, request.fs, properties).deploy() deployment_dirs['coord_%s_dir' % bundled.coordinator.id] = coord_dir properties.update(deployment_dirs) submission = Submission(request.user, bundle, request.fs, properties=properties) job_id = submission.run() History.objects.create_from_submission(submission) return job_id except RestException, ex: raise PopupException(_("Error submitting bundle %s") % (bundle,), detail=ex._headers.get('oozie-error-message', ex))
def _submit_coordinator(request, coordinator, mapping): try: wf_dir = Submission(request.user, coordinator.workflow, request.fs, mapping).deploy() properties = {'wf_application_path': request.fs.get_hdfs_path(wf_dir)} properties.update(mapping) submission = Submission(request.user, coordinator, request.fs, properties=properties) job_id = submission.run() History.objects.create_from_submission(submission) return job_id except RestException, ex: raise PopupException(_("Error submitting coordinator %s") % (coordinator, ), detail=ex._headers.get('oozie-error-message', ex))
def submit_external_job(request, application_path): ParametersFormSet = formset_factory(ParameterForm, extra=0) if request.method == 'POST': params_form = ParametersFormSet(request.POST) if params_form.is_valid(): mapping = dict([(param['name'], param['value']) for param in params_form.cleaned_data]) application_name = os.path.basename(application_path) application_class = Bundle if application_name == 'bundle.xml' else Coordinator if application_name == 'coordinator.xml' else get_workflow( ) mapping[application_class.get_application_path_key( )] = application_path try: submission = Submission(request.user, fs=request.fs, jt=request.jt, properties=mapping) job_id = submission.run(application_path) except RestException, ex: detail = ex._headers.get('oozie-error-message', ex) if 'Max retries exceeded with url' in str(detail): detail = '%s: %s' % (_('The Oozie server is not running'), detail) LOG.exception(smart_str(detail)) raise PopupException(_("Error submitting job %s") % (application_path, ), detail=detail) request.info(_('Oozie job submitted')) view = 'list_oozie_bundle' if application_name == 'bundle.xml' else 'list_oozie_coordinator' if application_name == 'coordinator.xml' else 'list_oozie_workflow' return redirect( reverse('oozie:%s' % view, kwargs={'job_id': job_id})) else: request.error(_('Invalid submission form: %s' % params_form.errors))