From 01e2fcf225892eabb4a7018de9f9ac107dc11a07 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Fri, 12 Feb 2016 16:38:16 +0100 Subject: [PATCH] Fix docker console port lost during update Fix https://github.com/GNS3/gns3-gui/issues/1026 --- gns3server/modules/docker/docker_vm.py | 3 +++ tests/modules/docker/test_docker_vm.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/gns3server/modules/docker/docker_vm.py b/gns3server/modules/docker/docker_vm.py index cb6a161d..2050d6da 100644 --- a/gns3server/modules/docker/docker_vm.py +++ b/gns3server/modules/docker/docker_vm.py @@ -184,8 +184,11 @@ class DockerVM(BaseVM): """ Destroy an recreate the container with the new settings """ + # We need to save the console port and restore it + console = self.console yield from self.remove() yield from self.create() + self.console = console @asyncio.coroutine def start(self): diff --git a/tests/modules/docker/test_docker_vm.py b/tests/modules/docker/test_docker_vm.py index 67d7d92c..238cd6c0 100644 --- a/tests/modules/docker/test_docker_vm.py +++ b/tests/modules/docker/test_docker_vm.py @@ -352,6 +352,9 @@ def test_update(loop, vm): "Id": "e90e34656806", "Warnings": [] } + + original_console = vm.console + with asyncio_patch("gns3server.modules.docker.Docker.list_images", return_value=[{"image": "ubuntu"}]) as mock_list_images: with asyncio_patch("gns3server.modules.docker.DockerVM._get_container_state", return_value="stopped"): with asyncio_patch("gns3server.modules.docker.Docker.query", return_value=response) as mock_query: @@ -373,6 +376,7 @@ def test_update(loop, vm): "Name": "test", "Image": "ubuntu" }) + assert vm.console == original_console def test_remove(loop, vm):