mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
parent
fd18458588
commit
2d42f32d71
@ -189,11 +189,15 @@ class DockerVM(BaseVM):
|
||||
"""
|
||||
Destroy an recreate the container with the new settings
|
||||
"""
|
||||
# We need to save the console port and restore it
|
||||
# We need to save the console and state and restore it
|
||||
console = self.console
|
||||
state = yield from self._get_container_state()
|
||||
|
||||
yield from self.remove()
|
||||
yield from self.create()
|
||||
self.console = console
|
||||
if state == "running":
|
||||
yield from self.start()
|
||||
|
||||
@asyncio.coroutine
|
||||
def start(self):
|
||||
|
@ -392,6 +392,43 @@ def test_update(loop, vm):
|
||||
assert vm.console == original_console
|
||||
|
||||
|
||||
def test_update_running(loop, vm):
|
||||
|
||||
response = {
|
||||
"Id": "e90e34656806",
|
||||
"Warnings": []
|
||||
}
|
||||
|
||||
original_console = vm.console
|
||||
vm.start = MagicMock()
|
||||
|
||||
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="running"):
|
||||
with asyncio_patch("gns3server.modules.docker.Docker.query", return_value=response) as mock_query:
|
||||
loop.run_until_complete(asyncio.async(vm.update()))
|
||||
|
||||
mock_query.assert_any_call("DELETE", "containers/e90e34656842", params={"force": 1})
|
||||
mock_query.assert_any_call("POST", "containers/create", data={
|
||||
"Tty": True,
|
||||
"OpenStdin": True,
|
||||
"StdinOnce": False,
|
||||
"HostConfig":
|
||||
{
|
||||
"CapAdd": ["ALL"],
|
||||
"Binds": [],
|
||||
"Privileged": True
|
||||
},
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Name": "test",
|
||||
"Hostname": "test",
|
||||
"Image": "ubuntu"
|
||||
})
|
||||
|
||||
assert vm.console == original_console
|
||||
assert vm.start.called
|
||||
|
||||
|
||||
def test_remove(loop, vm):
|
||||
|
||||
with asyncio_patch("gns3server.modules.docker.DockerVM._get_container_state", return_value="stopped"):
|
||||
|
Loading…
Reference in New Issue
Block a user