mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-16 08:44:52 +02:00
Add / update docstrings
This commit is contained in:
parent
f7996d5e98
commit
cafdb2522b
@ -1040,14 +1040,16 @@ class Project:
|
|||||||
"""
|
"""
|
||||||
Duplicate a project
|
Duplicate a project
|
||||||
|
|
||||||
It's the save as feature of the 1.X. It's implemented on top of the
|
Implemented on top of the export / import features. It will generate a gns3p and reimport it.
|
||||||
export / import features. It will generate a gns3p and reimport it.
|
|
||||||
It's a little slower but we have only one implementation to maintain.
|
NEW: fast duplication is used if possible (when there are no remote computes).
|
||||||
|
If not, the project is exported and reimported as explained above.
|
||||||
|
|
||||||
:param name: Name of the new project. A new one will be generated in case of conflicts
|
:param name: Name of the new project. A new one will be generated in case of conflicts
|
||||||
:param location: Parent directory of the new project
|
:param location: Parent directory of the new project
|
||||||
:param reset_mac_addresses: Reset MAC addresses for the new project
|
:param reset_mac_addresses: Reset MAC addresses for the new project
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# If the project was not open we open it temporary
|
# If the project was not open we open it temporary
|
||||||
previous_status = self._status
|
previous_status = self._status
|
||||||
if self._status == "closed":
|
if self._status == "closed":
|
||||||
@ -1254,10 +1256,20 @@ class Project:
|
|||||||
return "<gns3server.controller.Project {} {}>".format(self._name, self._id)
|
return "<gns3server.controller.Project {} {}>".format(self._name, self._id)
|
||||||
|
|
||||||
async def _fast_duplication(self, name=None, location=None, reset_mac_addresses=True):
|
async def _fast_duplication(self, name=None, location=None, reset_mac_addresses=True):
|
||||||
|
"""
|
||||||
|
Fast duplication of a project.
|
||||||
|
|
||||||
|
Copy the project files directly rather than in an import-export fashion.
|
||||||
|
|
||||||
|
:param name: Name of the new project. A new one will be generated in case of conflicts
|
||||||
|
:param location: Parent directory of the new project
|
||||||
|
:param reset_mac_addresses: Reset MAC addresses for the new project
|
||||||
|
"""
|
||||||
|
|
||||||
# remote replication is not supported with remote computes
|
# remote replication is not supported with remote computes
|
||||||
for compute in self.computes:
|
for compute in self.computes:
|
||||||
if compute.id != "local":
|
if compute.id != "local":
|
||||||
log.warning("Fast duplication is not support 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(location or self.path).parent.absolute()
|
||||||
@ -1308,4 +1320,4 @@ class Project:
|
|||||||
os.remove(new_project_path.joinpath('{}.gns3'.format(self.name)))
|
os.remove(new_project_path.joinpath('{}.gns3'.format(self.name)))
|
||||||
project = await self.controller.load_project(dot_gns3_path, load=False)
|
project = await self.controller.load_project(dot_gns3_path, load=False)
|
||||||
log.info("Project '{}' fast duplicated in {:.4f} seconds".format(project.name, time.time() - t0))
|
log.info("Project '{}' fast duplicated in {:.4f} seconds".format(project.name, time.time() - t0))
|
||||||
return project
|
return project
|
||||||
|
Loading…
Reference in New Issue
Block a user