1
0
mirror of https://github.com/GNS3/gns3-server synced 2025-01-11 16:41:04 +00:00

Support all characters for compute ID

This commit is contained in:
Julien Duponchelle 2016-05-12 16:41:05 +02:00
parent b46a0ff4ae
commit d43e78a1d7
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 16 additions and 16 deletions

View File

@ -60,20 +60,6 @@ class ComputeHandler:
controller = Controller.instance() controller = Controller.instance()
response.json([c for c in controller.computes.values()]) 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 @classmethod
@Route.post( @Route.post(
r"/computes/shutdown", r"/computes/shutdown",
@ -110,3 +96,17 @@ class ComputeHandler:
server = WebServer.instance() server = WebServer.instance()
asyncio.async(server.shutdown_server()) asyncio.async(server.shutdown_server())
response.set_status(201) 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)

View File

@ -39,7 +39,7 @@ def test_compute_create(http_controller, controller):
def test_compute_get(http_controller, controller): def test_compute_get(http_controller, controller):
params = { params = {
"compute_id": "my_compute_id", "compute_id": "my_compute/id",
"protocol": "http", "protocol": "http",
"host": "example.com", "host": "example.com",
"port": 84, "port": 84,
@ -49,7 +49,7 @@ def test_compute_get(http_controller, controller):
response = http_controller.post("/computes", params) response = http_controller.post("/computes", params)
assert response.status == 201 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.status == 200
assert response.json["protocol"] == "http" assert response.json["protocol"] == "http"