mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 12:57:56 +00:00
Merge branch 'ehlers-docker-init' into 1.5
This commit is contained in:
commit
60e9241857
@ -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
2
gns3server/modules/docker/resources/init.sh
Normal file → Executable 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 "$@"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user