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

Fix issues after merge

This commit is contained in:
grossmj 2024-10-31 13:06:17 +10:00
parent c4fcb43e78
commit 7e902726bf
No known key found for this signature in database
GPG Key ID: 0A2D76AC45EA25CD
3 changed files with 9 additions and 8 deletions

View File

@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import sys
import json import json
import asyncio import asyncio
import aiofiles import aiofiles

View File

@ -1083,7 +1083,7 @@ class Project:
assert self._status != "closed" assert self._status != "closed"
try: try:
proj = await self._fast_duplication(name, location, reset_mac_addresses) proj = await self._fast_duplication(name, reset_mac_addresses)
if proj: if proj:
if previous_status == "closed": if previous_status == "closed":
await self.close() await self.close()
@ -1091,7 +1091,7 @@ class Project:
else: else:
log.info("Fast duplication failed, fallback to normal duplication") log.info("Fast duplication failed, fallback to normal duplication")
except Exception as e: except Exception as e:
raise aiohttp.web.HTTPConflict(text="Cannot duplicate project: {}".format(str(e))) raise ControllerError(f"Cannot duplicate project: {str(e)}")
try: try:
begin = time.time() begin = time.time()
@ -1332,7 +1332,7 @@ class Project:
def __repr__(self): def __repr__(self):
return f"<gns3server.controller.Project {self._name} {self._id}>" return f"<gns3server.controller.Project {self._name} {self._id}>"
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. Fast duplication of a project.
@ -1349,7 +1349,7 @@ class Project:
log.warning("Fast duplication is not supported with remote compute: '{}'".format(compute.id)) log.warning("Fast duplication is not supported with remote compute: '{}'".format(compute.id))
return None return None
# work dir # work dir
p_work = pathlib.Path(location or self.path).parent.absolute() p_work = pathlib.Path(self.path).parent.absolute()
t0 = time.time() t0 = time.time()
new_project_id = str(uuid.uuid4()) new_project_id = str(uuid.uuid4())
new_project_path = p_work.joinpath(new_project_id) new_project_path = p_work.joinpath(new_project_id)

View File

@ -1812,10 +1812,10 @@ async def test_cpus(compute_project, manager):
], ],
"Privileged": True, "Privileged": True,
"Memory": 0, "Memory": 0,
"NanoCpus": 500000000 "NanoCpus": 500000000,
"UsernsMode": "host"
}, },
"Volumes": {}, "Volumes": {},
"UsernsMode": "host",
"NetworkDisabled": True, "NetworkDisabled": True,
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest", "Image": "ubuntu:latest",
@ -1863,10 +1863,10 @@ async def test_memory(compute_project, manager):
], ],
"Privileged": True, "Privileged": True,
"Memory": 33554432, # 32MB in bytes "Memory": 33554432, # 32MB in bytes
"NanoCpus": 0 "NanoCpus": 0,
"UsernsMode": "host",
}, },
"Volumes": {}, "Volumes": {},
"UsernsMode": "host",
"NetworkDisabled": True, "NetworkDisabled": True,
"Hostname": "test", "Hostname": "test",
"Image": "ubuntu:latest", "Image": "ubuntu:latest",