From a3495304add186c35291267ae5ad913ec0c90c6d Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Tue, 13 Dec 2016 16:05:38 +0100 Subject: [PATCH] Code cleanup for docker interface creation Fix #819 Signed-off-by: Julien Duponchelle --- gns3server/compute/docker/docker_vm.py | 5 ++--- tests/compute/docker/test_docker_vm.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gns3server/compute/docker/docker_vm.py b/gns3server/compute/docker/docker_vm.py index 063c9589..d8cd0dba 100644 --- a/gns3server/compute/docker/docker_vm.py +++ b/gns3server/compute/docker/docker_vm.py @@ -642,11 +642,10 @@ class DockerVM(BaseNode): adapter_number=adapter_number)) for index in range(4096): - if "veth-gns3-e{}".format(index) not in psutil.net_if_addrs(): - adapter.ifc = "eth{}".format(str(index)) + if "tap-gns3-e{}".format(index) not in psutil.net_if_addrs(): adapter.host_ifc = "tap-gns3-e{}".format(str(index)) 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, adapter_number=adapter_number)) diff --git a/tests/compute/docker/test_docker_vm.py b/tests/compute/docker/test_docker_vm.py index c2acdfed..cef3c15d 100644 --- a/tests/compute/docker/test_docker_vm.py +++ b/tests/compute/docker/test_docker_vm.py @@ -742,7 +742,7 @@ def test_add_ubridge_connection_no_free_interface(loop, vm): with pytest.raises(DockerError): # 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): loop.run_until_complete(asyncio.async(vm._add_ubridge_connection(nio, 0, 42)))