mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-23 11:22:21 +03:00
Change project creator on import
Fixes #3017 Signed-off-by: Albert Stefanov <aastefanov@outlook.com>
This commit is contained in:
parent
68c929e224
commit
63d7fec8a7
@ -806,7 +806,12 @@ async def export_project(
|
|||||||
openapi_extra=binary_request_body(ZIP_MEDIA_TYPE),
|
openapi_extra=binary_request_body(ZIP_MEDIA_TYPE),
|
||||||
dependencies=[Depends(has_privilege("Project.Allocate"))],
|
dependencies=[Depends(has_privilege("Project.Allocate"))],
|
||||||
)
|
)
|
||||||
async def import_project(project_id: UUID, request: Request, name: Optional[str] = None) -> schemas.Project:
|
async def import_project(
|
||||||
|
project_id: UUID,
|
||||||
|
request: Request,
|
||||||
|
name: Optional[str] = None,
|
||||||
|
current_user: schemas.User = Depends(get_current_active_user),
|
||||||
|
) -> schemas.Project:
|
||||||
"""
|
"""
|
||||||
Import a project from a portable archive.
|
Import a project from a portable archive.
|
||||||
|
|
||||||
@ -825,7 +830,7 @@ async def import_project(project_id: UUID, request: Request, name: Optional[str]
|
|||||||
async for chunk in request.stream():
|
async for chunk in request.stream():
|
||||||
await f.write(chunk)
|
await f.write(chunk)
|
||||||
with open(temp_project_path, "rb") as f:
|
with open(temp_project_path, "rb") as f:
|
||||||
project = await import_controller_project(controller, str(project_id), f, name=name)
|
project = await import_controller_project(controller, str(project_id), f, name=name, user=current_user.username)
|
||||||
|
|
||||||
log.info(f"Project '{project.name}' imported in {time.time() - begin:.4f} seconds")
|
log.info(f"Project '{project.name}' imported in {time.time() - begin:.4f} seconds")
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
|||||||
@ -51,6 +51,7 @@ async def import_project(
|
|||||||
auto_start=False,
|
auto_start=False,
|
||||||
auto_open=False,
|
auto_open=False,
|
||||||
auto_close=True,
|
auto_close=True,
|
||||||
|
user=None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Import a project contain in a zip file
|
Import a project contain in a zip file
|
||||||
@ -65,6 +66,7 @@ async def import_project(
|
|||||||
:param reset_mac_addresses: Reset MAC addresses for each node
|
:param reset_mac_addresses: Reset MAC addresses for each node
|
||||||
:param keep_compute_ids: keep compute IDs unchanged
|
:param keep_compute_ids: keep compute IDs unchanged
|
||||||
:param project_name: Original project name when restoring a snapshot
|
:param project_name: Original project name when restoring a snapshot
|
||||||
|
:param user: User importing the project
|
||||||
|
|
||||||
:returns: Project
|
:returns: Project
|
||||||
"""
|
"""
|
||||||
@ -120,6 +122,9 @@ async def import_project(
|
|||||||
topology["auto_open"] = auto_open
|
topology["auto_open"] = auto_open
|
||||||
topology["auto_close"] = auto_close
|
topology["auto_close"] = auto_close
|
||||||
|
|
||||||
|
if user:
|
||||||
|
topology["created_by"] = user
|
||||||
|
|
||||||
if not restoring_snapshot:
|
if not restoring_snapshot:
|
||||||
# Do not re-generate IDs if we are restoring a snapshot because they should be the same in a project
|
# Do not re-generate IDs if we are restoring a snapshot because they should be the same in a project
|
||||||
regenerate_topology_ids(topology, path, reset_mac_addresses=reset_mac_addresses)
|
regenerate_topology_ids(topology, path, reset_mac_addresses=reset_mac_addresses)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user