Web interface for debbuging controller

pull/565/head
Julien Duponchelle 8 years ago
parent 7a095478fe
commit c0e452133d
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D

@ -93,6 +93,13 @@ class Project:
except KeyError:
raise aiohttp.web.HTTPNotFound(text="VM ID {} doesn't exist".format(vm_id))
@property
def vms(self):
"""
:returns: Dictionnary of the VMS
"""
return self._vms
@asyncio.coroutine
def addLink(self):
"""
@ -111,6 +118,13 @@ class Project:
except KeyError:
raise aiohttp.web.HTTPNotFound(text="Link ID {} doesn't exist".format(link_id))
@property
def links(self):
"""
:returns: Dictionnary of the Links
"""
return self._links
@asyncio.coroutine
def close(self):
for hypervisor in self._hypervisors:

@ -52,6 +52,10 @@ class VM:
def id(self):
return self._id
@property
def name(self):
return self._name
@property
def vm_type(self):
return self._vm_type
@ -76,6 +80,14 @@ class VM:
def hypervisor(self):
return self._hypervisor
@property
def host(self):
"""
:returns: Domain or ip for console connection
"""
return self._hypervisor.host
@asyncio.coroutine
def create(self):
data = copy.copy(self._properties)

@ -16,6 +16,7 @@
from ..web.route import Route
from ..controller import Controller
from ..hypervisor.port_manager import PortManager
from ..hypervisor.project_manager import ProjectManager
from ..version import __version__
@ -33,14 +34,33 @@ class IndexHandler:
@classmethod
@Route.get(
r"/status",
description="Ressources used by GNS3Server"
r"/hypervisor",
description="Ressources used by GNS3 Hypervisor"
)
def ports(request, response):
response.template("status.html",
def hypervisor(request, response):
response.template("hypervisor.html",
port_manager=PortManager.instance(),
project_manager=ProjectManager.instance()
)
@classmethod
@Route.get(
r"/controller",
description="Ressources used by GNS3 Controller"
)
def controller(request, response):
response.template("controller.html",
controller=Controller.instance()
)
@classmethod
@Route.get(
r"/projects/{project_id}",
description="Ressources used by GNS3 Controller"
)
def project(request, response):
controller = Controller.instance()
response.template("project.html",
project=controller.getProject(request.match_info["project_id"]))
@classmethod
@Route.get(

@ -0,0 +1,41 @@
{% extends "layout.html" %}
{% block body %}
<h1>
Controller status
</h1>
The purpose of this page is to help for GNS3 debug. This can be dropped
in futur GNS3 versions.
<h2>Opened projects</h2>
<table border="1">
<tr>
<th>Name</th>
<th>ID</td>
<th>VMs</th>
<th>Links</th>
</tr>
{% for project in controller.projects.values() %}
<tr>
<td><a href="/projects/{{project.id}}">{{project.name}}</a></td>
<td><a href="/projects/{{project.id}}">{{project.id}}</a></td>
<td>{{project.vms|length}}</td>
<td>{{project.links|length}}</td>
</tr>
{% endfor %}
</table>
<h2>Hypervisors</h2>
<table border="1">
<tr>
<th>ID</td>
</tr>
{% for hypervisor in controller.hypervisors.values() %}
<tr>
<td>{{hypervisor.id}}</td>
</tr>
{% endfor %}
</table>
{%endblock%}

@ -3,7 +3,8 @@
<h1>
Server status
</h1>
The purpose of this page is to help for GNS3 debug.
The purpose of this page is to help for GNS3 debug. This can be dropped
in futur GNS3 versions.
<h2>Opened projects</h2>
<table border="1">

@ -16,7 +16,9 @@
|
<a href="/backup/projects.tar">Backup projects</a>
|
<a href="/status">Status</a>
<a href="/controller">Controller status</a>
|
<a href="/hypervisor">Hypervisor status</a>
</div>
{% block body %}{% endblock %}
</body>

@ -0,0 +1,39 @@
{% extends "layout.html" %}
{% block body %}
<h1>
{{project.name}}
</h1>
The purpose of this page is to help for GNS3 debug. This can be dropped
in futur GNS3 versions.
<h2>VMs</h2>
<table border="1">
<tr>
<th>Name</th>
<th>ID</td>
<th>Console</th>
</tr>
{% for vm in project.vms.values() %}
<tr>
<td>{{vm.name}}</td>
<td>{{vm.id}}</td>
<td><a href="{{vm.console_type}}://{{vm.host}}:{{vm.console}}">Console</a>
</tr>
{% endfor %}
</table>
<h2>Links</h2>
<table border="1">
<tr>
<th>ID</td>
</tr>
{% for link in project.links.values() %}
<tr>
<td>{{link.id}}</td>
</tr>
{% endfor %}
</table>
{%endblock%}

@ -21,6 +21,7 @@ import os
from unittest.mock import patch
from gns3server.version import __version__
from gns3server.controller import Controller
def test_index(http_root):
@ -31,8 +32,21 @@ def test_index(http_root):
assert __version__ in html
def test_status(http_root):
response = http_root.get('/status')
def test_controller(http_root, async_run):
project = async_run(Controller.instance().addProject(name="test"))
response = http_root.get('/controller')
assert "test" in response.html
assert response.status == 200
def test_hypervisor(http_root):
response = http_root.get('/hypervisor')
assert response.status == 200
def test_project(http_root, async_run):
project = async_run(Controller.instance().addProject(name="test"))
response = http_root.get('/projects/{}'.format(project.id))
assert response.status == 200

Loading…
Cancel
Save