Implement an api call for computing the IDLE PC

Fix https://github.com/GNS3/gns3-gui/pull/2153
This commit is contained in:
Julien Duponchelle committed 2017-07-07 17:50:40 +02:00
1 parent dc7a9ffc51
commit 3eadbb9adb
5 files changed
+72

No files matched your search

+21
View File
@@ -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
+1
View File
@@ -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))