Commit 851d534a by Kálmán Viktor

dashboard: vm delete

parent 5325758b
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a href="#"><i class="icon-refresh"></i> Reboot</a></li> <li><a href="#"><i class="icon-refresh"></i> Reboot</a></li>
<li><a href="#"><i class="icon-off"></i> Shutdown</a></li> <li><a href="#"><i class="icon-off"></i> Shutdown</a></li>
<li><a href="#"><i class="icon-remove"></i> Discard</a></li> <li><a href="{% url "dashboard.views.delete-vm" pk=instance.pk %}"><i class="icon-remove"></i> Discard</a></li>
</ul> </ul>
</div> </div>
</div> </div>
......
...@@ -2,12 +2,12 @@ from django.conf.urls import patterns, url ...@@ -2,12 +2,12 @@ from django.conf.urls import patterns, url
from vm.models import Instance from vm.models import Instance
from .views import ( from .views import (
IndexView, VmDetailView, VmList, VmCreate, TemplateDetail, AclUpdateView IndexView, VmDetailView, VmList, VmCreate, TemplateDetail, AclUpdateView,
) delete_vm)
urlpatterns = patterns( urlpatterns = patterns(
'', '',
url(r'^$', IndexView.as_view()), url(r'^$', IndexView.as_view(), name="dashboard.index"),
url(r'^template/(?P<pk>\d+)/$', TemplateDetail.as_view(), url(r'^template/(?P<pk>\d+)/$', TemplateDetail.as_view(),
name='dashboard.views.template-detail'), name='dashboard.views.template-detail'),
url(r'^vm/(?P<pk>\d+)/$', VmDetailView.as_view(), url(r'^vm/(?P<pk>\d+)/$', VmDetailView.as_view(),
...@@ -17,4 +17,6 @@ urlpatterns = patterns( ...@@ -17,4 +17,6 @@ urlpatterns = patterns(
url(r'^vm/list/$', VmList.as_view(), name='dashboard.views.vm-list'), url(r'^vm/list/$', VmList.as_view(), name='dashboard.views.vm-list'),
url(r'^vm/create/$', VmCreate.as_view(), url(r'^vm/create/$', VmCreate.as_view(),
name='dashboard.views.vm-create'), name='dashboard.views.vm-create'),
url(r'^vm/delete/(?P<pk>\d+)/$', delete_vm,
name="dashboard.views.delete-vm"),
) )
...@@ -234,3 +234,17 @@ class VmCreate(TemplateView): ...@@ -234,3 +234,17 @@ class VmCreate(TemplateView):
status=500 if resp.get('error') else 200) status=500 if resp.get('error') else 200)
else: else:
return redirect(reverse_lazy('dashboard.views.detail', resp)) return redirect(reverse_lazy('dashboard.views.detail', resp))
def delete_vm(request, **kwargs):
vm_pk = kwargs['pk']
vm = Instance.objects.get(pk=vm_pk)
print vm
vm.destroy_async()
if request.is_ajax():
return HttpResponse("ok")
else:
next = request.GET.get('next')
return redirect(next if next else reverse_lazy('dashboard.index'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment