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

Export the list of volumes to a env variable accessible in the container

Ref #550
This commit is contained in:
Julien Duponchelle 2016-06-01 11:39:42 +02:00
parent d3436756b2
commit ae687346f1
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 20 additions and 10 deletions

View File

@ -294,6 +294,8 @@ class DockerVM(BaseVM):
# Give the information to the container on how many interface should be inside # Give the information to the container on how many interface should be inside
params["Env"].append("GNS3_MAX_ETHERNET=eth{}".format(self.adapters - 1)) params["Env"].append("GNS3_MAX_ETHERNET=eth{}".format(self.adapters - 1))
# Give the information to the container the list of volume path mounted
params["Env"].append("GNS3_VOLUMES={}".format(":".join(self._volumes)))
if self._environment: if self._environment:
params["Env"] += [e.strip() for e in self._environment.split("\n")] params["Env"] += [e.strip() for e in self._environment.split("\n")]

View File

@ -104,7 +104,8 @@ def test_create(loop, project, manager):
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest", "Image": "ubuntu:latest",
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0" "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network"
], ],
"Entrypoint": ["/gns3/init.sh"], "Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"] "Cmd": ["/bin/sh"]
@ -141,7 +142,8 @@ def test_create_with_tag(loop, project, manager):
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest:16.04", "Image": "ubuntu:latest:16.04",
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0" "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network"
], ],
"Entrypoint": ["/gns3/init.sh"], "Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"] "Cmd": ["/bin/sh"]
@ -183,6 +185,7 @@ def test_create_vnc(loop, project, manager):
"Image": "ubuntu:latest", "Image": "ubuntu:latest",
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0", "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network",
"DISPLAY=:42" "DISPLAY=:42"
], ],
"Entrypoint": ["/gns3/init.sh"], "Entrypoint": ["/gns3/init.sh"],
@ -225,7 +228,8 @@ def test_create_start_cmd(loop, project, manager):
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest", "Image": "ubuntu:latest",
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0" "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network"
] ]
}) })
assert vm._cid == "e90e34656806" assert vm._cid == "e90e34656806"
@ -257,6 +261,7 @@ def test_create_environment(loop, project, manager):
}, },
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0", "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network",
"YES=1", "YES=1",
"NO=0" "NO=0"
], ],
@ -315,7 +320,8 @@ def test_create_image_not_available(loop, project, manager):
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest", "Image": "ubuntu:latest",
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0" "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network"
], ],
"Entrypoint": ["/gns3/init.sh"], "Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"] "Cmd": ["/bin/sh"]
@ -534,7 +540,8 @@ def test_update(loop, vm):
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest", "Image": "ubuntu:latest",
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0" "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network"
], ],
"Entrypoint": ["/gns3/init.sh"], "Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"] "Cmd": ["/bin/sh"]
@ -601,7 +608,8 @@ def test_update_running(loop, vm):
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest", "Image": "ubuntu:latest",
"Env": [ "Env": [
"GNS3_MAX_ETHERNET=eth0" "GNS3_MAX_ETHERNET=eth0",
"GNS3_VOLUMES=/etc/network"
], ],
"Entrypoint": ["/gns3/init.sh"], "Entrypoint": ["/gns3/init.sh"],
"Cmd": ["/bin/sh"] "Cmd": ["/bin/sh"]