1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Merge branch 'ehlers-docker-init' into 1.5

This commit is contained in:
Julien Duponchelle 2016-03-04 09:09:09 +01:00
commit 60e9241857
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D
3 changed files with 28 additions and 15 deletions

View File

@ -195,16 +195,22 @@ class DockerVM(BaseVM):
},
"Volumes": {},
"Env": [],
"Cmd": image_infos.get("ContainerConfig", {"Cmd": []})["Cmd"]
"Cmd": [],
"Entrypoint": image_infos.get("Config", {"Entrypoint": []})["Entrypoint"]
}
params["Cmd"].insert(0, "/bin/sh")
params["Cmd"].insert(1, "/gns3/init.sh")
if params["Entrypoint"] is None:
params["Entrypoint"] = []
if self._start_command:
params["Cmd"] += shlex.split(self._start_command)
else:
if len(params["Cmd"]) == 2:
params["Cmd"] += ["/bin/sh"]
params["Cmd"] = shlex.split(self._start_command)
if len(params["Cmd"]) == 0:
params["Cmd"] = image_infos.get("Config", {"Cmd": []})["Cmd"]
if params["Cmd"] is None:
params["Cmd"] = []
if len(params["Cmd"]) == 0 and len(params["Entrypoint"]) == 0:
params["Cmd"] = ["/bin/sh"]
params["Entrypoint"].insert(0, "/gns3/init.sh")
if self._environment:
params["Env"] += [e.strip() for e in self._environment.split("\n")]

2
gns3server/modules/docker/resources/init.sh Normal file → Executable file
View File

@ -43,4 +43,4 @@ sed -n 's/^ *\(eth[0-9]*\):.*/\1/p' < /proc/net/dev | while read dev; do
done
# continue normal docker startup
/bin/sh -c "$@"
exec "$@"

View File

@ -98,7 +98,8 @@ def test_create(loop, project, manager):
"Hostname": "test",
"Image": "ubuntu",
"Env": [],
"Cmd": ["/bin/sh", "/gns3/init.sh", "/bin/sh"]
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"]
})
assert vm._cid == "e90e34656806"
@ -135,7 +136,8 @@ def test_create_vnc(loop, project, manager):
"Hostname": "test",
"Image": "ubuntu",
"Env": ['DISPLAY=:42'],
"Cmd": ["/bin/sh", "/gns3/init.sh", "/bin/sh"]
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"]
})
assert vm._start_vnc.called
assert vm._cid == "e90e34656806"
@ -163,7 +165,8 @@ def test_create_start_cmd(loop, project, manager):
"Privileged": True
},
"Volumes": {},
"Cmd": ["/bin/sh", "/gns3/init.sh", "/bin/ls"],
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/ls"],
"NetworkDisabled": True,
"Name": "test",
"Hostname": "test",
@ -200,7 +203,8 @@ def test_create_environment(loop, project, manager):
"Name": "test",
"Hostname": "test",
"Image": "ubuntu",
"Cmd": ["/bin/sh", "/gns3/init.sh", "/bin/sh"]
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"]
})
assert vm._cid == "e90e34656806"
@ -246,7 +250,8 @@ def test_create_image_not_available(loop, project, manager):
"Hostname": "test",
"Image": "ubuntu",
"Env": [],
"Cmd": ["/bin/sh", "/gns3/init.sh", "/bin/sh"]
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"]
})
assert vm._cid == "e90e34656806"
mock_pull.assert_called_with("ubuntu")
@ -456,7 +461,8 @@ def test_update(loop, vm):
"Hostname": "test",
"Image": "ubuntu",
"Env": [],
"Cmd": ["/bin/sh", "/gns3/init.sh", "/bin/sh"]
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"]
})
assert vm.console == original_console
@ -493,7 +499,8 @@ def test_update_running(loop, vm):
"Hostname": "test",
"Image": "ubuntu",
"Env": [],
"Cmd": ["/bin/sh", "/gns3/init.sh", "/bin/sh"]
"Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"]
})
assert vm.console == original_console