diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index ae73907e..939e5eff 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -205,7 +205,7 @@ class BaseManager: yield from wait_run_in_executor(shutil.move, legacy_vm_working_path, new_vm_working_path) except OSError as e: raise aiohttp.web.HTTPInternalServerError(text="Could not move vm working directory: {} to {} {}".format(legacy_vm_working_path, - new_vm_working_path,e)) + new_vm_working_path, e)) return new_id @@ -309,6 +309,7 @@ class BaseManager: """ node = yield from self.close_node(node_id) + node.project.emit("node.deleted", node) node.project.mark_node_for_destruction(node) if node.id in self._nodes: del self._nodes[node.id] diff --git a/tests/compute/test_manager.py b/tests/compute/test_manager.py index 58062b18..2acec3eb 100644 --- a/tests/compute/test_manager.py +++ b/tests/compute/test_manager.py @@ -193,3 +193,14 @@ def test_list_images_empty(loop, qemu, tmpdir): def test_list_images_directory_not_exist(loop, qemu): with patch("gns3server.compute.Qemu.get_images_directory", return_value="/bla"): assert loop.run_until_complete(qemu.list_images()) == [] + + +def test_delete_node(async_run, vpcs, project): + project._nodes = set() + node_id = str(uuid.uuid4()) + node = async_run(vpcs.create_node("PC 1", project.id, node_id, console=2222)) + assert node in project.nodes + with patch("gns3server.compute.project.Project.emit") as mock_emit: + async_run(vpcs.delete_node(node_id)) + mock_emit.assert_called_with("node.deleted", node) + assert node not in project.nodes