mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
Instances overhaul
This commit is contained in:
parent
f23e6b000f
commit
47009d47ca
69 changed files with 5011 additions and 4127 deletions
24
webvirtcloud/middleware.py
Normal file
24
webvirtcloud/middleware.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
import json
|
||||
|
||||
from django.contrib import messages
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from libvirt import libvirtError
|
||||
|
||||
|
||||
class ExceptionMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
return self.get_response(request)
|
||||
|
||||
def process_exception(self, request, exception):
|
||||
if isinstance(exception, libvirtError):
|
||||
messages.error(
|
||||
request,
|
||||
_('libvirt Error - %(exception)s') % {'exception': exception},
|
||||
)
|
||||
return render(request, '500.html', status=500)
|
||||
# TODO: check connecting to host via VPN
|
|
@ -28,7 +28,6 @@ INSTALLED_APPS = [
|
|||
'appsettings',
|
||||
'computes',
|
||||
'console',
|
||||
'create',
|
||||
'datasource',
|
||||
'networks',
|
||||
'instances',
|
||||
|
@ -51,6 +50,7 @@ MIDDLEWARE = [
|
|||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'appsettings.middleware.AppSettingsMiddleware',
|
||||
'webvirtcloud.middleware.ExceptionMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'webvirtcloud.urls'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue