1
0
mirror of https://github.com/GNS3/gns3-server synced 2025-01-11 16:41:04 +00:00

Fixes connect call failed for Dynamips hypervisor #78.

This commit is contained in:
grossmj 2015-03-01 14:25:09 -07:00
parent 7223005acd
commit 518b037d54

View File

@ -73,12 +73,20 @@ class DynamipsHypervisor:
else:
host = self._host
try:
self._reader, self._writer = yield from asyncio.wait_for(asyncio.open_connection(host, self._port), timeout=self._timeout)
except OSError as e:
raise DynamipsError("Could not connect to hypervisor {}:{} {}".format(host, self._port, e))
except asyncio.TimeoutError:
raise DynamipsError("Timeout error while connecting to hypervisor {}:{}".format(host, self._port))
tries = 3
while tries > 0:
try:
self._reader, self._writer = yield from asyncio.wait_for(asyncio.open_connection(host, self._port), timeout=self._timeout)
break
except OSError as e:
if tries:
tries -= 1
log.warn("Could not connect to hypervisor {}:{} {}, retrying...".format(host, self._port, e))
yield from asyncio.sleep(0.1)
continue
raise DynamipsError("Could not connect to hypervisor {}:{} {}".format(host, self._port, e))
except asyncio.TimeoutError:
raise DynamipsError("Timeout error while connecting to hypervisor {}:{}".format(host, self._port))
try:
version = yield from self.send("hypervisor version")