From dd3dc0861485ce0ba34a1225ef6c637d2e19dd92 Mon Sep 17 00:00:00 2001 From: "Ing. Jan KRCMAR" Date: Mon, 1 Oct 2018 10:30:22 +0200 Subject: [PATCH] instance poweron checks is_template attribute. templates should not be started. --- instances/views.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/instances/views.py b/instances/views.py index ec6adbc..7145bbe 100644 --- a/instances/views.py +++ b/instances/views.py @@ -138,10 +138,14 @@ def instances(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.") + error_messages.append(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") @@ -412,10 +416,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()