|
|
@ -25,10 +25,8 @@ from tests.utils import asyncio_patch, AsyncioMagicMock
|
|
|
|
|
|
|
|
|
|
|
|
from gns3server.ubridge.ubridge_error import UbridgeNamespaceError
|
|
|
|
from gns3server.ubridge.ubridge_error import UbridgeNamespaceError
|
|
|
|
from gns3server.compute.docker.docker_vm import DockerVM
|
|
|
|
from gns3server.compute.docker.docker_vm import DockerVM
|
|
|
|
from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error, DockerHttp304Error
|
|
|
|
from gns3server.compute.docker.docker_error import DockerError, DockerHttp404Error
|
|
|
|
from gns3server.compute.docker import Docker
|
|
|
|
from gns3server.compute.docker import Docker
|
|
|
|
from gns3server.utils.get_resource import get_resource
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from unittest.mock import patch, MagicMock, call
|
|
|
|
from unittest.mock import patch, MagicMock, call
|
|
|
|
|
|
|
|
|
|
|
@ -101,7 +99,7 @@ async def test_create(compute_project, manager):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -139,7 +137,7 @@ async def test_create_with_tag(compute_project, manager):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -180,7 +178,7 @@ async def test_create_vnc(compute_project, manager):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"/tmp/.X11-unix/X{0}:/tmp/.X11-unix/X{0}:ro".format(vm._display)
|
|
|
|
"/tmp/.X11-unix/X{0}:/tmp/.X11-unix/X{0}:ro".format(vm._display)
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -310,7 +308,7 @@ async def test_create_start_cmd(compute_project, manager):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -408,7 +406,7 @@ async def test_create_image_not_available(compute_project, manager):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -451,7 +449,7 @@ async def test_create_with_user(compute_project, manager):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -533,7 +531,7 @@ async def test_create_with_extra_volumes_duplicate_1_image(compute_project, mana
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/vol/1".format(os.path.join(vm.working_dir, "vol", "1")),
|
|
|
|
"{}:/gns3volumes/vol/1".format(os.path.join(vm.working_dir, "vol", "1")),
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -572,7 +570,7 @@ async def test_create_with_extra_volumes_duplicate_2_user(compute_project, manag
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/vol/1".format(os.path.join(vm.working_dir, "vol", "1")),
|
|
|
|
"{}:/gns3volumes/vol/1".format(os.path.join(vm.working_dir, "vol", "1")),
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -611,7 +609,7 @@ async def test_create_with_extra_volumes_duplicate_3_subdir(compute_project, man
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/vol".format(os.path.join(vm.working_dir, "vol")),
|
|
|
|
"{}:/gns3volumes/vol".format(os.path.join(vm.working_dir, "vol")),
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -650,7 +648,7 @@ async def test_create_with_extra_volumes_duplicate_4_backslash(compute_project,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/vol".format(os.path.join(vm.working_dir, "vol")),
|
|
|
|
"{}:/gns3volumes/vol".format(os.path.join(vm.working_dir, "vol")),
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -689,7 +687,7 @@ async def test_create_with_extra_volumes_duplicate_5_subdir_issue_1595(compute_p
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc".format(os.path.join(vm.working_dir, "etc")),
|
|
|
|
"{}:/gns3volumes/etc".format(os.path.join(vm.working_dir, "etc")),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -727,7 +725,7 @@ async def test_create_with_extra_volumes_duplicate_6_subdir_issue_1595(compute_p
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc".format(os.path.join(vm.working_dir, "etc")),
|
|
|
|
"{}:/gns3volumes/etc".format(os.path.join(vm.working_dir, "etc")),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -771,7 +769,7 @@ async def test_create_with_extra_volumes(compute_project, manager):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/vol/1".format(os.path.join(vm.working_dir, "vol", "1")),
|
|
|
|
"{}:/gns3volumes/vol/1".format(os.path.join(vm.working_dir, "vol", "1")),
|
|
|
|
"{}:/gns3volumes/vol/2".format(os.path.join(vm.working_dir, "vol", "2")),
|
|
|
|
"{}:/gns3volumes/vol/2".format(os.path.join(vm.working_dir, "vol", "2")),
|
|
|
@ -996,7 +994,7 @@ async def test_update(vm):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -1064,7 +1062,7 @@ async def test_update_running(vm):
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"CapAdd": ["ALL"],
|
|
|
|
"Binds": [
|
|
|
|
"Binds": [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network"))
|
|
|
|
],
|
|
|
|
],
|
|
|
|
"Privileged": True
|
|
|
|
"Privileged": True
|
|
|
@ -1325,7 +1323,7 @@ async def test_mount_binds(vm):
|
|
|
|
|
|
|
|
|
|
|
|
dst = os.path.join(vm.working_dir, "test/experimental")
|
|
|
|
dst = os.path.join(vm.working_dir, "test/experimental")
|
|
|
|
assert vm._mount_binds(image_infos) == [
|
|
|
|
assert vm._mount_binds(image_infos) == [
|
|
|
|
"{}:/gns3:ro".format(get_resource("compute/docker/resources")),
|
|
|
|
"{}:/gns3:ro".format(Docker.resources_path()),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes/etc/network".format(os.path.join(vm.working_dir, "etc", "network")),
|
|
|
|
"{}:/gns3volumes{}".format(dst, "/test/experimental")
|
|
|
|
"{}:/gns3volumes{}".format(dst, "/test/experimental")
|
|
|
|
]
|
|
|
|
]
|
|
|
|