API method for getting a node

This commit is contained in:
Julien Duponchelle 2016-09-20 10:14:30 +02:00
parent 9fbe23e09b
commit 77eae35778
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 33 additions and 0 deletions

View File

@ -53,6 +53,21 @@ class NodeHandler:
response.set_status(201)
response.json(node)
@Route.get(
r"/projects/{project_id}/nodes/{node_id}",
status_codes={
200: "Node found",
400: "Invalid request",
404: "Node doesn't exist"
},
description="Update a node instance",
output=NODE_OBJECT_SCHEMA)
def get_node(request, response):
project = Controller.instance().get_project(request.match_info["project_id"])
node = project.get_node(request.match_info["node_id"])
response.set_status(200)
response.json(node)
@Route.get(
r"/projects/{project_id}/nodes",
parameters={

View File

@ -91,6 +91,24 @@ def test_list_node(http_controller, tmpdir, project, compute):
assert response.json[0]["name"] == "test"
def test_get_node(http_controller, tmpdir, project, compute):
response = MagicMock()
response.json = {"console": 2048}
compute.post = AsyncioMagicMock(return_value=response)
response = http_controller.post("/projects/{}/nodes".format(project.id), {
"name": "test",
"node_type": "vpcs",
"compute_id": "example.com",
"properties": {
"startup_script": "echo test"
}
})
response = http_controller.get("/projects/{}/nodes/{}".format(project.id, response.json["node_id"]), example=True)
assert response.status == 200
assert response.json["name"] == "test"
def test_update_node(http_controller, tmpdir, project, compute, node):
response = MagicMock()
response.json = {"console": 2048}