mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Support forwarding POST request to compute nodes
This commit is contained in:
4 files changed
+51
-8
No files matched your search
@@ -324,9 +324,9 @@ class Compute:
|
||||
return (yield from self.http_query("DELETE", path, **kwargs))
|
||||
|
||||
@asyncio.coroutine
|
||||
def forward(self, type, path):
|
||||
def forward(self, method, type, path, data=None):
|
||||
"""
|
||||
Forward a call to the emulator on compute
|
||||
"""
|
||||
res = yield from self.get("/{}/{}".format(type, path))
|
||||
res = yield from self.http_query(method, "/{}/{}".format(type, path), data=data)
|
||||
return res.json
|
||||
@@ -87,10 +87,26 @@ class ComputeHandler:
|
||||
404: "Instance doesn't exist"
|
||||
},
|
||||
description="Forward call specific to compute node. Read the full compute API for available actions")
|
||||
def forward(request, response):
|
||||
def get_forward(request, response):
|
||||
controller = Controller.instance()
|
||||
compute = controller.get_compute(request.match_info["compute_id"])
|
||||
images = yield from compute.forward(request.match_info["emulator"], request.match_info["action"])
|
||||
images = yield from compute.forward("GET", request.match_info["emulator"], request.match_info["action"])
|
||||
response.json(images)
|
||||
|
||||
@Route.post(
|
||||
r"/computes/{compute_id}/{emulator}/{action}",
|
||||
parameters={
|
||||
"compute_id": "Compute UUID"
|
||||
},
|
||||
status_codes={
|
||||
200: "OK",
|
||||
404: "Instance doesn't exist"
|
||||
},
|
||||
description="Forward call specific to compute node. Read the full compute API for available actions")
|
||||
def post_forward(request, response):
|
||||
controller = Controller.instance()
|
||||
compute = controller.get_compute(request.match_info["compute_id"])
|
||||
images = yield from compute.forward("POST", request.match_info["emulator"], request.match_info["action"], data=dict(request.json))
|
||||
response.json(images)
|
||||
|
||||
@Route.get(
|
||||
|
||||
Reference in new issue
Block a user