From 1b913fd4d627cc5b1b1bb0567f18ef22855d4948 Mon Sep 17 00:00:00 2001 From: catborise Date: Wed, 24 Oct 2018 16:56:05 +0300 Subject: [PATCH] instance poweron checks is_template attribute. templates should not be e started. by @honza801 --- instances/views.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/instances/views.py b/instances/views.py index e81c35d..86a5608 100644 --- a/instances/views.py +++ b/instances/views.py @@ -313,10 +313,14 @@ def instance(request, compute_id, vname): if request.method == 'POST': if 'poweron' in request.POST: - conn.start() - msg = _("Power On") - addlogmsg(request.user.username, instance.name, msg) - return HttpResponseRedirect(request.get_full_path() + '#poweron') + if instance.is_template: + msg = _("Templates cannot be started.") + error_messages.append(msg) + else: + conn.start() + msg = _("Power On") + addlogmsg(request.user.username, instance.name, msg) + return HttpResponseRedirect(request.get_full_path() + '#poweron') if 'powercycle' in request.POST: conn.force_shutdown() @@ -904,10 +908,14 @@ def instances_actions(request): instance.compute.password, instance.compute.type) if 'poweron' in request.POST: - msg = _("Power On") - addlogmsg(request.user.username, instance.name, msg) - conn.start(name) - return HttpResponseRedirect(request.get_full_path()) + if instance.is_template: + msg = _("Templates cannot be started.") + messages.error(request, msg) + else: + msg = _("Power On") + addlogmsg(request.user.username, instance.name, msg) + conn.start(name) + return HttpResponseRedirect(request.get_full_path()) if 'poweroff' in request.POST: msg = _("Power Off")