From 7e902726bf0b787476679c0f4756e94334abb643 Mon Sep 17 00:00:00 2001 From: grossmj Date: Thu, 31 Oct 2024 13:06:17 +1000 Subject: [PATCH] Fix issues after merge --- gns3server/controller/export_project.py | 1 + gns3server/controller/project.py | 8 ++++---- tests/compute/docker/test_docker_vm.py | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gns3server/controller/export_project.py b/gns3server/controller/export_project.py index 0c282f1b..29226fc7 100644 --- a/gns3server/controller/export_project.py +++ b/gns3server/controller/export_project.py @@ -16,6 +16,7 @@ # along with this program. If not, see . import os +import sys import json import asyncio import aiofiles diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 00829912..c1da4586 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -1083,7 +1083,7 @@ class Project: assert self._status != "closed" try: - proj = await self._fast_duplication(name, location, reset_mac_addresses) + proj = await self._fast_duplication(name, reset_mac_addresses) if proj: if previous_status == "closed": await self.close() @@ -1091,7 +1091,7 @@ class Project: else: log.info("Fast duplication failed, fallback to normal duplication") except Exception as e: - raise aiohttp.web.HTTPConflict(text="Cannot duplicate project: {}".format(str(e))) + raise ControllerError(f"Cannot duplicate project: {str(e)}") try: begin = time.time() @@ -1332,7 +1332,7 @@ class Project: def __repr__(self): return f"" - async def _fast_duplication(self, name=None, location=None, reset_mac_addresses=True): + async def _fast_duplication(self, name=None, reset_mac_addresses=True): """ Fast duplication of a project. @@ -1349,7 +1349,7 @@ class Project: log.warning("Fast duplication is not supported with remote compute: '{}'".format(compute.id)) return None # work dir - p_work = pathlib.Path(location or self.path).parent.absolute() + p_work = pathlib.Path(self.path).parent.absolute() t0 = time.time() new_project_id = str(uuid.uuid4()) new_project_path = p_work.joinpath(new_project_id) diff --git a/tests/compute/docker/test_docker_vm.py b/tests/compute/docker/test_docker_vm.py index debae032..c48c301d 100644 --- a/tests/compute/docker/test_docker_vm.py +++ b/tests/compute/docker/test_docker_vm.py @@ -1812,10 +1812,10 @@ async def test_cpus(compute_project, manager): ], "Privileged": True, "Memory": 0, - "NanoCpus": 500000000 + "NanoCpus": 500000000, + "UsernsMode": "host" }, "Volumes": {}, - "UsernsMode": "host", "NetworkDisabled": True, "Hostname": "test", "Image": "ubuntu:latest", @@ -1863,10 +1863,10 @@ async def test_memory(compute_project, manager): ], "Privileged": True, "Memory": 33554432, # 32MB in bytes - "NanoCpus": 0 + "NanoCpus": 0, + "UsernsMode": "host", }, "Volumes": {}, - "UsernsMode": "host", "NetworkDisabled": True, "Hostname": "test", "Image": "ubuntu:latest",