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

Return status when you start / stop / suspend a node

Should avoid sync issues
This commit is contained in:
Julien Duponchelle 2016-08-22 11:26:51 +02:00
parent 324962def5
commit cde28c849e
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
3 changed files with 17 additions and 8 deletions

View File

@ -182,7 +182,8 @@ class NodeHandler:
project = Controller.instance().get_project(request.match_info["project_id"])
node = project.get_node(request.match_info["node_id"])
yield from node.start()
response.set_status(204)
response.json(node)
response.set_status(201)
@Route.post(
r"/projects/{project_id}/nodes/{node_id}/stop",
@ -202,7 +203,8 @@ class NodeHandler:
project = Controller.instance().get_project(request.match_info["project_id"])
node = project.get_node(request.match_info["node_id"])
yield from node.stop()
response.set_status(204)
response.json(node)
response.set_status(201)
@Route.post(
r"/projects/{project_id}/nodes/{node_id}/suspend",
@ -222,7 +224,8 @@ class NodeHandler:
project = Controller.instance().get_project(request.match_info["project_id"])
node = project.get_node(request.match_info["node_id"])
yield from node.suspend()
response.set_status(204)
response.json(node)
response.set_status(201)
@Route.post(
r"/projects/{project_id}/nodes/{node_id}/reload",
@ -242,7 +245,8 @@ class NodeHandler:
project = Controller.instance().get_project(request.match_info["project_id"])
node = project.get_node(request.match_info["node_id"])
yield from node.reload()
response.set_status(204)
response.json(node)
response.set_status(201)
@Route.delete(
r"/projects/{project_id}/nodes/{node_id}",

View File

@ -100,6 +100,7 @@ TOPOLOGY_SCHEMA = {
"additionalProperties": False
}
def main():
import jsonschema
import sys

View File

@ -146,7 +146,8 @@ def test_start_node(http_controller, tmpdir, project, compute, node):
compute.post = AsyncioMagicMock()
response = http_controller.post("/projects/{}/nodes/{}/start".format(project.id, node.id), example=True)
assert response.status == 204
assert response.status == 201
assert response.json == node.__json__()
def test_stop_node(http_controller, tmpdir, project, compute, node):
@ -154,7 +155,8 @@ def test_stop_node(http_controller, tmpdir, project, compute, node):
compute.post = AsyncioMagicMock()
response = http_controller.post("/projects/{}/nodes/{}/stop".format(project.id, node.id), example=True)
assert response.status == 204
assert response.status == 201
assert response.json == node.__json__()
def test_suspend_node(http_controller, tmpdir, project, compute, node):
@ -162,7 +164,8 @@ def test_suspend_node(http_controller, tmpdir, project, compute, node):
compute.post = AsyncioMagicMock()
response = http_controller.post("/projects/{}/nodes/{}/suspend".format(project.id, node.id), example=True)
assert response.status == 204
assert response.status == 201
assert response.json == node.__json__()
def test_reload_node(http_controller, tmpdir, project, compute, node):
@ -170,7 +173,8 @@ def test_reload_node(http_controller, tmpdir, project, compute, node):
compute.post = AsyncioMagicMock()
response = http_controller.post("/projects/{}/nodes/{}/reload".format(project.id, node.id), example=True)
assert response.status == 204
assert response.status == 201
assert response.json == node.__json__()
def test_delete_node(http_controller, tmpdir, project, compute, node):