Commit ac7a1c25 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

helpdesk: Handle vm action errors

parent 8b702671
...@@ -39,6 +39,12 @@ ...@@ -39,6 +39,12 @@
</ul> </ul>
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
{% if error %}
<br />
<div class="alert alert-error ">
<span>{{ error|escape }}</span>
</div>
{% endif %}
<div class="object-anchor" id="account"></div> <div class="object-anchor" id="account"></div>
<h3 class="info">{{ account_name }} | {{ account }} | {{ vms|length }} VMs | {{ networks|length }} Networks</h3> <h3 class="info">{{ account_name }} | {{ account }} | {{ vms|length }} VMs | {{ networks|length }} Networks</h3>
</div> </div>
......
...@@ -176,6 +176,7 @@ def account(request, search_query): ...@@ -176,6 +176,7 @@ def account(request, search_query):
logging.info("Helpdesk search by %s: %s", request.user_uniq, search_query) logging.info("Helpdesk search by %s: %s", request.user_uniq, search_query)
show_deleted = bool(int(request.GET.get('deleted', SHOW_DELETED_VMS))) show_deleted = bool(int(request.GET.get('deleted', SHOW_DELETED_VMS)))
error = request.GET.get('error', None)
account_exists = True account_exists = True
# flag to indicate successfull astakos calls # flag to indicate successfull astakos calls
...@@ -249,6 +250,7 @@ def account(request, search_query): ...@@ -249,6 +250,7 @@ def account(request, search_query):
user_context = { user_context = {
'account_exists': account_exists, 'account_exists': account_exists,
'error': error,
'is_ip': is_ip, 'is_ip': is_ip,
'is_vm': is_vm, 'is_vm': is_vm,
'is_uuid': is_uuid, 'is_uuid': is_uuid,
...@@ -330,9 +332,17 @@ def vm_suspend_release(request, vm_id): ...@@ -330,9 +332,17 @@ def vm_suspend_release(request, vm_id):
def vm_shutdown(request, vm_id): def vm_shutdown(request, vm_id):
logging.info("VM %s shutdown by %s", vm_id, request.user_uniq) logging.info("VM %s shutdown by %s", vm_id, request.user_uniq)
vm = VirtualMachine.objects.get(pk=vm_id) vm = VirtualMachine.objects.get(pk=vm_id)
jobId = servers_backend.stop(vm)
account = vm.userid account = vm.userid
return HttpResponseRedirect(reverse('helpdesk-details', args=(account,))) error = None
try:
jobId = servers_backend.stop(vm)
except Exception, e:
error = e.message
redirect = reverse('helpdesk-details', args=(account,))
if error:
redirect = "%s?error=%s" % (redirect, error)
return HttpResponseRedirect(redirect)
@helpdesk_user_required @helpdesk_user_required
...@@ -340,6 +350,14 @@ def vm_shutdown(request, vm_id): ...@@ -340,6 +350,14 @@ def vm_shutdown(request, vm_id):
def vm_start(request, vm_id): def vm_start(request, vm_id):
logging.info("VM %s start by %s", vm_id, request.user_uniq) logging.info("VM %s start by %s", vm_id, request.user_uniq)
vm = VirtualMachine.objects.get(pk=vm_id) vm = VirtualMachine.objects.get(pk=vm_id)
jobId = servers_backend.start(vm)
account = vm.userid account = vm.userid
return HttpResponseRedirect(reverse('helpdesk-details', args=(account,))) error = None
try:
jobId = servers_backend.start(vm)
except Exception, e:
error = e.message
redirect = reverse('helpdesk-details', args=(account,))
if error:
redirect = "%s?error=%s" % (redirect, error)
return HttpResponseRedirect(redirect)
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 to comment