Merge branch '2.2' into 3.0

# Conflicts:
#	gns3server/compute/builtin/nodes/cloud.py
#	gns3server/compute/vmware/vmware_vm.py
#	gns3server/controller/link.py
#	gns3server/controller/snapshot.py
#	gns3server/handlers/api/compute/dynamips_vm_handler.py
#	gns3server/handlers/api/compute/iou_handler.py
#	gns3server/handlers/api/compute/qemu_handler.py
#	gns3server/handlers/api/controller/link_handler.py
#	gns3server/schemas/link.py
#	gns3server/utils/path.py
#	gns3server/version.py
#	requirements.txt
This commit is contained in:
grossmj committed 2021-06-12 14:36:32 +09:30
commit 6ec028ea4e
33 files changed
+310 -469

No files matched your search

+5 -4
View File
@@ -39,7 +39,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
@@ -99,9 +100,9 @@ async def import_project(controller, project_id, stream, location=None, name=Non
topology = load_topology(os.path.join(path, "project.gns3"))
topology["name"] = project_name
# To avoid unexpected behavior (project start without manual operations just after import)
topology["auto_start"] = False
topology["auto_open"] = False
topology["auto_close"] = True
topology["auto_start"] = auto_start
topology["auto_open"] = auto_open
topology["auto_close"] = auto_close
# Generate a new node id
node_old_to_new = {}
+16 -1
View File
@@ -85,6 +85,7 @@ class Link:
self._link_type = "ethernet"
self._suspended = False
self._filters = {}
self._link_style = {}
@property
def filters(self):
@@ -170,6 +171,13 @@ class Link:
self._project.emit_notification("link.updated", self.asdict())
self._project.dump()
async def update_link_style(self, link_style):
if link_style != self._link_style:
self._link_style = link_style
await self.update()
self._project.emit_notification("link.updated", self.__json__())
self._project.dump()
@property
def created(self):
"""
@@ -432,7 +440,13 @@ class Link:
}
)
if topology_dump:
return {"nodes": res, "link_id": self._id, "filters": self._filters, "suspend": self._suspended}
return {
"nodes": res,
"link_id": self._id,
"filters": self._filters,
"link_style": self._link_style,
"suspend": self._suspended,
}
return {
"nodes": res,
"link_id": self._id,
@@ -444,4 +458,5 @@ class Link:
"link_type": self._link_type,
"filters": self._filters,
"suspend": self._suspended,
"link_style": self._link_style,
}
+2
View File
@@ -966,6 +966,8 @@ class Project:
link = await self.add_link(link_id=link_data["link_id"])
if "filters" in link_data:
await link.update_filters(link_data["filters"])
if "link_style" in link_data:
await link.update_link_style(link_data["link_style"])
for node_link in link_data.get("nodes", []):
node = self.get_node(node_link["node_id"])
port = node.get_port(node_link["adapter_number"], node_link["port_number"])
+3 -3
View File
@@ -127,9 +127,9 @@ class Snapshot:
if os.path.exists(project_files_path):
await wait_run_in_executor(shutil.rmtree, project_files_path)
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:
raise ControllerError(str(e))
await project.open()