mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Implement an api call for computing the IDLE PC
Fix https://github.com/GNS3/gns3-gui/pull/2153
This commit is contained in:
5 files changed
+72
No files matched your search
@@ -597,3 +597,24 @@ class Controller:
|
||||
if not hasattr(Controller, '_instance') or Controller._instance is None:
|
||||
Controller._instance = Controller()
|
||||
return Controller._instance
|
||||
|
||||
@asyncio.coroutine
|
||||
def autoidlepc(self, compute_id, platform, image):
|
||||
"""
|
||||
Compute and IDLE PC value for an image
|
||||
|
||||
:param compute_id: ID of the compute where the idlepc operation need to run
|
||||
:param platform: Platform type
|
||||
:param image: Image to use
|
||||
"""
|
||||
compute = self.get_compute(compute_id)
|
||||
for project in list(self._projects.values()):
|
||||
if project.name == "AUTOIDLEPC":
|
||||
yield from project.delete()
|
||||
self.remove_project(project)
|
||||
project = yield from self.add_project(name="AUTOIDLEPC")
|
||||
node = yield from project.add_node(compute, "AUTOIDLEPC", str(uuid.uuid4()), node_type="dynamips", platform=platform, image=image, ram=512)
|
||||
res = yield from node.dynamips_auto_idlepc()
|
||||
yield from project.delete()
|
||||
self.remove_project(project)
|
||||
return res
|
||||
@@ -665,3 +665,4 @@ class Compute:
|
||||
return (this_interface["ip_address"], other_interface["ip_address"])
|
||||
|
||||
raise ValueError("No common subnet for compute {} and {}".format(self.name, other_compute.name))
|
||||
|
||||
@@ -154,3 +154,18 @@ class ComputeHandler:
|
||||
controller = Controller.instance()
|
||||
yield from controller.delete_compute(request.match_info["compute_id"])
|
||||
response.set_status(204)
|
||||
|
||||
@Route.post(
|
||||
r"/computes/{compute_id}/autoidlepc",
|
||||
parameters={
|
||||
"compute_id": "Compute UUID"
|
||||
},
|
||||
status_codes={
|
||||
200: "Idle PC computed",
|
||||
},
|
||||
description="Compute IDLE PC value")
|
||||
def autoidlepc(request, response):
|
||||
controller = Controller.instance()
|
||||
res = yield from controller.autoidlepc(request.match_info["compute_id"], request.json["platform"], request.json["image"])
|
||||
response.set_status(200)
|
||||
response.json(res)
|
||||
Reference in new issue
Block a user