mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 04:47:54 +00:00
parent
342bcdb5b6
commit
ce0d715895
@ -140,6 +140,12 @@ class Project:
|
||||
return node
|
||||
return self._nodes[node_id]
|
||||
|
||||
@asyncio.coroutine
|
||||
def delete_node(self, node_id):
|
||||
node = self.get_node(node_id)
|
||||
del self._nodes[node.id]
|
||||
yield from node.delete()
|
||||
|
||||
def get_node(self, node_id):
|
||||
"""
|
||||
Return the node or raise a 404 if the node is unknown
|
||||
|
@ -260,6 +260,5 @@ class NodeHandler:
|
||||
description="Delete a node instance")
|
||||
def delete(request, response):
|
||||
project = Controller.instance().get_project(request.match_info["project_id"])
|
||||
node = project.get_node(request.match_info["node_id"])
|
||||
yield from node.destroy()
|
||||
yield from project.delete_node(request.match_info["node_id"])
|
||||
response.set_status(204)
|
||||
|
@ -89,6 +89,7 @@ def test_add_node_local(async_run):
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
assert node.id in project._nodes
|
||||
|
||||
compute.post.assert_any_call('/projects', data={
|
||||
"name": project._name,
|
||||
@ -131,6 +132,25 @@ def test_add_node_non_local(async_run):
|
||||
assert compute in project._project_created_on_compute
|
||||
|
||||
|
||||
def test_delete_node(async_run):
|
||||
"""
|
||||
For a local server we send the project path
|
||||
"""
|
||||
compute = MagicMock()
|
||||
project = Project()
|
||||
|
||||
response = MagicMock()
|
||||
response.json = {"console": 2048}
|
||||
compute.post = AsyncioMagicMock(return_value=response)
|
||||
|
||||
node = async_run(project.add_node(compute, None, name="test", node_type="vpcs", properties={"startup_config": "test.cfg"}))
|
||||
assert node.id in project._nodes
|
||||
async_run(project.delete_node(node.id))
|
||||
assert node.id not in project._nodes
|
||||
|
||||
compute.delete.assert_any_call('/projects/{}/vpcs/nodes/{}'.format(project.id, node.id))
|
||||
|
||||
|
||||
def test_getVM(async_run):
|
||||
compute = MagicMock()
|
||||
project = Project()
|
||||
|
Loading…
Reference in New Issue
Block a user