1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Fixes important issue when searching for a free port.

This commit is contained in:
Jeremy 2014-11-12 19:49:02 -07:00
parent f6561bf684
commit a9e924934a
3 changed files with 12 additions and 9 deletions

View File

@ -67,13 +67,10 @@ def find_unused_port(start_port, end_port, host='127.0.0.1', socket_type="TCP",
return port
except OSError as e:
last_exception = e
if e.errno == errno.EADDRINUSE or e.errno == errno.EACCES: # socket already in use or permission denied
if port + 1 == end_port:
break
else:
continue
if port + 1 == end_port:
break
else:
raise Exception("Could not find an unused port between {} and {} on host {}: {}".format(start_port, end_port, host, e))
continue
raise Exception("Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port, end_port, host, last_exception))

View File

@ -157,7 +157,10 @@ class Dynamips(IModule):
# automatically save configs for all router instances
for router_id in self._routers:
router = self._routers[router_id]
router.save_configs()
try:
router.save_configs()
except DynamipsError:
continue
# stop all Dynamips hypervisors
if self._hypervisor_manager:
@ -232,7 +235,10 @@ class Dynamips(IModule):
# automatically save configs for all router instances
for router_id in self._routers:
router = self._routers[router_id]
router.save_configs()
try:
router.save_configs()
except DynamipsError:
continue
# stop all Dynamips hypervisors
if self._hypervisor_manager:

View File

@ -715,7 +715,7 @@ class QemuVM(object):
# create a "FLASH" with 256MB if no disk image has been specified
hda_disk = os.path.join(self._working_dir, "flash.qcow2")
if not os.path.exists(hda_disk):
retcode = subprocess.call([qemu_img_path, "create", "-f", "qcow2", hda_disk, "256M"])
retcode = subprocess.call([qemu_img_path, "create", "-f", "qcow2", hda_disk, "128M"])
log.info("{} returned with {}".format(qemu_img_path, retcode))
except OSError as e: