Beispiel #1
0
def newnode(request):
    if request.method == 'POST':
        print request.POST.get("provider")
        provider = request.POST.get("provider")
        form = InstanceForm(provider, request.POST)
        print form
        if form.is_valid():
            Inst = form.save(commit = False)
            controller = ProviderController(Inst.provider)
            data_from_provider = controller.spawn_new_instance(form)
            if data_from_provider is not None:
                #TODO: do extra things with data_from_provider
                Inst.save()
                return HttpResponseRedirect('/overview/')
    else:
        print request.GET
        if "provider" in request.GET:
            #p = Provider.objects.get(id=request.GET.get("provider"))
            form = InstanceForm(request.GET.get("provider"), initial={'providier': request.GET.get("provider")})
            #images = p.get_images()
            #form.fields['image'].choices = [(str(img.id), img.name) for img in images]
        else:
            raise Exception
            #TODO: proper HttpError
        
        
    
    return render_to_response('node_form.html', { 'form': form })
Beispiel #2
0
 def get_images(self):
     controller = ProviderController(self)
     return controller.get_images()
Beispiel #3
0
 def get_realms(self):
     controller = ProviderController(self)
     return controller.get_realms()
Beispiel #4
0
 def get_flavors(self):
     controller = ProviderController(self)
     return controller.get_flavors()