From 286cd7a3ace2f80aa5067bb6fbec70fbf8560905 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Fri, 18 Dec 2015 14:38:26 +0100 Subject: [PATCH] A debug status page embed in the server --- gns3server/handlers/index_handler.py | 14 ++++++++++++++ gns3server/templates/layout.html | 2 ++ gns3server/templates/status.html | 29 ++++++++++++++++++++++++++++ tests/handlers/test_index.py | 5 +++++ 4 files changed, 50 insertions(+) create mode 100644 gns3server/templates/status.html diff --git a/gns3server/handlers/index_handler.py b/gns3server/handlers/index_handler.py index 0a770147..854ed556 100644 --- a/gns3server/handlers/index_handler.py +++ b/gns3server/handlers/index_handler.py @@ -15,6 +15,8 @@ # along with this program. If not, see . from ..web.route import Route +from ..modules.port_manager import PortManager +from ..modules.project_manager import ProjectManager class IndexHandler: @@ -27,3 +29,15 @@ class IndexHandler: ) def index(request, response): response.template("index.html") + + @classmethod + @Route.get( + r"/status", + description="Ressources used by GNS3Server", + api_version=None + ) + def ports(request, response): + response.template("status.html", + port_manager=PortManager.instance(), + project_manager=ProjectManager.instance() + ) diff --git a/gns3server/templates/layout.html b/gns3server/templates/layout.html index 68e3a219..87eed6f3 100644 --- a/gns3server/templates/layout.html +++ b/gns3server/templates/layout.html @@ -15,6 +15,8 @@ Backup images | Backup projects + | + Status {% block body %}{% endblock %} diff --git a/gns3server/templates/status.html b/gns3server/templates/status.html new file mode 100644 index 00000000..40953637 --- /dev/null +++ b/gns3server/templates/status.html @@ -0,0 +1,29 @@ +{% extends "layout.html" %} +{% block body %} +

+ Server status +

+The purpose of this page is to help for GNS3 debug. + +

Opened projects

+ + +

Ports reserved by GNS3

+

TCP

+ + +

UDP

+ +{% endblock %} diff --git a/tests/handlers/test_index.py b/tests/handlers/test_index.py index e4575f83..9866823f 100644 --- a/tests/handlers/test_index.py +++ b/tests/handlers/test_index.py @@ -29,3 +29,8 @@ def test_index(server): html = response.html assert "Website" in html assert __version__ in html + + +def test_status(server): + response = server.get('/status', api_version=None) + assert response.status == 200