mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
Change address/host binding implementation.
This commit is contained in:
1 parent
862448ada1
commit
3edbdbe0b5
6 files changed
+35
-17
No files matched your search
@@ -115,7 +115,7 @@ class Dynamips(IModule):
|
||||
self._tempdir = kwargs["temp_dir"]
|
||||
self._working_dir = self._projects_dir
|
||||
self._dynamips = ""
|
||||
self._default_host = "127.0.0.1"
|
||||
self._host = kwargs["host"]
|
||||
|
||||
if not sys.platform.startswith("win32"):
|
||||
#FIXME: pickle issues Windows
|
||||
@@ -216,7 +216,7 @@ class Dynamips(IModule):
|
||||
raise DynamipsError("Cannot write to working directory {}".format(self._working_dir))
|
||||
|
||||
log.info("starting the hypervisor manager with Dynamips working directory set to '{}'".format(self._working_dir))
|
||||
self._hypervisor_manager = HypervisorManager(self._dynamips, self._working_dir, self._default_host)
|
||||
self._hypervisor_manager = HypervisorManager(self._dynamips, self._working_dir, self._host)
|
||||
|
||||
for name, value in self._hypervisor_manager_settings.items():
|
||||
if hasattr(self._hypervisor_manager, name) and getattr(self._hypervisor_manager, name) != value:
|
||||
|
||||
@@ -67,8 +67,17 @@ class DynamipsHypervisor(object):
|
||||
Connects to the hypervisor.
|
||||
"""
|
||||
|
||||
# connect to a local address by default
|
||||
# if listening to all addresses (IPv4 or IPv6)
|
||||
if self._host == "0.0.0.0":
|
||||
host = "127.0.0.1"
|
||||
elif self._host == "::":
|
||||
host = "::1"
|
||||
else:
|
||||
host = self._host
|
||||
|
||||
try:
|
||||
self._socket = socket.create_connection((self._host,
|
||||
self._socket = socket.create_connection((host,
|
||||
self._port),
|
||||
self._timeout)
|
||||
except OSError as e:
|
||||
|
||||
@@ -406,6 +406,13 @@ class HypervisorManager(object):
|
||||
:param timeout: timeout value (default is 10 seconds)
|
||||
"""
|
||||
|
||||
# connect to a local address by default
|
||||
# if listening to all addresses (IPv4 or IPv6)
|
||||
if host == "0.0.0.0":
|
||||
host = "127.0.0.1"
|
||||
elif host == "::":
|
||||
host = "::1"
|
||||
|
||||
connection_success = False
|
||||
begin = time.time()
|
||||
# try to connect for 10 seconds
|
||||
@@ -423,7 +430,7 @@ class HypervisorManager(object):
|
||||
if not connection_success:
|
||||
# FIXME: throw exception here
|
||||
log.critical("Couldn't connect to hypervisor on {}:{} :{}".format(host, port,
|
||||
last_exception))
|
||||
last_exception))
|
||||
else:
|
||||
log.info("Dynamips server ready after {:.4f} seconds".format(time.time() - begin))
|
||||
|
||||
|
||||
Reference in new issue
Block a user