mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-21 05:43:12 +00:00
Preserve auto_start/auto_open/auto_close when restoring snapshot
Fixes #1904
This commit is contained in:
parent
150526b1ff
commit
c051367d4b
@ -38,7 +38,8 @@ Handle the import of project from a .gns3project
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
async def import_project(controller, project_id, stream, location=None, name=None, keep_compute_id=False):
|
async def import_project(controller, project_id, stream, location=None, name=None, keep_compute_id=False,
|
||||||
|
auto_start=False, auto_open=False, auto_close=True):
|
||||||
"""
|
"""
|
||||||
Import a project contain in a zip file
|
Import a project contain in a zip file
|
||||||
|
|
||||||
@ -98,9 +99,9 @@ async def import_project(controller, project_id, stream, location=None, name=Non
|
|||||||
topology = load_topology(os.path.join(path, "project.gns3"))
|
topology = load_topology(os.path.join(path, "project.gns3"))
|
||||||
topology["name"] = project_name
|
topology["name"] = project_name
|
||||||
# To avoid unexpected behavior (project start without manual operations just after import)
|
# To avoid unexpected behavior (project start without manual operations just after import)
|
||||||
topology["auto_start"] = False
|
topology["auto_start"] = auto_start
|
||||||
topology["auto_open"] = False
|
topology["auto_open"] = auto_open
|
||||||
topology["auto_close"] = True
|
topology["auto_close"] = auto_close
|
||||||
|
|
||||||
# Generate a new node id
|
# Generate a new node id
|
||||||
node_old_to_new = {}
|
node_old_to_new = {}
|
||||||
|
@ -121,7 +121,9 @@ class Snapshot:
|
|||||||
if os.path.exists(project_files_path):
|
if os.path.exists(project_files_path):
|
||||||
await wait_run_in_executor(shutil.rmtree, project_files_path)
|
await wait_run_in_executor(shutil.rmtree, project_files_path)
|
||||||
with open(self._path, "rb") as f:
|
with open(self._path, "rb") as f:
|
||||||
project = await import_project(self._project.controller, self._project.id, f, location=self._project.path)
|
project = await import_project(self._project.controller, self._project.id, f, location=self._project.path,
|
||||||
|
auto_start=self._project.auto_start, auto_open=self._project.auto_open,
|
||||||
|
auto_close=self._project.auto_close)
|
||||||
except (OSError, PermissionError) as e:
|
except (OSError, PermissionError) as e:
|
||||||
raise aiohttp.web.HTTPConflict(text=str(e))
|
raise aiohttp.web.HTTPConflict(text=str(e))
|
||||||
await project.open()
|
await project.open()
|
||||||
|
Loading…
Reference in New Issue
Block a user