mirror of
https://github.com/GNS3/gns3-server
synced 2025-05-31 05:08:50 +00:00
Fixes important issue when searching for a free port.
This commit is contained in:
parent
f6561bf684
commit
a9e924934a
@ -67,13 +67,10 @@ def find_unused_port(start_port, end_port, host='127.0.0.1', socket_type="TCP",
|
|||||||
return port
|
return port
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
last_exception = 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:
|
||||||
if port + 1 == end_port:
|
break
|
||||||
break
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
else:
|
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))
|
raise Exception("Could not find a free port between {} and {} on host {}, last exception: {}".format(start_port, end_port, host, last_exception))
|
||||||
|
|
||||||
|
@ -157,7 +157,10 @@ class Dynamips(IModule):
|
|||||||
# automatically save configs for all router instances
|
# automatically save configs for all router instances
|
||||||
for router_id in self._routers:
|
for router_id in self._routers:
|
||||||
router = self._routers[router_id]
|
router = self._routers[router_id]
|
||||||
router.save_configs()
|
try:
|
||||||
|
router.save_configs()
|
||||||
|
except DynamipsError:
|
||||||
|
continue
|
||||||
|
|
||||||
# stop all Dynamips hypervisors
|
# stop all Dynamips hypervisors
|
||||||
if self._hypervisor_manager:
|
if self._hypervisor_manager:
|
||||||
@ -232,7 +235,10 @@ class Dynamips(IModule):
|
|||||||
# automatically save configs for all router instances
|
# automatically save configs for all router instances
|
||||||
for router_id in self._routers:
|
for router_id in self._routers:
|
||||||
router = self._routers[router_id]
|
router = self._routers[router_id]
|
||||||
router.save_configs()
|
try:
|
||||||
|
router.save_configs()
|
||||||
|
except DynamipsError:
|
||||||
|
continue
|
||||||
|
|
||||||
# stop all Dynamips hypervisors
|
# stop all Dynamips hypervisors
|
||||||
if self._hypervisor_manager:
|
if self._hypervisor_manager:
|
||||||
|
@ -715,7 +715,7 @@ class QemuVM(object):
|
|||||||
# create a "FLASH" with 256MB if no disk image has been specified
|
# create a "FLASH" with 256MB if no disk image has been specified
|
||||||
hda_disk = os.path.join(self._working_dir, "flash.qcow2")
|
hda_disk = os.path.join(self._working_dir, "flash.qcow2")
|
||||||
if not os.path.exists(hda_disk):
|
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))
|
log.info("{} returned with {}".format(qemu_img_path, retcode))
|
||||||
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user