mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Manage error when GNS3VM failed to start
Fix https://github.com/GNS3/gns3-gui/issues/1446
This commit is contained in:
7 files changed
+101
-12
No files matched your search
@@ -334,6 +334,9 @@ class Compute:
|
||||
@asyncio.coroutine
|
||||
def http_query(self, method, path, data=None, **kwargs):
|
||||
if not self._connected:
|
||||
if self._id == "vm" and not self._controller.gns3vm.running:
|
||||
yield from self._controller.gns3vm.start()
|
||||
|
||||
yield from self.connect()
|
||||
if not self._connected:
|
||||
raise aiohttp.web.HTTPConflict(text="Can't connect to {}".format(self._name))
|
||||
|
||||
@@ -19,9 +19,11 @@ import sys
|
||||
import copy
|
||||
import asyncio
|
||||
|
||||
from ...utils.asyncio import locked_coroutine
|
||||
from .vmware_gns3_vm import VMwareGNS3VM
|
||||
from .virtualbox_gns3_vm import VirtualBoxGNS3VM
|
||||
from .remote_gns3_vm import RemoteGNS3VM
|
||||
from .gns3_vm_error import GNS3VMError
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -212,8 +214,14 @@ class GNS3VM:
|
||||
Auto start the GNS3 VM if require
|
||||
"""
|
||||
if self.enable:
|
||||
yield from self._start()
|
||||
|
||||
try:
|
||||
yield from self.start()
|
||||
except GNS3VMError as e:
|
||||
# User will receive the error later when they will try to use the node
|
||||
yield from self._controller.add_compute(compute_id="vm",
|
||||
name="GNS3 VM ({})".format(self._current_engine().vmname),
|
||||
host=None,
|
||||
force=True)
|
||||
@asyncio.coroutine
|
||||
def auto_stop_vm(self):
|
||||
if self.enable and self.auto_stop:
|
||||
@@ -222,8 +230,8 @@ class GNS3VM:
|
||||
except GNS3VMError as e:
|
||||
log.warn(str(e))
|
||||
|
||||
@asyncio.coroutine
|
||||
def _start(self):
|
||||
@locked_coroutine
|
||||
def start(self):
|
||||
"""
|
||||
Start the GNS3 VM
|
||||
"""
|
||||
@@ -232,7 +240,7 @@ class GNS3VM:
|
||||
log.info("Start the GNS3 VM")
|
||||
engine.vmname = self._settings["vmname"]
|
||||
yield from engine.start()
|
||||
yield from self._controller.add_compute(compute_id="vm",
|
||||
yield from self._controller.add_compute(compute_id="vm",
|
||||
name="GNS3 VM ({})".format(engine.vmname),
|
||||
protocol=self.protocol,
|
||||
host=self.ip_address,
|
||||
@@ -241,7 +249,7 @@ class GNS3VM:
|
||||
password=self.password,
|
||||
force=True)
|
||||
|
||||
@asyncio.coroutine
|
||||
@locked_coroutine
|
||||
def _stop(self):
|
||||
"""
|
||||
Stop the GNS3 VM
|
||||
|
||||
@@ -26,4 +26,4 @@ class GNS3VMError(Exception):
|
||||
return self._message
|
||||
|
||||
def __str__(self):
|
||||
return self._message
|
||||
return "GNS3VM: {}".format(self._message)
|
||||
@@ -114,7 +114,6 @@ class VMwareGNS3VM(BaseGNS3VM):
|
||||
args.extend(["nogui"])
|
||||
yield from self._execute("start", args)
|
||||
log.info("GNS3 VM has been started")
|
||||
self.running = True
|
||||
|
||||
# check if the VMware guest tools are installed
|
||||
vmware_tools_state = yield from self._execute("checkToolsState", [self._vmx_path])
|
||||
@@ -125,6 +124,7 @@ class VMwareGNS3VM(BaseGNS3VM):
|
||||
guest_ip_address = yield from self._execute("getGuestIPAddress", [self._vmx_path, "-wait"], timeout=120)
|
||||
self.ip_address = guest_ip_address
|
||||
log.info("GNS3 VM IP address set to {}".format(guest_ip_address))
|
||||
self.running = True
|
||||
|
||||
@asyncio.coroutine
|
||||
def stop(self):
|
||||
|
||||
Reference in new issue
Block a user