From a496aaab9e457d5154f5179d5e9689886d1d4992 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 16 May 2016 21:12:32 +0200 Subject: [PATCH] Send node.updated event and tests are green Fix #524 --- gns3server/compute/base_node.py | 4 +--- gns3server/controller/project.py | 4 ++-- tests/controller/test_project.py | 6 ++++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gns3server/compute/base_node.py b/gns3server/compute/base_node.py index 850ccec5..7fefb89c 100644 --- a/gns3server/compute/base_node.py +++ b/gns3server/compute/base_node.py @@ -105,9 +105,7 @@ class BaseNode: def status(self, status): self._node_status = status - if status in ("started", "stopped", "suspended"): - self.project.emit("node.{status}".format(status=status), {"node_id": self.id}) - self.project.emit("node.updated", self) # FIXME: should we send this when we just start/stop/suspend a node? + self.project.emit("node.updated", self) @property def command_line(self): diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 819eb454..d97949c3 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -121,14 +121,14 @@ class Project: if compute not in self._project_created_on_compute: # For a local server we send the project path if compute.id == "local": - yield from compute.post("/projects", { + yield from compute.post("/projects", data={ "name": self._name, "project_id": self._id, "temporary": self._temporary, "path": self._path }) else: - yield from compute.post("/projects", { + yield from compute.post("/projects", data={ "name": self._name, "project_id": self._id, "temporary": self._temporary diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 75881c2c..90ac792f 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -90,7 +90,7 @@ def test_add_node_local(async_run): node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"})) - compute.post.assert_any_call('/projects', { + compute.post.assert_any_call('/projects', data={ "name": project._name, "project_id": project._id, "temporary": project._temporary, @@ -98,6 +98,7 @@ def test_add_node_local(async_run): }) compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id), data={'node_id': node.id, + 'console_type': 'telnet', 'startup_config': 'test.cfg', 'name': 'test'}) assert compute in project._project_created_on_compute @@ -117,13 +118,14 @@ def test_add_node_non_local(async_run): node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"})) - compute.post.assert_any_call('/projects', { + compute.post.assert_any_call('/projects', data={ "name": project._name, "project_id": project._id, "temporary": project._temporary }) compute.post.assert_any_call('/projects/{}/vpcs/nodes'.format(project.id), data={'node_id': node.id, + 'console_type': 'telnet', 'startup_config': 'test.cfg', 'name': 'test'}) assert compute in project._project_created_on_compute