mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge branch '2.2' into 3.0
# Conflicts: # .github/workflows/testing.yml # CHANGELOG # README.md # dev-requirements.txt # gns3server/compute/docker/docker_vm.py # gns3server/controller/export_project.py # gns3server/controller/import_project.py # gns3server/controller/project.py # gns3server/crash_report.py # gns3server/static/web-ui/index.html # gns3server/static/web-ui/main.df8c319a3da6fb0e3629.js # gns3server/version.py # requirements.txt # setup.py # tests/compute/docker/test_docker_vm.py # tests/controller/test_import_project.py
This commit is contained in:
24 files changed
+648
-312
No files matched your search
@@ -121,9 +121,9 @@ async def test_create(compute_project, manager):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -172,9 +172,9 @@ async def test_create_with_tag(compute_project, manager):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -232,9 +232,9 @@ async def test_create_vnc(compute_project, manager):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -378,9 +378,9 @@ async def test_create_start_cmd(compute_project, manager):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"Entrypoint": ["/gns3/init.sh"],
|
||||
"Cmd": ["/bin/ls"],
|
||||
@@ -491,9 +491,9 @@ async def test_create_image_not_available(compute_project, manager):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -547,9 +547,9 @@ async def test_create_with_user(compute_project, manager):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host",
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -651,9 +651,9 @@ async def test_create_with_extra_volumes_duplicate_1_image(compute_project, mana
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -707,9 +707,9 @@ async def test_create_with_extra_volumes_duplicate_2_user(compute_project, manag
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -763,9 +763,9 @@ async def test_create_with_extra_volumes_duplicate_3_subdir(compute_project, man
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -819,9 +819,9 @@ async def test_create_with_extra_volumes_duplicate_4_backslash(compute_project,
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -870,9 +870,9 @@ async def test_create_with_extra_volumes_duplicate_5_subdir_issue_1595(compute_p
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -921,9 +921,9 @@ async def test_create_with_extra_volumes_duplicate_6_subdir_issue_1595(compute_p
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -988,9 +988,9 @@ async def test_create_with_extra_volumes(compute_project, manager):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -1265,9 +1265,9 @@ async def test_update(vm):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
@@ -1347,9 +1347,9 @@ async def test_update_running(vm):
|
||||
],
|
||||
"Privileged": True,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0
|
||||
"NanoCpus": 0,
|
||||
"UsernsMode": "host"
|
||||
},
|
||||
"UsernsMode": "host",
|
||||
"Volumes": {},
|
||||
"NetworkDisabled": True,
|
||||
"Hostname": "test",
|
||||
|
||||
@@ -21,6 +21,7 @@ import json
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
import zipfile
|
||||
import stat
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
@@ -119,6 +120,8 @@ async def test_export(tmpdir, project):
|
||||
with open(os.path.join(path, "project-files", "snapshots", "test"), 'w+') as f:
|
||||
f.write("WORLD")
|
||||
|
||||
os.symlink("/tmp/anywhere", os.path.join(path, "vm-1", "dynamips", "symlink"))
|
||||
|
||||
with aiozipstream.ZipFile() as z:
|
||||
with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),):
|
||||
await export_project(z, project, str(tmpdir), include_images=False)
|
||||
@@ -134,9 +137,12 @@ async def test_export(tmpdir, project):
|
||||
assert 'vm-1/dynamips/empty-dir/' in myzip.namelist()
|
||||
assert 'project-files/snapshots/test' not in myzip.namelist()
|
||||
assert 'vm-1/dynamips/test_log.txt' not in myzip.namelist()
|
||||
|
||||
assert 'images/IOS/test.image' not in myzip.namelist()
|
||||
|
||||
assert 'vm-1/dynamips/symlink' in myzip.namelist()
|
||||
zip_info = myzip.getinfo('vm-1/dynamips/symlink')
|
||||
assert stat.S_ISLNK(zip_info.external_attr >> 16)
|
||||
|
||||
with myzip.open("project.gns3") as myfile:
|
||||
topo = json.loads(myfile.read().decode())["topology"]
|
||||
assert topo["nodes"][0]["compute_id"] == "local" # All node should have compute_id local after export
|
||||
|
||||
@@ -23,7 +23,11 @@ import zipfile
|
||||
|
||||
from pathlib import Path
|
||||
from tests.utils import asyncio_patch, AsyncioMagicMock
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
from gns3server.utils.asyncio import aiozipstream
|
||||
from gns3server.controller.project import Project
|
||||
from gns3server.controller.export_project import export_project
|
||||
from gns3server.controller.import_project import import_project, _move_files_to_compute
|
||||
from gns3server.version import __version__
|
||||
|
||||
@@ -111,6 +115,54 @@ async def test_import_project_override(projects_dir, controller):
|
||||
assert project.name == "test"
|
||||
|
||||
|
||||
async def write_file(path, z):
|
||||
|
||||
with open(path, 'wb') as f:
|
||||
async for chunk in z:
|
||||
f.write(chunk)
|
||||
|
||||
|
||||
async def test_import_project_containing_symlink(tmpdir, controller):
|
||||
|
||||
project = Project(controller=controller, name="test")
|
||||
project.dump = MagicMock()
|
||||
path = project.path
|
||||
|
||||
project_id = str(uuid.uuid4())
|
||||
topology = {
|
||||
"project_id": str(uuid.uuid4()),
|
||||
"name": "test",
|
||||
"auto_open": True,
|
||||
"auto_start": True,
|
||||
"topology": {
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
||||
|
||||
with open(os.path.join(path, "project.gns3"), 'w+') as f:
|
||||
json.dump(topology, f)
|
||||
|
||||
os.makedirs(os.path.join(path, "vm1", "dynamips"))
|
||||
symlink_path = os.path.join(project.path, "vm1", "dynamips", "symlink")
|
||||
symlink_target = "/tmp/anywhere"
|
||||
os.symlink(symlink_target, symlink_path)
|
||||
|
||||
zip_path = str(tmpdir / "project.zip")
|
||||
with aiozipstream.ZipFile() as z:
|
||||
with patch("gns3server.compute.Dynamips.get_images_directory", return_value=str(tmpdir / "IOS"),):
|
||||
await export_project(z, project, str(tmpdir), include_images=False)
|
||||
await write_file(zip_path, z)
|
||||
|
||||
with open(zip_path, "rb") as f:
|
||||
project = await import_project(controller, project_id, f)
|
||||
|
||||
assert project.name == "test"
|
||||
assert project.id == project_id
|
||||
symlink_path = os.path.join(project.path, "vm1", "dynamips", "symlink")
|
||||
assert os.path.islink(symlink_path)
|
||||
assert os.readlink(symlink_path) == symlink_target
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_import_upgrade(tmpdir, controller):
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user