1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Show version for debug

This commit is contained in:
Julien Duponchelle 2016-05-11 16:31:16 +02:00
parent 95d2bd0065
commit a0344576ba
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
4 changed files with 29 additions and 2 deletions

View File

@ -115,7 +115,7 @@ class Controller:
controller=self, controller=self,
protocol=server_config.get("protocol", "http"), protocol=server_config.get("protocol", "http"),
host=server_config.get("host", "localhost"), host=server_config.get("host", "localhost"),
port=server_config.get("port", 3080), port=server_config.getint("port", 3080),
user=server_config.get("user", ""), user=server_config.get("user", ""),
password=server_config.get("password", "")) password=server_config.get("password", ""))
return self._computes["local"] return self._computes["local"]

View File

@ -51,6 +51,7 @@ class Compute:
self._controller = controller self._controller = controller
self._setAuth(user, password) self._setAuth(user, password)
self._session = aiohttp.ClientSession() self._session = aiohttp.ClientSession()
self._version = None
# If the compute is local but the compute id is local # If the compute is local but the compute id is local
# it's a configuration issue # it's a configuration issue
@ -71,6 +72,20 @@ class Compute:
else: else:
self._auth = None self._auth = None
@property
def version(self):
"""
:returns: Version of compute node (string or None if not connected)
"""
return self._version
@property
def connected(self):
"""
:returns: True if compute node is connected
"""
return self._connected
@property @property
def id(self): def id(self):
""" """
@ -160,6 +175,7 @@ class Compute:
if "version" not in response.json: if "version" not in response.json:
raise aiohttp.web.HTTPConflict(text="The server {} is not a GNS3 server".format(self._id)) raise aiohttp.web.HTTPConflict(text="The server {} is not a GNS3 server".format(self._id))
self._version = response.json["version"]
if parse_version(__version__)[:2] != parse_version(response.json["version"])[:2]: if parse_version(__version__)[:2] != parse_version(response.json["version"])[:2]:
raise aiohttp.web.HTTPConflict(text="The server {} versions are not compatible {} != {}".format(self._id, __version__, response.json["version"])) raise aiohttp.web.HTTPConflict(text="The server {} versions are not compatible {} != {}".format(self._id, __version__, response.json["version"]))

View File

@ -28,11 +28,21 @@ in futur GNS3 versions.
<h2>Computes</h2> <h2>Computes</h2>
<table border="1"> <table border="1">
<tr> <tr>
<th>ID</td> <th>ID</th>
<th>Version</th>
<th>Connected</th>
<th>Protocol</th>
<th>Host</th>
<th>Port</th>
</tr> </tr>
{% for compute in controller.computes.values() %} {% for compute in controller.computes.values() %}
<tr> <tr>
<td>{{compute.id}}</td> <td>{{compute.id}}</td>
<td>{{compute.version}}</td>
<td>{{compute.connected}}</td>
<td>{{compute.protocol}}</td>
<td>{{compute.host}}</td>
<td>{{compute.port}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -86,6 +86,7 @@ def test_compute_httpQueryNotConnected(compute, async_run):
mock.assert_any_call("GET", "https://example.com:84/v2/compute/version", headers={'content-type': 'application/json'}, data=None, auth=None) mock.assert_any_call("GET", "https://example.com:84/v2/compute/version", headers={'content-type': 'application/json'}, data=None, auth=None)
mock.assert_any_call("POST", "https://example.com:84/v2/compute/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None) mock.assert_any_call("POST", "https://example.com:84/v2/compute/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None)
assert compute._connected assert compute._connected
assert compute.version == __version__
def test_compute_httpQueryNotConnectedInvalidVersion(compute, async_run): def test_compute_httpQueryNotConnectedInvalidVersion(compute, async_run):