Commit d4f0e64c by Kálmán Viktor

dashboard: shut down button

parent cd68ac0d
...@@ -13,7 +13,11 @@ ...@@ -13,7 +13,11 @@
<a title="Start" href="#" class="btn btn-default btn-xs"><i class="icon-play"></i></a> <a title="Start" href="#" class="btn btn-default btn-xs"><i class="icon-play"></i></a>
<a title="Wake up" href="#" class="btn btn-default btn-xs"><i class="icon-sun"></i></a> <a title="Wake up" href="#" class="btn btn-default btn-xs"><i class="icon-sun"></i></a>
{% endif %} {% endif %}
<a title="Shut down" href="#" class="btn btn-default btn-xs"><i class="icon-off"></i></a> <form style="display: inline;" method="POST" action="{% url "dashboard.views.detail" pk=instance.pk %}">
{% csrf_token %}
<input type="hidden" name="shut_down" value="dummy"/>
<button title="Shut down" class="btn btn-default btn-xs" type="submit"><i class="icon-off"></i></button>
</form>
<a title="Migrate" href="#" class="btn btn-default btn-xs"><i class="icon-truck"></i></a> <a title="Migrate" href="#" class="btn btn-default btn-xs"><i class="icon-truck"></i></a>
<form style="display: inline;" method="POST" action="{% url "dashboard.views.detail" pk=instance.pk %}"> <form style="display: inline;" method="POST" action="{% url "dashboard.views.detail" pk=instance.pk %}">
{% csrf_token %} {% csrf_token %}
......
...@@ -174,6 +174,7 @@ class VmDetailView(CheckedDetailView): ...@@ -174,6 +174,7 @@ class VmDetailView(CheckedDetailView):
'new_network_vlan': self.__new_network, 'new_network_vlan': self.__new_network,
'save_as': self.__save_as, 'save_as': self.__save_as,
'disk-name': self.__add_disk, 'disk-name': self.__add_disk,
'shut_down': self.__shut_down,
} }
for k, v in options.iteritems(): for k, v in options.iteritems():
...@@ -360,6 +361,15 @@ class VmDetailView(CheckedDetailView): ...@@ -360,6 +361,15 @@ class VmDetailView(CheckedDetailView):
return redirect("%s#resources" % reverse_lazy( return redirect("%s#resources" % reverse_lazy(
"dashboard.views.detail", kwargs={'pk': self.object.pk})) "dashboard.views.detail", kwargs={'pk': self.object.pk}))
def __shut_down(self, request):
self.object = self.get_object()
if not self.object.has_level(request.user, 'owner'):
raise PermissionDenied()
self.object.shutdown_async(request.user)
return redirect("%s#activity" % reverse_lazy(
"dashboard.views.detail", kwargs={'pk': self.object.pk}))
class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView): class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
template_name = "dashboard/node-detail.html" template_name = "dashboard/node-detail.html"
......
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