Better management of the GNS3 VM with VirtualBox

pull/712/head
Julien Duponchelle 8 years ago
parent 896d279ded
commit 4cd164fc24
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

@ -60,7 +60,8 @@ class GNS3VM:
"engine_id": "vmware",
"description": 'VMware is the recommended choice for best performances.<br>The GNS3 VM can be <a href="{}">downloaded here</a>.'.format(download_url),
"support_when_exit": True,
"support_headless": True
"support_headless": True,
"support_ram": True
}
if sys.platform.startswith("darwin"):
vmware_informations["name"] = "VMware Fusion"
@ -73,7 +74,8 @@ class GNS3VM:
"name": "VirtualBox",
"description": 'VirtualBox doesn\'t support nested virtualization, this means running Qemu based VM could be very slow.<br>The GNS3 VM can be <a href="{}">downloaded here</a>'.format(download_url),
"support_when_exit": True,
"support_headless": True
"support_headless": True,
"support_ram": True
}
remote_informations = {
@ -81,7 +83,8 @@ class GNS3VM:
"name": "Remote",
"description": "Use a remote GNS3 server as the GNS3 VM.",
"support_when_exit": False,
"support_headless": False
"support_headless": False,
"support_ram": False
}
return [
@ -185,7 +188,7 @@ class GNS3VM:
else:
# When user fix something on his system and try again
if not self._current_engine().running and self.enable:
yield from self.auto_start_vm()
yield from self.start()
def _get_engine(self, engine):
"""

@ -243,7 +243,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
if json_data:
for interface in json_data:
if "name" in interface and interface["name"] == "eth{}".format(hostonly_interface_number - 1):
if "ip_address" in interface:
if "ip_address" in interface and len(interface["ip_address"]) > 0:
return interface["ip_address"]
remaining_try -= 1
yield from asyncio.sleep(1)
@ -265,7 +265,27 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
Stops the GNS3 VM.
"""
vm_state = yield from self._get_state()
if vm_state == "poweroff":
self.running = False
return
yield from self._execute("controlvm", [self._vmname, "acpipowerbutton"], timeout=3)
trial = 120
while True:
try:
vm_state = yield from self._get_state()
# During a small amount of time the command will fail
except GNS3VMError:
vm_state = "running"
if vm_state == "poweroff":
break
trial -= 1
if trial == 0:
yield from self._execute("controlvm", [self._vmname, "poweroff"], timeout=3)
break
yield from asyncio.sleep(1)
log.info("GNS3 VM has been stopped")
self.running = False

Loading…
Cancel
Save