mirror of
https://github.com/retspen/webvirtcloud.git
synced 2026-06-06 20:39:38 +00:00
1
.github/workflows/linter.yml
vendored
1
.github/workflows/linter.yml
vendored
@@ -71,6 +71,7 @@ jobs:
|
|||||||
FILTER_REGEX_EXCLUDE: .*(static|scss|venv|locale)/.*
|
FILTER_REGEX_EXCLUDE: .*(static|scss|venv|locale)/.*
|
||||||
DEFAULT_BRANCH: master
|
DEFAULT_BRANCH: master
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
VALIDATE_ALL_CODEBASE: false
|
||||||
VALIDATE_ANSIBLE: false
|
VALIDATE_ANSIBLE: false
|
||||||
VALIDATE_CLOJURE: false
|
VALIDATE_CLOJURE: false
|
||||||
VALIDATE_COFFEE: false
|
VALIDATE_COFFEE: false
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
from vrtManager.util import randomUUID
|
||||||
|
|
||||||
|
from django.http.response import HttpResponseServerError
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
from libvirt import libvirtError
|
from libvirt import libvirtError
|
||||||
|
|
||||||
|
from accounts.models import UserInstance
|
||||||
from appsettings.settings import app_settings
|
from appsettings.settings import app_settings
|
||||||
from instances.models import Instance
|
from instances.models import Instance
|
||||||
from vrtManager.instance import wvmInstance
|
from vrtManager.instance import wvmInstance
|
||||||
@@ -35,7 +40,20 @@ def console(request):
|
|||||||
temptoken = token.split("-", 1)
|
temptoken = token.split("-", 1)
|
||||||
host = int(temptoken[0])
|
host = int(temptoken[0])
|
||||||
uuid = temptoken[1]
|
uuid = temptoken[1]
|
||||||
instance = Instance.objects.get(compute_id=host, uuid=uuid)
|
|
||||||
|
if not request.user.is_superuser:
|
||||||
|
try:
|
||||||
|
userInstance = UserInstance.objects.get(
|
||||||
|
instance__compute_id=host, instance__uuid=uuid, user__id=request.user.id
|
||||||
|
)
|
||||||
|
instance = Instance.objects.get(compute_id=host, uuid=uuid)
|
||||||
|
except UserInstance.DoesNotExist:
|
||||||
|
instance = None
|
||||||
|
console_error = _("User does not have permission to access console or host/instance not exist")
|
||||||
|
return HttpResponseServerError(console_error)
|
||||||
|
else:
|
||||||
|
instance = Instance.objects.get(compute_id=host, uuid=uuid)
|
||||||
|
|
||||||
conn = wvmInstance(
|
conn = wvmInstance(
|
||||||
instance.compute.hostname,
|
instance.compute.hostname,
|
||||||
instance.compute.login,
|
instance.compute.login,
|
||||||
@@ -63,9 +81,9 @@ def console(request):
|
|||||||
response = render(request, console_page, locals())
|
response = render(request, console_page, locals())
|
||||||
else:
|
else:
|
||||||
if console_type is None:
|
if console_type is None:
|
||||||
console_error = "Fail to get console. Please check the console configuration of your VM."
|
console_error = _("Fail to get console. Please check the console configuration of your VM.")
|
||||||
else:
|
else:
|
||||||
console_error = "Console type '%(type)s' has not support" % {"type": console_type}
|
console_error = _("Console type '%(type)s' has not support") % {"type": console_type}
|
||||||
response = render(request, "console-vnc-lite.html", locals())
|
response = render(request, "console-vnc-lite.html", locals())
|
||||||
|
|
||||||
response.set_cookie("token", token)
|
response.set_cookie("token", token)
|
||||||
|
|||||||
Reference in New Issue
Block a user