From d43e78a1d73b41bcdb598d2bb9f290f74454f363 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 12 May 2016 16:41:05 +0200 Subject: [PATCH] Support all characters for compute ID --- .../api/controller/compute_handler.py | 28 +++++++++---------- tests/handlers/api/controller/test_compute.py | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gns3server/handlers/api/controller/compute_handler.py b/gns3server/handlers/api/controller/compute_handler.py index 46aaaff3..0037ea3c 100644 --- a/gns3server/handlers/api/controller/compute_handler.py +++ b/gns3server/handlers/api/controller/compute_handler.py @@ -60,20 +60,6 @@ class ComputeHandler: controller = Controller.instance() response.json([c for c in controller.computes.values()]) - @classmethod - @Route.get( - r"/computes/{compute_id}", - description="Get a compute node informations", - status_codes={ - 200: "Compute list" - }, - output=COMPUTE_OBJECT_SCHEMA) - def get(request, response): - - controller = Controller.instance() - compute = controller.get_compute(request.match_info["compute_id"]) - response.json(compute) - @classmethod @Route.post( r"/computes/shutdown", @@ -110,3 +96,17 @@ class ComputeHandler: server = WebServer.instance() asyncio.async(server.shutdown_server()) response.set_status(201) + + @classmethod + @Route.get( + r"/computes/{compute_id:.+}", + description="Get a compute node informations", + status_codes={ + 200: "Compute list" + }, + output=COMPUTE_OBJECT_SCHEMA) + def get(request, response): + + controller = Controller.instance() + compute = controller.get_compute(request.match_info["compute_id"]) + response.json(compute) diff --git a/tests/handlers/api/controller/test_compute.py b/tests/handlers/api/controller/test_compute.py index 3c49a698..8639a1df 100644 --- a/tests/handlers/api/controller/test_compute.py +++ b/tests/handlers/api/controller/test_compute.py @@ -39,7 +39,7 @@ def test_compute_create(http_controller, controller): def test_compute_get(http_controller, controller): params = { - "compute_id": "my_compute_id", + "compute_id": "my_compute/id", "protocol": "http", "host": "example.com", "port": 84, @@ -49,7 +49,7 @@ def test_compute_get(http_controller, controller): response = http_controller.post("/computes", params) assert response.status == 201 - response = http_controller.get("/computes/my_compute_id", example=True) + response = http_controller.get("/computes/my_compute/id", example=True) assert response.status == 200 assert response.json["protocol"] == "http"