Verified Commit 6bc97d6c authored by Marco Marinello's avatar Marco Marinello
Browse files

Added a view for clients to download Veyon configuration

parent f82be960
Pipeline #250 passed with stage
in 1 minute and 12 seconds
......@@ -6,6 +6,7 @@ urlpatterns = [
url(r"^login/$", views.Login.as_view(), name="login"),
url(r"^logout/$", views.Logout.as_view(), name="logout"),
url(r"^newsfeed/$", views.NewsFeed.as_view(), name="newsfeed"),
url(r"^veyon/VeyonClientConfiguration$", views.NewsFeed.as_view(), name="veyon-client-conf"),
url(r"^octofussd-error/$", views.OctofussdError.as_view(), name="octofussd_error"),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r"^hostqueue/", include("hostqueue.urls", namespace="hostqueue")),
# coding: utf-8
# Copyright (C) 2021-2022 The FUSS Project <>
# Author: Marco Marinello <>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program or from the site that you downloaded it
# from; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
import re
import mimetypes
from urllib.parse import urlparse
......@@ -9,6 +26,7 @@ from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from django.views.generic import View, TemplateView
from django.views.generic.edit import FormView
import json
from . import backend
from .forms import FormControlClassMixin
from .mixins import OctonetMixin, REDIRECT_FIELD_NAME
......@@ -137,7 +155,7 @@ class Home(OctonetMixin, TemplateView):
if root.has("/"):
serverinfo = root.get("/")
ctx['filesystems'] = serverinfo.pop("filesystems", [])
ctx['load_avg' ] = serverinfo.pop("load_avg", [])
ctx['load_avg'] = serverinfo.pop("load_avg", [])
ctx['last_seen_clients'] = serverinfo.pop("last_seen_clients", [])
sorted_keys = ['organization', 'kernel_version', 'ram_mbyte']
if serverinfo:
......@@ -149,3 +167,33 @@ class Home(OctonetMixin, TemplateView):
class OctofussdError(IntermediatePageMixin, TemplateView):
template_name = "octonet/octofussd_error.html"
class VeyonClientConfiguration(View):
def read_clusters(self):
with open("/etc/clusters") as a:
content =
clusters = {}
for line in content.split("\n"):
if len(line.split(" ")) > 1:
line = line.split(" ")
clusters[line[0]] = line[1:]
return clusters
def get_host_clusters(self, hostname, clusters):
out = []
for cluster in clusters:
if hostname in clusters[cluster]:
return out
def get(self):
if "hostname" not in self.request.GET:
return http.HttpResponse(status=400)
clusters = self.read_clusters()
host_clusters = [
{"name": a, "computers": clusters[a]} for a in self.get_host_clusters(self.request.GET["hostname"])
return http.HttpResponse(
json.dumps(host_clusters), content_type="application/json"
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