diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 53518b26..d1d2f2eb 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -115,7 +115,7 @@ class Controller: controller=self, protocol=server_config.get("protocol", "http"), host=server_config.get("host", "localhost"), - port=server_config.get("port", 3080), + port=server_config.getint("port", 3080), user=server_config.get("user", ""), password=server_config.get("password", "")) return self._computes["local"] diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 97cafa41..d64929ab 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -51,6 +51,7 @@ class Compute: self._controller = controller self._setAuth(user, password) self._session = aiohttp.ClientSession() + self._version = None # If the compute is local but the compute id is local # it's a configuration issue @@ -71,6 +72,20 @@ class Compute: else: 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 def id(self): """ @@ -160,6 +175,7 @@ class Compute: if "version" not in response.json: 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]: raise aiohttp.web.HTTPConflict(text="The server {} versions are not compatible {} != {}".format(self._id, __version__, response.json["version"])) diff --git a/gns3server/templates/controller.html b/gns3server/templates/controller.html index a9064f16..871e72ce 100644 --- a/gns3server/templates/controller.html +++ b/gns3server/templates/controller.html @@ -28,11 +28,21 @@ in futur GNS3 versions.

Computes

- + + + + + {% for compute in controller.computes.values() %} + + + + + {% endfor %}
ID + IDVersionConnectedProtocolHostPort
{{compute.id}}{{compute.version}}{{compute.connected}}{{compute.protocol}}{{compute.host}}{{compute.port}}
diff --git a/tests/controller/test_compute.py b/tests/controller/test_compute.py index 63aa8fc7..2a6d7293 100644 --- a/tests/controller/test_compute.py +++ b/tests/controller/test_compute.py @@ -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("POST", "https://example.com:84/v2/compute/projects", data='{"a": "b"}', headers={'content-type': 'application/json'}, auth=None) assert compute._connected + assert compute.version == __version__ def test_compute_httpQueryNotConnectedInvalidVersion(compute, async_run):