def edit_application(request, appid=0): re = application.show(appid) if re: context = {} context['title'] = "Edit Application" context['baseinfo'] = re context['meth'] = "edit" return render(request, 'docker/edit_application.html', context) else: return HttpResponseRedirect("/cmdb/application")
def edit_application(request,appid=0): re=application.show(appid) if re: context={} context['title']="Edit Application" context['baseinfo']=re context['meth']="edit" return render(request,'docker/edit_application.html',context) else: return HttpResponseRedirect("/cmdb/application")
def applications(request, appid=0): if not appid: context = {} q = request.GET.get('q') p = int(request.GET.get('page', 1)) if q: re = application.search(q) context['title'] = "Applications in search" else: re = application.showAll() context['title'] = "Applications List" if re: page = Paginator(re, 10) if p > 0 and p <= page.num_pages: context['page'] = page.page(p) else: context['page'] = page.page(1) context['num_pages'] = page.num_pages for pa in context['page']: pa.setUrl("/cmdb/application/" + str(pa.id)) context['uri'] = 'application' context['with_group'] = False context['with_new'] = True return render(request, 'list.html', context) else: if request.method == 'POST': meth = request.POST.get('_method', 'show') if meth == 'delete': application.delete(appid) return HttpResponse("ok") if meth == 'edit': name = request.POST.get('name') description = request.POST.get('description') if name: application.edit(appid, name, description) return HttpResponse("ok") if meth == 'start': app = application.show(appid) containerid = app.containerid ip = app.engineip port = app.engineport dockerclient.start(ip, port, containerid) application.updateStatus(app) return HttpResponse("ok") if meth == 'stop': app = application.show(appid) containerid = app.containerid ip = app.engineip port = app.engineport dockerclient.stop(ip, port, containerid) application.updateStatus(app) return HttpResponse("ok") else: context = {} re = application.show(appid) if re: inspect = dockerclient.inspect_container( re.engineip, re.engineport, re.containername) context['title'] = "Applications Info" context['baseinfo'] = re context['inspect'] = inspect return render(request, 'docker/application.html', context) else: return HttpResponseRedirect("/cmdb/application")
def applications(request,appid=0): if not appid: context={} q=request.GET.get('q') p=int(request.GET.get('page',1)) if q: re=application.search(q) context['title']="Applications in search" else: re=application.showAll() context['title']="Applications List" if re: page=Paginator(re,10) if p>0 and p<=page.num_pages: context['page']=page.page(p) else: context['page']=page.page(1) context['num_pages']=page.num_pages for pa in context['page']: pa.setUrl("/cmdb/application/"+str(pa.id)) context['uri']='application' context['with_group']=False context['with_new']=True return render(request, 'list.html',context) else: if request.method=='POST': meth=request.POST.get('_method','show') if meth=='delete': application.delete(appid) return HttpResponse("ok") if meth=='edit': name=request.POST.get('name') description=request.POST.get('description') if name: application.edit(appid, name, description) return HttpResponse("ok") if meth=='start': app=application.show(appid) containerid=app.containerid ip=app.engineip port=app.engineport dockerclient.start(ip, port, containerid) application.updateStatus(app) return HttpResponse("ok") if meth=='stop': app=application.show(appid) containerid=app.containerid ip=app.engineip port=app.engineport dockerclient.stop(ip, port, containerid) application.updateStatus(app) return HttpResponse("ok") else: context={} re=application.show(appid) if re: inspect=dockerclient.inspect_container(re.engineip,re.engineport,re.containername) context['title']="Applications Info" context['baseinfo']=re context['inspect']=inspect return render(request, 'docker/application.html',context) else: return HttpResponseRedirect("/cmdb/application")