1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-14 12:29:02 +00:00

Code cleanup for docker interface creation

Fix #819

Signed-off-by: Julien Duponchelle <julien@gns3.net>
This commit is contained in:
Bernhard Ehlers 2016-12-13 16:05:38 +01:00 committed by Julien Duponchelle
parent 9f6f830418
commit a3495304ad
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 3 additions and 4 deletions

View File

@ -642,11 +642,10 @@ class DockerVM(BaseNode):
adapter_number=adapter_number)) adapter_number=adapter_number))
for index in range(4096): for index in range(4096):
if "veth-gns3-e{}".format(index) not in psutil.net_if_addrs(): if "tap-gns3-e{}".format(index) not in psutil.net_if_addrs():
adapter.ifc = "eth{}".format(str(index))
adapter.host_ifc = "tap-gns3-e{}".format(str(index)) adapter.host_ifc = "tap-gns3-e{}".format(str(index))
break break
if not hasattr(adapter, "ifc"): if adapter.host_ifc is None:
raise DockerError("Adapter {adapter_number} couldn't allocate interface on Docker container '{name}'. Too many Docker interfaces already exists".format(name=self.name, raise DockerError("Adapter {adapter_number} couldn't allocate interface on Docker container '{name}'. Too many Docker interfaces already exists".format(name=self.name,
adapter_number=adapter_number)) adapter_number=adapter_number))

View File

@ -742,7 +742,7 @@ def test_add_ubridge_connection_no_free_interface(loop, vm):
with pytest.raises(DockerError): with pytest.raises(DockerError):
# We create fake ethernet interfaces for docker # We create fake ethernet interfaces for docker
interfaces = ["veth-gns3-e{}".format(index) for index in range(4096)] interfaces = ["tap-gns3-e{}".format(index) for index in range(4096)]
with patch("psutil.net_if_addrs", return_value=interfaces): with patch("psutil.net_if_addrs", return_value=interfaces):
loop.run_until_complete(asyncio.async(vm._add_ubridge_connection(nio, 0, 42))) loop.run_until_complete(asyncio.async(vm._add_ubridge_connection(nio, 0, 42)))