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:
parent
9f6f830418
commit
a3495304ad
@ -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))
|
||||||
|
|
||||||
|
@ -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)))
|
||||||
|
Loading…
Reference in New Issue
Block a user