Exemple #1
0
def workflow_jobsub_actions(request, workflow):
  if request.method not in ['GET', 'POST']:
    raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET or POST request.'), error_code=405)

  available_actions = OozieDesign.objects.all()
  if request.method == 'POST':
    form = ImportJobsubDesignForm(data=request.POST, choices=[(action.id, action.name) for action in available_actions])
    if form.is_valid():
      try:
        design = OozieDesign.objects.get(id=form.cleaned_data['jobsub_id'])
        action = convert_jobsub_design(design)
        action.workflow = workflow

        response = {
          'status': 0,
          'data': {
            'node': model_to_dict(action)
          }
        }
        response['data']['node']['child_links'] = []
        return HttpResponse(json.dumps(response), mimetype="application/json")
      except OozieDesign.DoesNotExist, e:
        raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Job Designer design does not exist.'), data={'exception': str(e)}, error_code=400)
      except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist), e:
        raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Could not convert Job Designer design.'), data={'exception': str(e)}, error_code=400)
      except Exception, e:
        raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error importing node from Job Designer'), data={'exception': str(e)}, error_code=400)
Exemple #2
0
def import_action(request, workflow, parent_action_id):
  available_actions = OozieDesign.objects.all()

  if request.method == 'POST':
    form = ImportJobsubDesignForm(data=request.POST, choices=[(action.id, action.name) for action in available_actions])
    if form.is_valid():
      try:
        design = OozieDesign.objects.get(id=form.cleaned_data['action_id'])
        action = convert_jobsub_design(design)
        action.workflow = workflow
        action.save()

        workflow.add_action(action, parent_action_id)
      except OozieDesign.DoesNotExist:
        request.error(_('Jobsub design doesn\'t exist.'))
      except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist):
        request.error(_('Could not convert jobsub design'))
      except:
        request.error(_('Could not convert jobsub design or add action to workflow'))

    return redirect(reverse('oozie:edit_workflow', kwargs={'workflow': action.workflow.id}))

  return render('editor/import_workflow_action.mako', request, {
    'workflow': workflow,
    'available_actions': available_actions,
    'form_url': reverse('oozie:import_action', kwargs={'workflow': workflow.id, 'parent_action_id': parent_action_id}),
  })
Exemple #3
0
def workflow_jobsub_actions(request, workflow):
  if request.method not in ['GET', 'POST']:
    raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be GET or POST request.'), error_code=405)

  available_actions = OozieDesign.objects.all()
  if request.method == 'POST':
    form = ImportJobsubDesignForm(data=request.POST, choices=[(action.id, action.name) for action in available_actions])
    if form.is_valid():
      try:
        design = OozieDesign.objects.get(id=form.cleaned_data['jobsub_id'])
        action = convert_jobsub_design(design)
        action.workflow = workflow

        response = {
          'status': 0,
          'data': {
            'node': model_to_dict(action)
          }
        }
        response['data']['node']['child_links'] = []
        return HttpResponse(json.dumps(response), mimetype="application/json")
      except OozieDesign.DoesNotExist, e:
        raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Job Designer design does not exist.'), data={'exception': str(e)}, error_code=400)
      except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist), e:
        raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Could not convert Job Designer design.'), data={'exception': str(e)}, error_code=400)
      except Exception, e:
        raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error importing node from Job Designer'), data={'exception': str(e)}, error_code=400)
    def forwards(self, orm):
        """ Find every design and move them into Oozie. """
        for design in orm.OozieDesign.objects.all():
            action = convert_jobsub_design(design)

            if not action:
                raise RuntimeError(_("Cannot convert %s design into an Oozie action.") % design.name)

            # User is guaranteed to exist since this executes for upgrades only.
            workflow = Workflow.objects.new_workflow(User.objects.get(id=design.owner.pk))
            workflow.name = action.name
            workflow.description = design.description
            # Inform oozie to not manage this workflow.
            workflow.managed = False
            workflow.save()

            workflow.start.workflow = workflow
            workflow.start.save()
            workflow.start = Start.objects.get(id=workflow.start.id)

            workflow.end.workflow = workflow
            workflow.end.save()
            workflow.end = End.objects.get(id=workflow.end.id)

            Kill.objects.create(name='kill', workflow=workflow, node_type=Kill.node_type)

            action.workflow = workflow
            action.save()

            workflow.start.add_node(action)
            action.add_node(workflow.end)

            workflow.save()
Exemple #5
0
def import_action(request, workflow, parent_action_id):
    available_actions = OozieDesign.objects.all()

    if request.method == "POST":
        form = ImportJobsubDesignForm(
            data=request.POST, choices=[(action.id, action.name) for action in available_actions]
        )
        if form.is_valid():
            try:
                design = OozieDesign.objects.get(id=form.cleaned_data["action_id"])
                action = convert_jobsub_design(design)
                action.workflow = workflow
                action.save()

                workflow.add_action(action, parent_action_id)
            except OozieDesign.DoesNotExist:
                request.error(_("Jobsub design doesn't exist."))
            except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist):
                request.error(_("Could not convert jobsub design"))
            except:
                request.error(_("Could not convert jobsub design or add action to workflow"))

        return redirect(reverse("oozie:edit_workflow", kwargs={"workflow": action.workflow.id}))

    return render(
        "editor/import_workflow_action.mako",
        request,
        {
            "workflow": workflow,
            "available_actions": available_actions,
            "form_url": reverse(
                "oozie:import_action", kwargs={"workflow": workflow.id, "parent_action_id": parent_action_id}
            ),
        },
    )
Exemple #6
0
    def forwards(self, orm):
        """ Find every design and move them into Oozie. """
        for design in orm.JobDesign.objects.all():
            action = convert_jobsub_design(design)

            if not action:
                raise RuntimeException(_("Cannot convert %s design into an Oozie action.") % design.name)

            workflow = Workflow.objects.new_workflow(request.user)
            workflow.name = action.name
            workflow.owner = design.owner
            workflow.description = design.description
            # Inform oozie to not manage this workflow.
            workflow.managed = False
            action.workflow = workflow

            workflow.save()
            action.save()
Exemple #7
0
def import_action(request, workflow, parent_action_id):
    available_actions = OozieDesign.objects.all()

    if request.method == 'POST':
        form = ImportJobsubDesignForm(data=request.POST,
                                      choices=[(action.id, action.name)
                                               for action in available_actions
                                               ])
        if form.is_valid():
            try:
                design = OozieDesign.objects.get(
                    id=form.cleaned_data['action_id'])
                action = convert_jobsub_design(design)
                action.workflow = workflow
                action.save()

                workflow.add_action(action, parent_action_id)
            except OozieDesign.DoesNotExist:
                request.error(_('Jobsub design doesn\'t exist.'))
            except (Mapreduce.DoesNotExist, Streaming.DoesNotExist,
                    Java.DoesNotExist):
                request.error(_('Could not convert jobsub design'))
            except:
                request.error(
                    _('Could not convert jobsub design or add action to workflow'
                      ))

        return redirect(
            reverse('oozie:edit_workflow',
                    kwargs={'workflow': action.workflow.id}))

    return render(
        'editor/import_workflow_action.mako', request, {
            'workflow':
            workflow,
            'available_actions':
            available_actions,
            'form_url':
            reverse('oozie:import_action',
                    kwargs={
                        'workflow': workflow.id,
                        'parent_action_id': parent_action_id
                    }),
        })
    def forwards(self, orm):
        """ Find every design and move them into Oozie. """
        for design in orm.JobDesign.objects.all():
            action = convert_jobsub_design(design)

            if not action:
                raise RuntimeError(
                    _("Cannot convert %s design into an Oozie action.") %
                    design.name)

            workflow = Workflow.objects.new_workflow(request.user)
            workflow.name = action.name
            workflow.owner = design.owner
            workflow.description = design.description
            # Inform oozie to not manage this workflow.
            workflow.managed = False
            action.workflow = workflow

            workflow.save()
            action.save()
Exemple #9
0
def workflow_jobsub_actions(request, workflow):
    if request.method not in ["GET", "POST"]:
        raise StructuredException(
            code="METHOD_NOT_ALLOWED_ERROR", message=_("Must be GET or POST request."), error_code=405
        )

    available_actions = OozieDesign.objects.all()
    if request.method == "POST":
        form = ImportJobsubDesignForm(
            data=request.POST, choices=[(action.id, action.name) for action in available_actions]
        )
        if form.is_valid():
            try:
                design = OozieDesign.objects.get(id=form.cleaned_data["jobsub_id"])
                action = convert_jobsub_design(design)
                action.workflow = workflow

                response = {"status": 0, "data": {"node": model_to_dict(action)}}
                response["data"]["node"]["child_links"] = []
                return HttpResponse(json.dumps(response), mimetype="application/json")
            except OozieDesign.DoesNotExist, e:
                raise StructuredException(
                    code="INVALID_REQUEST_ERROR",
                    message=_("Job Designer design does not exist."),
                    data={"exception": str(e)},
                    error_code=400,
                )
            except (Mapreduce.DoesNotExist, Streaming.DoesNotExist, Java.DoesNotExist), e:
                raise StructuredException(
                    code="INVALID_REQUEST_ERROR",
                    message=_("Could not convert Job Designer design."),
                    data={"exception": str(e)},
                    error_code=400,
                )
            except Exception, e:
                raise StructuredException(
                    code="INVALID_REQUEST_ERROR",
                    message=_("Error importing node from Job Designer"),
                    data={"exception": str(e)},
                    error_code=400,
                )
Exemple #10
0
    def forwards(self, orm):
        """ Find every design and move them into Oozie. """
        for design in orm.OozieDesign.objects.all():
            action = convert_jobsub_design(design)

            if not action:
                raise RuntimeError(
                    _("Cannot convert %s design into an Oozie action.") %
                    design.name)

            # User is guaranteed to exist since this executes for upgrades only.
            workflow = Workflow.objects.new_workflow(
                User.objects.get(id=design.owner.pk))
            workflow.name = action.name
            workflow.description = design.description
            # Inform oozie to not manage this workflow.
            workflow.managed = False
            workflow.save()

            workflow.start.workflow = workflow
            workflow.start.save()
            workflow.start = Start.objects.get(id=workflow.start.id)

            workflow.end.workflow = workflow
            workflow.end.save()
            workflow.end = End.objects.get(id=workflow.end.id)

            Kill.objects.create(name='kill',
                                workflow=workflow,
                                node_type=Kill.node_type)

            action.workflow = workflow
            action.save()

            workflow.start.add_node(action)
            action.add_node(workflow.end)

            workflow.save()