コード例 #1
0
def create_or_update_outofbandworker(request, worker_pk=None):
    if request.method == "POST":
        if worker_pk is None:
            out_of_band_worker_node_form = OutOfBandWorkerNodeForm(request.POST, request.FILES)
        else:
            worker = OutOfBandWorkerNode()
            out_of_band_worker_node_form = OutOfBandWorkerNodeForm(request.POST, request.FILES, instance=worker)

        if out_of_band_worker_node_form.is_valid():
            if worker_pk is not None:
                json = simplejson.dumps("Worker successfully updated.")
            else:
                worker = out_of_band_worker_node_form.save(commit=False)
                worker.pk = 120
                worker.active = True
                context = { 'worker': {'worker': worker,
                            'workerForm': out_of_band_worker_node_form }}
                html = render_to_response("celerymanagementapp/configure_outofbandworker_instance.html",
                        context,
                        context_instance=RequestContext(request))
                success = { 'success': 'Worker successfully created.',
                            'html': urlquote(html.content),
                            'pk': worker.pk }
                json = simplejson.dumps(success)
        else:
            errors = []
            for field in out_of_band_worker_node_form:
                errors.append({ 'field' : field.html_name,
                                'error' : field.errors })
            failed = { 'failure' : errors,
                        'id': worker_pk }
            json = simplejson.dumps(failed)
        
        return HttpResponse("<textarea>" + json + "</textarea>")
コード例 #2
0
def configure(request):
    context = { "load_test_data": "true" }
    if settings.CELERYMANAGEMENTAPP_INFRASTRUCTURE_USE_MODE == "static":
        out_of_band_worker_node_form = OutOfBandWorkerNodeForm()
        OutOfBandWorkers = []

        for i in range(0,10):
            worker = OutOfBandWorkerNode(ip="4.5.6." + str(i), celeryd_username="******")
            worker.pk = i
            random.seed()
            choice = random.randint(0, 1000)
            worker.active = True if i < 5 else False
            workerForm = OutOfBandWorkerNodeForm(instance=worker)
            OutOfBandWorkers.append({ "worker" : worker, "workerForm" : workerForm })

        context["outofbandworkernode_form"] = out_of_band_worker_node_form
        context["outofbandworkernodes"] = OutOfBandWorkers

    elif settings.CELERYMANAGEMENTAPP_INFRASTRUCTURE_USE_MODE == "dynamic":
        provider = Provider(provider_user_id="test456YUser", celeryd_username="******", 
                            provider_name=Provider.PROVIDER_CHOICES[3][1], image_id="6sd6aF8dadSSa3")
        provider.pk = 0
        #provider = None
        providers = {}
        if provider:
            provider_form = ProviderForm(instance=provider)
            providers["provider_form"] = provider_form
            providers["provider"] = provider
        else:
            provider_form = ProviderForm()
            providers["provider_form"] = provider_form

        inbandnode = InBandWorkerNode(instance_id="adsfatte22d")
        inbandnode1 = InBandWorkerNode(instance_id="nfgttadfd")
        inbandnode2 = InBandWorkerNode(instance_id="nk^3764646d")

        context["provider"] = providers
        if provider is not None:
            context["instances"] = [inbandnode, inbandnode1, inbandnode2]

    return render_to_response('celerymanagementapp/configure.html',
            context,
            context_instance=RequestContext(request))